00001 #ifndef REGEXEXCEPTION_H
00002 #define REGEXEXCEPTION_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <tagcoll/Exception.h>
00025 #include <sys/types.h>
00026 #include <regex.h>
00027
00028 namespace Debtags
00029 {
00030
00032
00033 class RegexpException : public SystemException
00034 {
00035 protected:
00036 std::string _message;
00037
00038 public:
00039 RegexpException(const regex_t& re, int code, const std::string& context)
00040 throw ();
00041 ~RegexpException() throw () {}
00042
00043 virtual const char* type() const throw () { return "RegexpException"; }
00044 virtual std::string desc() const throw () { return _message + " " + _context; }
00045 };
00046
00047 class Regexp
00048 {
00049 protected:
00050 regex_t re;
00051 regmatch_t* pmatch;
00052 int nmatch;
00053 std::string lastMatch;
00054
00055 public:
00056 Regexp(const std::string& expr, int match_count = 0, int flags = 0) throw (RegexpException);
00057 ~Regexp() throw ();
00058
00059 bool match(const std::string& str, int flags = 0) throw (RegexpException);
00060
00061 std::string operator[](int idx) throw (OutOfRangeException);
00062 };
00063
00064 class ExtendedRegexp : public Regexp
00065 {
00066 public:
00067 ExtendedRegexp(const std::string& expr, int match_count = 0, int flags = 0) throw (RegexpException)
00068 : Regexp(expr, match_count, flags | REG_EXTENDED) {}
00069 };
00070
00071 };
00072
00073
00074 #endif