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 class Regex
00017 {
00018 public:
00019
00020 Regex (const char*, int = REG_EXTENDED, unsigned int = 10);
00021 Regex (const string&, int = REG_EXTENDED, unsigned int = 10);
00022 ~Regex ();
00023
00024 string getPattern () const { return pattern; };
00025 int getCflags () const { return cflags; }
00026
00027 bool match (const string&, int = 0) const;
00028
00029 regoff_t so (unsigned int) const;
00030 regoff_t eo (unsigned int) const;
00031
00032 string cap (unsigned int) const;
00033
00034 private:
00035 const string pattern;
00036 const int cflags;
00037 const unsigned int nm;
00038
00039 mutable regex_t rx;
00040 mutable int my_nl_msg_cat_cntr;
00041 mutable regmatch_t* rm;
00042
00043 mutable string last_str;
00044 };
00045
00046 #endif