00001 #ifndef REGEX_H
00002 #define REGEX_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <sys/types.h>
00011 #include <regex.h>
00012 #include <string>
00013
00014 using std::string;
00015
00016 namespace storage
00017 {
00018
00019 class Regex
00020 {
00021 public:
00022
00023 Regex (const char*, int = REG_EXTENDED, unsigned int = 10);
00024 Regex (const string&, int = 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 = 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 static const string& ws;
00037 static const string& number;
00038
00039 private:
00040 const string pattern;
00041 const int cflags;
00042 const unsigned int nm;
00043
00044 mutable regex_t rx;
00045 mutable int my_nl_msg_cat_cntr;
00046 mutable regmatch_t* rm;
00047
00048 mutable string last_str;
00049 };
00050
00051 }
00052
00053 #endif