Rev | Line | |
---|
[1] | 1 | //----------------------------------------------------------- |
---|
| 2 | // Copyright Christian Arnault LAL-Orsay CNRS |
---|
| 3 | // arnault@lal.in2p3.fr |
---|
| 4 | // See the complete license in cmt_license.txt "http://www.cecill.info". |
---|
| 5 | //----------------------------------------------------------- |
---|
| 6 | |
---|
| 7 | #ifndef __cmt_regexp_h__ |
---|
| 8 | #define __cmt_regexp_h__ |
---|
| 9 | |
---|
| 10 | #include "cmt_string.h" |
---|
| 11 | |
---|
| 12 | class cmt_regexp_node; |
---|
| 13 | |
---|
| 14 | class cmt_regexp |
---|
| 15 | { |
---|
| 16 | public: |
---|
| 17 | cmt_regexp (); |
---|
| 18 | cmt_regexp (const cmt_string& expression); |
---|
| 19 | ~cmt_regexp (); |
---|
| 20 | |
---|
| 21 | void set (const cmt_string& expression); |
---|
| 22 | |
---|
| 23 | bool is_valid () const; |
---|
| 24 | |
---|
| 25 | class iterator |
---|
| 26 | { |
---|
| 27 | public: |
---|
| 28 | static const iterator null (); |
---|
| 29 | |
---|
| 30 | public: |
---|
| 31 | iterator (); |
---|
| 32 | iterator (int pos, int length); |
---|
| 33 | iterator (const iterator& other); |
---|
| 34 | |
---|
| 35 | int operator != (const iterator& other) const; |
---|
| 36 | int operator == (const iterator& other) const; |
---|
| 37 | int operator < (const iterator& other) const; |
---|
| 38 | |
---|
| 39 | cmt_string operator () (const cmt_string& text) const; |
---|
| 40 | |
---|
| 41 | int _pos; |
---|
| 42 | int _length; |
---|
| 43 | }; |
---|
| 44 | |
---|
| 45 | iterator begin (const cmt_string& text, int pos = 0); |
---|
| 46 | iterator end (); |
---|
| 47 | |
---|
| 48 | iterator begin (const cmt_string& text, int pos = 0) const; |
---|
| 49 | iterator end () const; |
---|
| 50 | |
---|
| 51 | bool match (const cmt_string& text) const; |
---|
| 52 | |
---|
| 53 | private: |
---|
| 54 | |
---|
| 55 | cmt_regexp_node* _root; |
---|
| 56 | }; |
---|
| 57 | |
---|
| 58 | #endif |
---|
| 59 | |
---|
Note: See
TracBrowser
for help on using the repository browser.