[1] | 1 | #ifndef __cmt_use_h__ |
---|
| 2 | #define __cmt_use_h__ |
---|
| 3 | |
---|
| 4 | #include "cmt_include.h" |
---|
| 5 | #include "cmt_script.h" |
---|
| 6 | #include "cmt_pattern.h" |
---|
| 7 | |
---|
| 8 | class Use |
---|
| 9 | { |
---|
| 10 | public: |
---|
| 11 | typedef cmt_vector<Use> UseVector; |
---|
| 12 | typedef cmt_vector<Use*> UsePtrVector; |
---|
| 13 | |
---|
| 14 | static Use* action (const CmtSystem::cmt_string_vector& words, Use* use); |
---|
| 15 | static Use* find (const cmt_string& package, |
---|
| 16 | const cmt_string& version = "", |
---|
| 17 | const cmt_string& path = ""); |
---|
| 18 | static Use* add (const cmt_string& path, |
---|
| 19 | const cmt_string& package, |
---|
| 20 | const cmt_string& version, |
---|
| 21 | const cmt_string& version_alias, |
---|
| 22 | const cmt_string& path_alias, |
---|
| 23 | Use* context_use); |
---|
| 24 | static void move (Use* use1); |
---|
| 25 | static void reorder (Use* use1, Use* use2); |
---|
| 26 | static void select_clients (const cmt_string& package, |
---|
| 27 | const cmt_string& version); |
---|
| 28 | static void show_all (bool skip_discarded = false); |
---|
| 29 | static void show_all (const cmt_string& prefix, bool skip_discarded = false); |
---|
| 30 | static Use& current (); |
---|
| 31 | static const Use& const_current (); |
---|
| 32 | static UseVector& all_uses (); |
---|
| 33 | static UsePtrVector& uses (); |
---|
| 34 | static void clear_all (); |
---|
| 35 | static void unselect_all (); |
---|
| 36 | static void undiscard_all (); |
---|
| 37 | static void fill_macro_all (cmt_string& buffer, const cmt_string& suffix); |
---|
| 38 | |
---|
| 39 | private: |
---|
| 40 | static Use* create (const cmt_string& path, |
---|
| 41 | const cmt_string& package, |
---|
| 42 | const cmt_string& version, |
---|
| 43 | const cmt_string& version_alias, |
---|
| 44 | const cmt_string& path_alias); |
---|
| 45 | |
---|
| 46 | public: |
---|
| 47 | Use (); |
---|
| 48 | Use (const cmt_string& new_package, |
---|
| 49 | const cmt_string& new_version, |
---|
| 50 | const cmt_string& new_path); |
---|
| 51 | ~Use (); |
---|
| 52 | void set (const cmt_string& new_package, |
---|
| 53 | const cmt_string& new_version, |
---|
| 54 | const cmt_string& new_path, |
---|
| 55 | const cmt_string& new_version_alias = "", |
---|
| 56 | const cmt_string& new_path_alias = ""); |
---|
| 57 | void author_action (const CmtSystem::cmt_string_vector& words); |
---|
| 58 | void manager_action (const CmtSystem::cmt_string_vector& words); |
---|
| 59 | bool move_to (); |
---|
| 60 | void discard (); |
---|
| 61 | void undiscard (); |
---|
| 62 | void apply_global_patterns (); |
---|
| 63 | void set_include_path (const cmt_string& new_path); |
---|
| 64 | |
---|
| 65 | void fill_includes_macro (cmt_string& buffer) const; |
---|
| 66 | void fill_macro (cmt_string& buffer, const cmt_string& suffix) const; |
---|
| 67 | |
---|
| 68 | bool get_paths (Use* to, UsePtrVector& list); |
---|
| 69 | |
---|
| 70 | cmt_string package; /* directly read from requirements */ |
---|
| 71 | cmt_string specified_version; /* idem */ |
---|
| 72 | cmt_string specified_path; /* idem */ |
---|
| 73 | cmt_string version_alias; |
---|
| 74 | cmt_string path_alias; |
---|
| 75 | cmt_string author; /* idem */ |
---|
| 76 | cmt_string manager; /* idem */ |
---|
| 77 | |
---|
| 78 | cmt_string path; /* expanded path */ |
---|
| 79 | cmt_string version; /* idem */ |
---|
| 80 | cmt_string real_path; |
---|
| 81 | CmtDirStyle style; /* May be cmt or mgr */ |
---|
| 82 | |
---|
| 83 | cmt_string prefix; /* upper case copy of package */ |
---|
| 84 | ScopeType cmt_scope; /* copy of the current scope */ |
---|
| 85 | ScopeType scope; /* final scope */ |
---|
| 86 | bool done; /* true when requirements file has |
---|
| 87 | already been read */ |
---|
| 88 | bool discarded; /* discarded by version strategy */ |
---|
| 89 | bool selected; /* used for recursive access */ |
---|
| 90 | |
---|
| 91 | bool auto_imports; |
---|
| 92 | |
---|
| 93 | Include::IncludeVector includes; |
---|
| 94 | cmt_string include_path; |
---|
| 95 | Script::ScriptVector scripts; |
---|
| 96 | ApplyPattern::ApplyPatternVector apply_patterns; |
---|
| 97 | IgnorePattern::IgnorePatternVector ignore_patterns; |
---|
| 98 | |
---|
| 99 | private: |
---|
| 100 | void clear (); |
---|
| 101 | void change_path (const cmt_string& path); |
---|
| 102 | int reach_package (const cmt_string& current_path); |
---|
| 103 | void select (); |
---|
| 104 | void unselect (); |
---|
| 105 | bool is_selected (); |
---|
| 106 | bool is_client (const cmt_string& package, |
---|
| 107 | const cmt_string& version); |
---|
| 108 | void show_sub_uses (bool skip_discarded = false); |
---|
| 109 | bool select_alternate (); |
---|
| 110 | Use* get_selected_version (); |
---|
| 111 | static bool need_new (const cmt_string& path, |
---|
| 112 | const cmt_string& package, |
---|
| 113 | const cmt_string& version, |
---|
| 114 | Use** old_use); |
---|
| 115 | |
---|
| 116 | UsePtrVector sub_uses; |
---|
| 117 | CmtSystem::cmt_string_vector alternate_versions; |
---|
| 118 | CmtSystem::cmt_string_vector alternate_paths; |
---|
| 119 | }; |
---|
| 120 | |
---|
| 121 | #endif |
---|