upgraded to C++17 compatibility

This commit is contained in:
Marc Wäckerlin
2018-11-21 15:24:07 +00:00
parent 4528cd8d78
commit 80c80e9cc4
50 changed files with 1893 additions and 1231 deletions
+4 -4
View File
@@ -25,25 +25,25 @@
namespace mrw {
RegExp::RegExp(const std::string& pattern, bool hassub, int flags)
throw(std::exception):
:
_hassub(hassub) {
if (flags&nosub) throw mrw::invalid_argument("nosub");
if (regcomp(&_regex, pattern.c_str(), (_hassub?flags:(flags|nosub))))
throw mrw::invalid_argument(pattern);
}
RegExp::~RegExp() throw() {
RegExp::~RegExp() noexcept {
regfree(&_regex);
}
bool RegExp::operator()(const std::string& text) throw(std::bad_exception) {
bool RegExp::operator()(const std::string& text) {
if (_hassub)
return !regexec(&_regex, (_text=text).c_str(), MAX_SUB, _sub, 0);
else
return !regexec(&_regex, text.c_str(), 0, 0, 0);
}
std::string RegExp::operator[](unsigned int n) const throw(std::exception) {
std::string RegExp::operator[](unsigned int n) const {
if (!_hassub)
throw mrw::invalid_argument("initialized with no sub expressions");
if (n>=MAX_SUB || _sub[n].rm_so<0 || _sub[n].rm_eo<0)