|
Aegis
4.25.D505
|
00001 // 00002 // aegis - project change supervisor 00003 // Copyright (C) 2004-2006, 2008, 2009, 2012 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 00057 regular_expression(const nstring &pattern, bool icase = false); 00058 00073 bool matches(const char *text, size_t &so, size_t &eo); 00074 00088 bool match(const nstring &arg, size_t offset = 0); 00089 00094 const char *strerror() const; 00095 00113 bool match_and_substitute(const nstring &rhs, const nstring &actual, 00114 long how_many_times, nstring &output); 00115 00116 private: 00121 nstring errstr; 00122 00131 void set_error(int err); 00132 00137 nstring lhs; 00138 00143 bool icase; 00144 00150 bool compile(); 00151 00156 bool compiled; 00157 00162 regex_t preg; 00163 00168 regmatch_t regmatch[10]; 00169 00173 regular_expression(); 00174 00178 regular_expression(const regular_expression &); 00179 00183 regular_expression &operator=(const regular_expression &); 00184 }; 00185 00186 #endif // COMMON_REGULA_EXPRE_H 00187 // vim: set ts=8 sw=4 et :
1.7.6.1