00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef REGEX_H
00024 #define REGEX_H
00025
00026
00027
00028
00029
00030
00031
00032 #include <regex.h>
00033 #include <string>
00034 #include <boost/noncopyable.hpp>
00035
00036 using std::string;
00037
00038 namespace storage
00039 {
00040
00041 class Regex : boost::noncopyable
00042 {
00043 public:
00044
00045 Regex (const char* pattern, int cflags = REG_EXTENDED, unsigned int = 10);
00046 Regex (const string& pattern, int cflags = REG_EXTENDED, unsigned int = 10);
00047 ~Regex ();
00048
00049 string getPattern () const { return pattern; };
00050 int getCflags () const { return cflags; }
00051
00052 bool match (const string&, int eflags = 0) const;
00053
00054 regoff_t so (unsigned int) const;
00055 regoff_t eo (unsigned int) const;
00056
00057 string cap (unsigned int) const;
00058
00059 static const string ws;
00060 static const string number;
00061
00062 private:
00063
00064 const string pattern;
00065 const int cflags;
00066 const unsigned int nm;
00067
00068 mutable regex_t rx;
00069 mutable int my_nl_msg_cat_cntr;
00070 mutable regmatch_t* rm;
00071
00072 mutable string last_str;
00073 };
00074
00075 }
00076
00077 #endif