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