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 #include <regex.h>
00028 #include <string>
00029 #include <boost/noncopyable.hpp>
00030
00031
00032 namespace storage
00033 {
00034 using std::string;
00035
00036
00037 class Regex : boost::noncopyable
00038 {
00039 public:
00040
00041 Regex (const char* pattern, int cflags = REG_EXTENDED, unsigned int = 10);
00042 Regex (const string& pattern, int cflags = REG_EXTENDED, unsigned int = 10);
00043 ~Regex ();
00044
00045 string getPattern () const { return pattern; }
00046 int getCflags () const { return cflags; }
00047
00048 bool match (const string&, int eflags = 0) const;
00049
00050 regoff_t so (unsigned int) const;
00051 regoff_t eo (unsigned int) const;
00052
00053 string cap (unsigned int) const;
00054
00055 static const string ws;
00056 static const string number;
00057
00058 private:
00059
00060 const string pattern;
00061 const int cflags;
00062 const unsigned int nm;
00063
00064 mutable regex_t rx;
00065 mutable int my_nl_msg_cat_cntr;
00066 mutable regmatch_t* rm;
00067
00068 mutable string last_str;
00069 };
00070
00071 }
00072
00073 #endif