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