source: CMT/v1r18p20041201/source/cmt_pattern.h @ 1

Last change on this file since 1 was 1, checked in by arnault, 19 years ago

Import all tags

File size: 3.6 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_pattern_h__
8#define __cmt_pattern_h__
9
10#include "cmt_map.h"
11#include "cmt_parser.h"
12#include "cmt_system.h"
13
14class Use;
15
16class Template
17{
18public:
19  typedef cmt_vector<Template> TemplateVector;
20  cmt_string name;
21  cmt_string value;
22};
23
24class Pattern
25{
26public:
27  typedef cmt_vector<Pattern> PatternVector;
28  typedef cmt_vector<Pattern*> PatternPtrVector;
29
30  static void action (const CmtSystem::cmt_string_vector& words, Use* use);
31
32  static Pattern* find (const cmt_string& name);
33  static Pattern* find (const cmt_string& name, Use* use);
34  static void add (const cmt_string& name,
35                   const CmtSystem::cmt_string_vector& words,
36                   int start_index,
37                   bool global,
38                   Use* use);
39
40  static int pattern_number ();
41  static Pattern& pattern (int index);
42  static void clear_all ();
43  static PatternVector& patterns ();
44
45  static void apply_all_globals ();
46  static void apply_all_globals (Use* use);
47  static void show_all_names ();
48  static void show_all ();
49  static void show_all_applied_patterns ();
50  static void show (const cmt_string& name);
51
52public:
53  Pattern ();
54  ~Pattern ();
55
56  void clear ();
57  void apply () const;
58  void apply (Use* constext_use) const;
59  void apply (Use* constext_use,
60              const Template::TemplateVector& templates) const;
61  void expand (Use* constext_use,
62               const Template::TemplateVector& templates,
63               cmt_string& line) const;
64  void show () const;
65
66  cmt_string name;
67  cmt_string line;
68  bool global;
69  Use* use;
70};
71
72class PatternList
73{
74public:
75
76  typedef cmt_map<cmt_string, PatternList> PatternListMap;
77  typedef cmt_vector<PatternList> PatternListVector;
78
79  static PatternList* find (const cmt_string& name);
80  static Pattern* find_pattern (const cmt_string& name);
81  static Pattern* find (const cmt_string& name, Use* use);
82
83  static PatternList* add (const cmt_string& name);
84
85  static void clear_all ();
86  static PatternListMap& pattern_list_map ();
87  static PatternListVector& pattern_lists ();
88
89  static void apply_all_globals ();
90  static void apply_all_globals (Use* use);
91  static void show_all_patterns ();
92  static void show_all_pattern_names ();
93
94public:
95  PatternList ();
96  PatternList (const cmt_string& name);
97  ~PatternList ();
98
99  Pattern::PatternPtrVector& get_patterns ();
100
101  void add_pattern (Pattern* pattern);
102
103  void clear ();
104
105  cmt_string m_name;
106  Pattern::PatternPtrVector m_patterns;
107};
108
109class ApplyPattern
110{
111public:
112  typedef cmt_vector<ApplyPattern> ApplyPatternVector;
113
114  static void action (const CmtSystem::cmt_string_vector& words,
115                      Use* use);
116
117  static ApplyPattern* add (const cmt_string& name, Use* use);
118
119public:
120  ApplyPattern ();
121  ~ApplyPattern ();
122
123  void show () const;
124  void apply_globals () const;
125  void apply () const;
126
127  cmt_string name;
128  Use* use;
129  cmt_vector<Template> replacements;
130};
131
132class IgnorePattern
133{
134public:
135  typedef cmt_vector<IgnorePattern> IgnorePatternVector;
136
137  static void action (const CmtSystem::cmt_string_vector& words, Use* use);
138
139  static IgnorePattern* find (const cmt_string& name, Use* use);
140  static void add (const cmt_string& name, Use* use);
141
142public:
143  IgnorePattern ();
144  ~IgnorePattern ();
145
146  void show () const;
147
148  cmt_string name;
149  Use* use;
150};
151
152#endif
Note: See TracBrowser for help on using the repository browser.