[2] | 1 | //----------------------------------------------------------- |
---|
| 2 | // Copyright Christian Arnault LAL-Orsay CNRS |
---|
| 3 | // arnault@lal.in2p3.fr |
---|
[663] | 4 | // Modified by Grigory Rybkin |
---|
[2] | 5 | // See the complete license in cmt_license.txt "http://www.cecill.info". |
---|
| 6 | //----------------------------------------------------------- |
---|
| 7 | |
---|
| 8 | #ifndef __cmt_symbol_h__ |
---|
| 9 | #define __cmt_symbol_h__ |
---|
| 10 | |
---|
| 11 | #include "cmt_tag.h" |
---|
| 12 | #include "cmt_use.h" |
---|
| 13 | #include "cmt_map.h" |
---|
| 14 | |
---|
| 15 | class SymbolValue |
---|
| 16 | { |
---|
| 17 | public: |
---|
| 18 | typedef cmt_vector<SymbolValue> SymbolValueVector; |
---|
| 19 | |
---|
| 20 | SymbolValue (); |
---|
| 21 | ~SymbolValue (); |
---|
| 22 | |
---|
| 23 | Tag* tag; |
---|
| 24 | cmt_string text; /* A symbol value is created only if */ |
---|
| 25 | /* its text is non empty */ |
---|
| 26 | int selected; |
---|
| 27 | }; |
---|
| 28 | |
---|
| 29 | class SymbolValueList |
---|
| 30 | { |
---|
| 31 | public: |
---|
| 32 | typedef cmt_vector<SymbolValueList> SymbolValueListVector; |
---|
| 33 | |
---|
| 34 | int select_first (const cmt_string& tag_name = "") const; |
---|
| 35 | int select_last () const; |
---|
| 36 | void show (const Symbol& symbol, const SymbolValue& value, bool& first_definition) const; |
---|
[656] | 37 | int print (const Symbol& symbol, const SymbolValue& value, bool& first_definition, ostream& out = cout) const; |
---|
[2] | 38 | |
---|
| 39 | CommandType command_type; |
---|
| 40 | Use* use; |
---|
| 41 | SymbolValue::SymbolValueVector values; |
---|
| 42 | bool is_reflexive; |
---|
| 43 | bool discarded; |
---|
| 44 | }; |
---|
| 45 | |
---|
| 46 | class Symbol; |
---|
| 47 | |
---|
| 48 | class ValueBuilder |
---|
| 49 | { |
---|
| 50 | public: |
---|
[3] | 51 | ValueBuilder (); |
---|
| 52 | const cmt_string build_and_display (const Symbol& symbol); |
---|
[549] | 53 | int print (const Symbol& symbol, ostream& out = cout); |
---|
[3] | 54 | |
---|
[2] | 55 | virtual const cmt_string build (const Symbol& symbol, |
---|
| 56 | const cmt_string& tag_name = "") = 0; |
---|
| 57 | virtual const cmt_string clean (const Symbol& symbol, |
---|
| 58 | const cmt_string& tag_name = "") = 0; |
---|
[3] | 59 | protected: |
---|
| 60 | bool m_display_it; |
---|
[2] | 61 | }; |
---|
| 62 | |
---|
| 63 | class Symbol |
---|
| 64 | { |
---|
| 65 | public: |
---|
| 66 | typedef cmt_vector<Symbol> SymbolVector; |
---|
| 67 | typedef cmt_map<cmt_string, Symbol> SymbolMap; |
---|
| 68 | |
---|
| 69 | typedef enum |
---|
| 70 | { |
---|
| 71 | SymbolUndefined, |
---|
| 72 | SymbolAction, |
---|
| 73 | SymbolAlias, |
---|
| 74 | SymbolMacro, |
---|
| 75 | SymbolSetupScript, |
---|
| 76 | SymbolCleanupScript, |
---|
| 77 | SymbolSet, |
---|
| 78 | SymbolPath |
---|
| 79 | } SymbolType; |
---|
| 80 | |
---|
| 81 | static Symbol* create (const cmt_string& name, |
---|
| 82 | CommandType command, |
---|
| 83 | Use* use = 0); |
---|
| 84 | |
---|
| 85 | static Symbol* find (const cmt_string& name); |
---|
| 86 | static void action (const CmtSystem::cmt_string_vector& words, |
---|
| 87 | CommandType command_type, |
---|
| 88 | Use* use); |
---|
| 89 | static int is_selected (const cmt_string& name); |
---|
| 90 | |
---|
| 91 | static void all_set (); |
---|
[656] | 92 | static void all_print (PrintMode mode, ostream& out = cout); |
---|
| 93 | //static void all_print (PrintMode mode); |
---|
[2] | 94 | static void all_print_clean (PrintMode mode); |
---|
[144] | 95 | static void check_all_paths (); |
---|
[2] | 96 | |
---|
| 97 | static int symbol_number (); |
---|
| 98 | static SymbolVector& symbols (); |
---|
| 99 | static SymbolMap& symbol_map (); |
---|
[656] | 100 | static SymbolMap& std_env_vars (); |
---|
[2] | 101 | static Symbol& symbol (int index); |
---|
| 102 | static void clear_all (); |
---|
| 103 | static void expand (cmt_string& text); |
---|
| 104 | |
---|
[102] | 105 | static void filter_path_value (const cmt_string& name, cmt_string& text); |
---|
| 106 | |
---|
[588] | 107 | static bool check_tag_used (const Tag* tag); |
---|
[3] | 108 | |
---|
[136] | 109 | static cmt_string get_env_value (const cmt_string& name); |
---|
| 110 | |
---|
| 111 | static bool get_inhibit_display (); |
---|
[659] | 112 | static bool set_strip_path (const bool& strip_path); |
---|
[136] | 113 | |
---|
[2] | 114 | public: |
---|
| 115 | Symbol (); |
---|
| 116 | ~Symbol (); |
---|
| 117 | bool value_is_reflexive (const cmt_string& text) const; |
---|
| 118 | void add_value_to_list (CommandType command_type, |
---|
| 119 | Use* use, |
---|
| 120 | Tag* tag, |
---|
| 121 | const cmt_string& text); |
---|
| 122 | |
---|
| 123 | int print_clean (PrintMode mode); |
---|
[656] | 124 | int print (PrintMode mode, ostream& out = cout); |
---|
| 125 | //int print (PrintMode mode); |
---|
[3] | 126 | cmt_string build_macro_value (bool display_it = false) const; |
---|
[549] | 127 | int print_macro (PrintMode mode, ostream& out = cout) const; |
---|
[2] | 128 | cmt_string clean_macro_value () const; |
---|
[588] | 129 | cmt_string resolve_macro_value (const cmt_string& tag_name = "") const; |
---|
[547] | 130 | void show_macro (PrintMode mode, ostream& out = cout); |
---|
| 131 | // void show_macro (PrintMode mode); |
---|
[2] | 132 | |
---|
| 133 | ValueBuilder* builder; |
---|
| 134 | |
---|
| 135 | cmt_string name; |
---|
| 136 | ScopeType scope; |
---|
| 137 | SymbolType type; |
---|
| 138 | |
---|
| 139 | SymbolValueList::SymbolValueListVector value_lists; |
---|
| 140 | |
---|
| 141 | int selected_value; /* according to the last selected tag */ |
---|
[549] | 142 | bool printed; |
---|
[136] | 143 | |
---|
| 144 | private: |
---|
| 145 | |
---|
| 146 | static bool m_inhibit_display; // Global inhibitor of any display |
---|
| 147 | |
---|
[2] | 148 | }; |
---|
| 149 | |
---|
| 150 | #endif |
---|