source: CMT/v1r25p20140131/source/cmt_symbol.h

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

merge -r 646:663 HEAD

  • Property svn:eol-style set to native
File size: 4.1 KB
Line 
1//-----------------------------------------------------------
2// Copyright Christian Arnault LAL-Orsay CNRS
3// arnault@lal.in2p3.fr
4// Modified by Grigory Rybkin
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
15class SymbolValue
16{
17public:
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
29class SymbolValueList
30{
31public:
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;
37  int print (const Symbol& symbol, const SymbolValue& value, bool& first_definition, ostream& out = cout) const;
38
39  CommandType command_type;
40  Use* use;
41  SymbolValue::SymbolValueVector values;
42  bool is_reflexive;
43  bool discarded;
44};
45
46class Symbol;
47
48class ValueBuilder
49{
50public:
51  ValueBuilder ();
52  const cmt_string build_and_display (const Symbol& symbol);
53  int print (const Symbol& symbol, ostream& out = cout);
54
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;
59 protected:
60  bool m_display_it;
61};
62
63class Symbol
64{
65public:
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 ();
92  static void all_print (PrintMode mode, ostream& out = cout);
93  //static void all_print (PrintMode mode);
94  static void all_print_clean (PrintMode mode);
95  static void check_all_paths ();
96
97  static int symbol_number ();
98  static SymbolVector& symbols ();
99  static SymbolMap& symbol_map ();
100  static SymbolMap& std_env_vars ();
101  static Symbol& symbol (int index);
102  static void clear_all ();
103  static void expand (cmt_string& text);
104
105  static void filter_path_value (const cmt_string& name, cmt_string& text);
106
107  static bool check_tag_used (const Tag* tag);
108
109  static cmt_string get_env_value (const cmt_string& name);
110
111  static bool get_inhibit_display ();
112  static bool set_strip_path (const bool& strip_path);
113
114public:
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);
124  int print (PrintMode mode, ostream& out = cout);
125  //int print (PrintMode mode);
126  cmt_string build_macro_value (bool display_it = false) const;
127  int print_macro (PrintMode mode, ostream& out = cout) const;
128  cmt_string clean_macro_value () const;
129  cmt_string resolve_macro_value (const cmt_string& tag_name = "") const;
130  void show_macro (PrintMode mode, ostream& out = cout);
131  //  void show_macro (PrintMode mode);
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 */
142  bool printed;
143
144private:
145
146  static bool m_inhibit_display;  // Global inhibitor of any display
147
148};
149
150#endif
Note: See TracBrowser for help on using the repository browser.