#ifndef __cmt_use_h__ #define __cmt_use_h__ #include "cmt_include.h" #include "cmt_script.h" #include "cmt_pattern.h" class Use { public: typedef cmt_vector UseVector; typedef cmt_vector UsePtrVector; static Use* action (const CmtSystem::cmt_string_vector& words, Use* use); static Use* find (const cmt_string& package, const cmt_string& version = "", const cmt_string& path = ""); static int find_index (const cmt_string& package, const cmt_string& version, const cmt_string& path); static void set_auto_imports_state (int use_index, cmt_vector& auto_imports_states); static Use* add (const cmt_string& path, const cmt_string& package, const cmt_string& version, const cmt_string& version_alias, const cmt_string& path_alias, Use* context_use, State specified_auto_imports = Unspecified); static void move (Use* use1); static void reorder (Use* use1, Use* use2); static void select_clients (const cmt_string& package, const cmt_string& version); static void show_all (bool skip_discarded = false); static void show_all (const cmt_string& prefix, bool skip_discarded = false); static Use& current (); static const Use& const_current (); static UseVector& all_uses (); static UsePtrVector& uses (); static void clear_all (); static void unselect_all (); static void undiscard_all (); static void fill_macro_all (cmt_string& buffer, const cmt_string& suffix); private: static Use* create (const cmt_string& path, const cmt_string& package, const cmt_string& version, const cmt_string& version_alias, const cmt_string& path_alias); public: Use (); Use (const cmt_string& new_package, const cmt_string& new_version, const cmt_string& new_path); ~Use (); void set (const cmt_string& new_package, const cmt_string& new_version, const cmt_string& new_path, const cmt_string& new_version_alias = "", const cmt_string& new_path_alias = ""); void author_action (const CmtSystem::cmt_string_vector& words); void manager_action (const CmtSystem::cmt_string_vector& words); bool move_to (); void discard (); void undiscard (); void apply_global_patterns (); void set_include_path (const cmt_string& new_path); void get_full_path (cmt_string& s) const; cmt_string get_full_path () const; void reduce_path (cmt_string& s) const; void fill_includes_macro (cmt_string& buffer) const; void fill_macro (cmt_string& buffer, const cmt_string& suffix) const; bool get_paths (Use* to, UsePtrVector& list); bool located () const; void change_path (const cmt_string& path); void set_auto_imports (State new_state); void set_native_version (bool state); bool has_native_version () const; cmt_string package; /* directly read from requirements */ cmt_string specified_version; /* idem */ cmt_string specified_path; /* idem */ cmt_string version_alias; cmt_string path_alias; cmt_string author; /* idem */ cmt_string manager; /* idem */ cmt_string path; /* expanded path */ cmt_string version; /* idem */ cmt_string real_path; CmtDirStyle style; /* May be cmt or mgr */ cmt_string prefix; /* upper case copy of package */ ScopeType scope; /* copy of the current scope */ bool done; /* true when requirements file has already been read */ bool discarded; /* discarded by version strategy */ bool selected; /* used for recursive access */ State auto_imports; Include::IncludeVector includes; cmt_string include_path; Script::ScriptVector scripts; ApplyPattern::ApplyPatternVector apply_patterns; IgnorePattern::IgnorePatternVector ignore_patterns; private: void clear (); int reach_package (const cmt_string& current_path); void select (); void unselect (); bool is_selected (); bool is_client (const cmt_string& package, const cmt_string& version); void show_sub_uses (bool skip_discarded = false); bool select_alternate (); Use* get_selected_version (); static bool need_new (const cmt_string& path, const cmt_string& package, const cmt_string& version, Use** old_use); bool m_located; bool m_has_native_version; UsePtrVector sub_uses; cmt_vector sub_use_scopes; cmt_vector sub_use_auto_imports; CmtSystem::cmt_string_vector alternate_versions; CmtSystem::cmt_string_vector alternate_paths; }; #endif