Main?Page | Class?Hierarchy | Class?List | File?List | Class?Members | File?Members

cmt_pattern.h

Go to the documentation of this file.
00001 //-----------------------------------------------------------
00002 // Copyright Christian Arnault LAL-Orsay CNRS
00003 // 
00004 // See the complete license in cmt_license.txt "http://www.cecill.info". 
00005 //-----------------------------------------------------------
00006 
00007 #ifndef __cmt_pattern_h__
00008 #define __cmt_pattern_h__
00009 
00010 #include "cmt_map.h"
00011 #include "cmt_parser.h"
00012 #include "cmt_system.h"
00013 
00014 class Use;
00015 
00016 class Template
00017 {
00018 public:
00019   typedef cmt_vector TemplateVector;
00020   cmt_string name;
00021   cmt_string value;
00022 };
00023 
00024 class Pattern
00025 {
00026 public:
00027   typedef cmt_vector PatternVector;
00028   typedef cmt_vector PatternPtrVector;
00029 
00030   static void action (const CmtSystem::cmt_string_vector& words, Use* use);
00031 
00032   static Pattern* find (const cmt_string& name);
00033   static Pattern* find (const cmt_string& name, Use* use);
00034   static void add (const cmt_string& name,
00035                    const CmtSystem::cmt_string_vector& words,
00036                    int start_index,
00037                    bool global,
00038                    Use* use);
00039 
00040   static int pattern_number ();
00041   static Pattern& pattern (int index);
00042   static void clear_all ();
00043   static PatternVector& patterns ();
00044 
00045   static void apply_all_globals ();
00046   static void apply_all_globals (Use* use);
00047   static void show_all_names ();
00048   static void show_all ();
00049   static void show_all_applied_patterns ();
00050   static void show (const cmt_string& name);
00051 
00052 public:
00053   Pattern ();
00054   ~Pattern ();
00055 
00056   void clear ();
00057   void apply () const;
00058   void apply (Use* constext_use) const;
00059   void apply (Use* constext_use,
00060               const Template::TemplateVector& templates) const;
00061   void expand (Use* constext_use,
00062                const Template::TemplateVector& templates,
00063                cmt_string& line) const;
00064   void show () const;
00065 
00066   cmt_string name;
00067   cmt_string line;
00068   bool global;
00069   Use* use;
00070 };
00071 
00072 class PatternList
00073 {
00074 public:
00075 
00076   typedef cmt_map PatternListMap;
00077   typedef cmt_vector PatternListVector;
00078 
00079   static PatternList* find (const cmt_string& name);
00080   static Pattern* find_pattern (const cmt_string& name);
00081   static Pattern* find (const cmt_string& name, Use* use);
00082 
00083   static PatternList* add (const cmt_string& name);
00084 
00085   static void clear_all ();
00086   static PatternListMap& pattern_list_map ();
00087   static PatternListVector& pattern_lists ();
00088 
00089   static void apply_all_globals ();
00090   static void apply_all_globals (Use* use);
00091   static void show_all_patterns ();
00092   static void show_all_pattern_names ();
00093 
00094 public:
00095   PatternList ();
00096   PatternList (const cmt_string& name);
00097   ~PatternList ();
00098 
00099   Pattern::PatternPtrVector& get_patterns ();
00100 
00101   void add_pattern (Pattern* pattern);
00102 
00103   void clear ();
00104 
00105   cmt_string m_name;
00106   Pattern::PatternPtrVector m_patterns;
00107 };
00108 
00109 class ApplyPattern
00110 {
00111 public:
00112   typedef cmt_vector ApplyPatternVector;
00113 
00114   static void action (const CmtSystem::cmt_string_vector& words,
00115                       Use* use);
00116 
00117   static ApplyPattern* add (const cmt_string& name, Use* use);
00118 
00119 public:
00120   ApplyPattern ();
00121   ~ApplyPattern ();
00122 
00123   void show () const;
00124   void apply_globals () const;
00125   void apply () const;
00126 
00127   cmt_string name;
00128   Use* use;
00129   cmt_vector replacements;
00130 };
00131 
00132 class IgnorePattern
00133 {
00134 public:
00135   typedef cmt_vector IgnorePatternVector;
00136 
00137   static void action (const CmtSystem::cmt_string_vector& words, Use* use);
00138 
00139   static IgnorePattern* find (const cmt_string& name, Use* use);
00140   static void add (const cmt_string& name, Use* use);
00141 
00142 public:
00143   IgnorePattern ();
00144   ~IgnorePattern ();
00145 
00146   void show () const;
00147 
00148   cmt_string name;
00149   Use* use;
00150 };
00151 
00152 #endif

Generated on Mon May 2 10:25:05 2005 for CMT by 1.3.5