//----------------------------------------------------------- // Copyright Christian Arnault LAL-Orsay CNRS // arnault@lal.in2p3.fr // See the complete license in cmt_license.txt "http://www.cecill.info". //----------------------------------------------------------- #ifndef __cmt_symbol_h__ #define __cmt_symbol_h__ #include "cmt_tag.h" #include "cmt_use.h" #include "cmt_map.h" class SymbolValue { public: typedef cmt_vector SymbolValueVector; SymbolValue (); ~SymbolValue (); Tag* tag; cmt_string text; /* A symbol value is created only if */ /* its text is non empty */ int selected; }; class SymbolValueList { public: typedef cmt_vector SymbolValueListVector; int select_first (const cmt_string& tag_name = "") const; int select_last () const; void show (const Symbol& symbol, const SymbolValue& value, bool& first_definition) const; CommandType command_type; Use* use; SymbolValue::SymbolValueVector values; bool is_reflexive; bool discarded; }; class Symbol; class ValueBuilder { public: virtual const cmt_string build (const Symbol& symbol, const cmt_string& tag_name = "") = 0; virtual const cmt_string clean (const Symbol& symbol, const cmt_string& tag_name = "") = 0; }; class Symbol { public: typedef cmt_vector SymbolVector; typedef cmt_map SymbolMap; typedef enum { SymbolUndefined, SymbolAction, SymbolAlias, SymbolMacro, SymbolSetupScript, SymbolCleanupScript, SymbolSet, SymbolPath } SymbolType; static Symbol* create (const cmt_string& name, CommandType command, Use* use = 0); static Symbol* find (const cmt_string& name); static void action (const CmtSystem::cmt_string_vector& words, CommandType command_type, Use* use); static int is_selected (const cmt_string& name); static void all_set (); static void all_print (PrintMode mode); static void all_print_clean (PrintMode mode); static int symbol_number (); static SymbolVector& symbols (); static SymbolMap& symbol_map (); static Symbol& symbol (int index); static void clear_all (); static void expand (cmt_string& text); public: Symbol (); ~Symbol (); bool value_is_reflexive (const cmt_string& text) const; void add_value_to_list (CommandType command_type, Use* use, Tag* tag, const cmt_string& text); int print_clean (PrintMode mode); int print (PrintMode mode); cmt_string build_macro_value () const; cmt_string clean_macro_value () const; cmt_string resolve_macro_value (const cmt_string& tag_name = ""); void show_macro (PrintMode mode); ValueBuilder* builder; cmt_string name; ScopeType scope; SymbolType type; SymbolValueList::SymbolValueListVector value_lists; int selected_value; /* according to the last selected tag */ }; #endif