00001 // -*- indent-tabs-mode: nil -*- 00002 00003 #ifndef __ARC_REGEX_H__ 00004 #define __ARC_REGEX_H__ 00005 00006 #include <list> 00007 #include <string> 00008 #include <regex.h> 00009 00010 namespace Arc { 00011 00013 00016 class RegularExpression { 00017 public: 00018 00020 RegularExpression() : status(-1) {} 00021 00023 RegularExpression(std::string pattern); 00024 00026 RegularExpression(const RegularExpression& regex); 00027 00029 ~RegularExpression(); 00030 00032 RegularExpression& operator=(const RegularExpression& regex); 00033 00035 bool isOk(); 00036 00038 bool hasPattern(std::string str); 00039 00041 bool match(const std::string& str) const; 00042 00044 00050 bool match(const std::string& str, std::list<std::string>& unmatched, std::list<std::string>& matched) const; 00051 00053 std::string getPattern() const; 00054 00055 private: 00056 std::string pattern; 00057 regex_t preg; 00058 int status; 00059 }; 00060 } 00061 00062 #endif