[1] | 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 apply_all_globals (Use* use); |
---|
| 39 | static void show_all_names (); |
---|
| 40 | static void show_all (); |
---|
| 41 | static void show_all_applied_patterns (); |
---|
| 42 | static void show (const cmt_string& name); |
---|
| 43 | |
---|
| 44 | public: |
---|
| 45 | Pattern (); |
---|
| 46 | ~Pattern (); |
---|
| 47 | |
---|
| 48 | void clear (); |
---|
| 49 | void apply () const; |
---|
| 50 | void apply (Use* constext_use) const; |
---|
| 51 | void apply (Use* constext_use, |
---|
| 52 | const Template::TemplateVector& templates) const; |
---|
| 53 | void expand (Use* constext_use, |
---|
| 54 | const Template::TemplateVector& templates, |
---|
| 55 | cmt_string& line) const; |
---|
| 56 | |
---|
| 57 | cmt_string name; |
---|
| 58 | CmtSystem::cmt_string_vector words; |
---|
| 59 | bool global; |
---|
| 60 | Use* use; |
---|
| 61 | }; |
---|
| 62 | |
---|
| 63 | class ApplyPattern |
---|
| 64 | { |
---|
| 65 | public: |
---|
| 66 | typedef cmt_vector<ApplyPattern> ApplyPatternVector; |
---|
| 67 | |
---|
| 68 | static void action (const CmtSystem::cmt_string_vector& words, |
---|
| 69 | Use* use); |
---|
| 70 | |
---|
| 71 | static ApplyPattern* add (const cmt_string& name, Use* use); |
---|
| 72 | |
---|
| 73 | public: |
---|
| 74 | ApplyPattern (); |
---|
| 75 | ~ApplyPattern (); |
---|
| 76 | |
---|
| 77 | void show () const; |
---|
| 78 | void apply_globals () const; |
---|
| 79 | void apply () const; |
---|
| 80 | |
---|
| 81 | cmt_string name; |
---|
| 82 | Use* use; |
---|
| 83 | cmt_vector<Template> replacements; |
---|
| 84 | }; |
---|
| 85 | |
---|
| 86 | class IgnorePattern |
---|
| 87 | { |
---|
| 88 | public: |
---|
| 89 | typedef cmt_vector<IgnorePattern> IgnorePatternVector; |
---|
| 90 | |
---|
| 91 | static void action (const CmtSystem::cmt_string_vector& words, Use* use); |
---|
| 92 | |
---|
| 93 | static IgnorePattern* find (const cmt_string& name, Use* use); |
---|
| 94 | static void add (const cmt_string& name, Use* use); |
---|
| 95 | |
---|
| 96 | public: |
---|
| 97 | IgnorePattern (); |
---|
| 98 | ~IgnorePattern (); |
---|
| 99 | |
---|
| 100 | void show () const; |
---|
| 101 | |
---|
| 102 | cmt_string name; |
---|
| 103 | Use* use; |
---|
| 104 | }; |
---|
| 105 | |
---|
| 106 | #endif |
---|