source: CMT/v1r20p20070208/source/cmt_symbol.h

Last change on this file was 144, checked in by arnault, 18 years ago

Various fixes and message cleanups see CL 294 and 295

  • Property svn:eol-style set to native
File size: 3.5 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
37  CommandType command_type;
38  Use* use;
39  SymbolValue::SymbolValueVector values;
40  bool is_reflexive;
41  bool discarded;
42};
43
44class Symbol;
45
46class ValueBuilder
47{
48public:
49  ValueBuilder ();
50  const cmt_string build_and_display (const Symbol& symbol);
51
52  virtual const cmt_string build (const Symbol& symbol,
53                                  const cmt_string& tag_name = "") = 0;
54  virtual const cmt_string clean (const Symbol& symbol,
55                                  const cmt_string& tag_name = "") = 0;
56 protected:
57  bool m_display_it;
58};
59
60class Symbol
61{
62public:
63  typedef cmt_vector<Symbol> SymbolVector;
64  typedef cmt_map<cmt_string, Symbol> SymbolMap;
65
66  typedef enum
67    {
68      SymbolUndefined,
69      SymbolAction,
70      SymbolAlias,
71      SymbolMacro,
72      SymbolSetupScript,
73      SymbolCleanupScript,
74      SymbolSet,
75      SymbolPath
76    } SymbolType;
77
78  static Symbol* create (const cmt_string& name,
79                         CommandType command,
80                         Use* use = 0);
81 
82  static Symbol* find (const cmt_string& name);
83  static void action (const CmtSystem::cmt_string_vector& words,
84                      CommandType command_type,
85                      Use* use);
86  static int is_selected (const cmt_string& name);
87
88  static void all_set ();
89  static void all_print (PrintMode mode);
90  static void all_print_clean (PrintMode mode);
91  static void check_all_paths ();
92
93  static int symbol_number ();
94  static SymbolVector& symbols ();
95  static SymbolMap& symbol_map ();
96  static Symbol& symbol (int index);
97  static void clear_all ();
98  static void expand (cmt_string& text);
99
100  static void filter_path_value (const cmt_string& name, cmt_string& text);
101
102  static bool check_tag_used (Tag* tag);
103
104  static cmt_string get_env_value (const cmt_string& name);
105
106  static bool get_inhibit_display ();
107
108public:
109  Symbol ();
110  ~Symbol ();
111  bool value_is_reflexive (const cmt_string& text) const;
112  void add_value_to_list (CommandType command_type,
113                          Use* use,
114                          Tag* tag,
115                          const cmt_string& text);
116
117  int print_clean (PrintMode mode);
118  int print (PrintMode mode);
119  cmt_string build_macro_value (bool display_it = false) const;
120  cmt_string clean_macro_value () const;
121  cmt_string resolve_macro_value (const cmt_string& tag_name = "");
122  void show_macro (PrintMode mode);
123
124  ValueBuilder* builder;
125
126  cmt_string name;
127  ScopeType scope;
128  SymbolType type;
129
130  SymbolValueList::SymbolValueListVector value_lists;
131
132  int selected_value;        /* according to the last selected tag */
133
134private:
135
136  static bool m_inhibit_display;  // Global inhibitor of any display
137
138};
139
140#endif
Note: See TracBrowser for help on using the repository browser.