00001 //----------------------------------------------------------- 00002 // Copyright Christian Arnault LAL-Orsay CNRS 00003 // arnault@lal.in2p3.fr 00004 // See the complete license in cmt_license.txt "http://www.cecill.info". 00005 //----------------------------------------------------------- 00006 00007 #ifndef __cmt_regexp_h__ 00008 #define __cmt_regexp_h__ 00009 00010 #include "cmt_string.h" 00011 00012 class cmt_regexp_node; 00013 00014 class cmt_regexp 00015 { 00016 public: 00017 cmt_regexp (); 00018 cmt_regexp (const cmt_string& expression); 00019 ~cmt_regexp (); 00020 00021 void set (const cmt_string& expression); 00022 00023 bool is_valid () const; 00024 00025 class iterator 00026 { 00027 public: 00028 static const iterator null (); 00029 00030 public: 00031 iterator (); 00032 iterator (int pos, int length); 00033 iterator (const iterator& other); 00034 00035 int operator != (const iterator& other) const; 00036 int operator == (const iterator& other) const; 00037 int operator < (const iterator& other) const; 00038 00039 cmt_string operator () (const cmt_string& text) const; 00040 00041 int _pos; 00042 int _length; 00043 }; 00044 00045 iterator begin (const cmt_string& text, int pos = 0); 00046 iterator end (); 00047 00048 iterator begin (const cmt_string& text, int pos = 0) const; 00049 iterator end () const; 00050 00051 bool match (const cmt_string& text) const; 00052 00053 private: 00054 00055 cmt_regexp_node* _root; 00056 }; 00057 00058 #endif 00059