00001 // 00002 // aegis - project change supervisor 00003 // Copyright (C) 2004-2006, 2008 Peter Miller 00004 // 00005 // This program is free software; you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation; either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // This program is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with this program. If not, see 00017 // <http://www.gnu.org/licenses/>. 00018 // 00019 00020 #ifndef COMMON_REGULA_EXPRE_H 00021 #define COMMON_REGULA_EXPRE_H 00022 00023 #include <common/ac/regex.h> 00024 #include <common/nstring.h> 00025 00038 class regular_expression 00039 { 00040 public: 00044 virtual ~regular_expression(); 00045 00055 regular_expression(const nstring &arg); 00056 00070 bool match(const nstring &arg, size_t offset = 0); 00071 00076 const char *strerror() const; 00077 00095 bool match_and_substitute(const nstring &rhs, const nstring &actual, 00096 long how_many_times, nstring &output); 00097 00098 private: 00103 nstring errstr; 00104 00113 void set_error(int err); 00114 00119 nstring lhs; 00120 00126 bool compile(); 00127 00132 bool compiled; 00133 00138 regex_t preg; 00139 00144 regmatch_t regmatch[10]; 00145 00149 regular_expression(); 00150 00154 regular_expression(const regular_expression &); 00155 00159 regular_expression &operator=(const regular_expression &); 00160 }; 00161 00162 #endif // COMMON_REGULA_EXPRE_H