source: CMT/HEAD/source/cmt_symbol.h @ 659

Last change on this file since 659 was 659, checked in by rybkin, 10 years ago

See C.L. 518

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