1 | #ifndef __cmt_pattern_h__ |
---|
2 | #define __cmt_pattern_h__ |
---|
3 | |
---|
4 | #include "cmt_parser.h" |
---|
5 | #include "cmt_system.h" |
---|
6 | |
---|
7 | class Use; |
---|
8 | |
---|
9 | class Template |
---|
10 | { |
---|
11 | public: |
---|
12 | typedef cmt_vector<Template> TemplateVector; |
---|
13 | cmt_string name; |
---|
14 | cmt_string value; |
---|
15 | }; |
---|
16 | |
---|
17 | class Pattern |
---|
18 | { |
---|
19 | public: |
---|
20 | typedef cmt_vector<Pattern> PatternVector; |
---|
21 | |
---|
22 | static void action (const CmtSystem::cmt_string_vector& words, Use* use); |
---|
23 | |
---|
24 | static Pattern* find (const cmt_string& name); |
---|
25 | static Pattern* find (const cmt_string& name, Use* use); |
---|
26 | static void add (const cmt_string& name, |
---|
27 | const CmtSystem::cmt_string_vector& words, |
---|
28 | int start_index, |
---|
29 | bool global, |
---|
30 | Use* use); |
---|
31 | |
---|
32 | static int pattern_number (); |
---|
33 | static Pattern& pattern (int index); |
---|
34 | static void clear_all (); |
---|
35 | static PatternVector& patterns (); |
---|
36 | |
---|
37 | static void apply_all_globals (); |
---|
38 | static void show_all_names (); |
---|
39 | static void show_all (); |
---|
40 | static void show (const cmt_string& name); |
---|
41 | |
---|
42 | public: |
---|
43 | Pattern (); |
---|
44 | ~Pattern (); |
---|
45 | |
---|
46 | void clear (); |
---|
47 | void apply () const; |
---|
48 | void apply (Use* constext_use) const; |
---|
49 | void apply (Use* constext_use, |
---|
50 | const Template::TemplateVector& templates) const; |
---|
51 | void expand (Use* constext_use, |
---|
52 | const Template::TemplateVector& templates, |
---|
53 | cmt_string& line) const; |
---|
54 | |
---|
55 | cmt_string name; |
---|
56 | CmtSystem::cmt_string_vector words; |
---|
57 | bool global; |
---|
58 | Use* use; |
---|
59 | }; |
---|
60 | |
---|
61 | class ApplyPattern |
---|
62 | { |
---|
63 | public: |
---|
64 | typedef cmt_vector<ApplyPattern> ApplyPatternVector; |
---|
65 | |
---|
66 | static void action (const CmtSystem::cmt_string_vector& words, |
---|
67 | Use* use); |
---|
68 | |
---|
69 | static ApplyPattern* add (const cmt_string& name, Use* use); |
---|
70 | |
---|
71 | public: |
---|
72 | ApplyPattern (); |
---|
73 | ~ApplyPattern (); |
---|
74 | |
---|
75 | void show () const; |
---|
76 | void apply_globals () const; |
---|
77 | void apply () const; |
---|
78 | |
---|
79 | cmt_string name; |
---|
80 | Use* use; |
---|
81 | cmt_vector<Template> replacements; |
---|
82 | }; |
---|
83 | |
---|
84 | class IgnorePattern |
---|
85 | { |
---|
86 | public: |
---|
87 | typedef cmt_vector<IgnorePattern> IgnorePatternVector; |
---|
88 | |
---|
89 | static void action (const CmtSystem::cmt_string_vector& words, Use* use); |
---|
90 | |
---|
91 | static IgnorePattern* find (const cmt_string& name, Use* use); |
---|
92 | static void add (const cmt_string& name, Use* use); |
---|
93 | |
---|
94 | public: |
---|
95 | IgnorePattern (); |
---|
96 | ~IgnorePattern (); |
---|
97 | |
---|
98 | void show () const; |
---|
99 | |
---|
100 | cmt_string name; |
---|
101 | Use* use; |
---|
102 | }; |
---|
103 | |
---|
104 | #endif |
---|