From 570512ac95c5ff14099d36f3e8b8ea24e905e9af Mon Sep 17 00:00:00 2001 From: pantor Date: Sat, 17 Feb 2018 11:49:26 +0100 Subject: [PATCH] fix warnings --- src/inja.hpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/inja.hpp b/src/inja.hpp index 4d63de2..d588e52 100644 --- a/src/inja.hpp +++ b/src/inja.hpp @@ -50,24 +50,24 @@ public: -class Match: public std::smatch { +class Match: public std::match_results { size_t offset_ = 0; unsigned int group_offset_ = 0; Regex regex_; public: - Match(): std::smatch() { } - explicit Match(size_t offset): std::smatch(), offset_(offset) { } - explicit Match(size_t offset, const Regex& regex): std::smatch(), offset_(offset), regex_(regex) { } + Match(): std::match_results() { } + explicit Match(size_t offset): std::match_results(), offset_(offset) { } + explicit Match(size_t offset, const Regex& regex): std::match_results(), offset_(offset), regex_(regex) { } void setGroupOffset(unsigned int group_offset) { group_offset_ = group_offset; } void setRegex(Regex regex) { regex_ = regex; } - size_t position() const { return offset_ + std::smatch::position(); } + size_t position() const { return offset_ + std::match_results::position(); } size_t end_position() const { return position() + length(); } bool found() const { return not empty(); } const std::string str() const { return str(0); } - const std::string str(int i) const { return std::smatch::str(i + group_offset_); } + const std::string str(int i) const { return std::match_results::str(i + group_offset_); } Regex regex() const { return regex_; } }; @@ -100,8 +100,8 @@ public: size_t end_position() const { return close_match.end_position(); } int length() const { return close_match.end_position() - open_match.position(); } bool found() const { return open_match.found() and close_match.found(); } - std::string prefix() const { return open_match.prefix(); } - std::string suffix() const { return close_match.suffix(); } + std::string prefix() const { return open_match.prefix().str(); } + std::string suffix() const { return close_match.suffix().str(); } std::string outer() const { return open_match.str() + static_cast(open_match.suffix()).substr(0, close_match.end_position() - open_match.end_position()); } std::string inner() const { return static_cast(open_match.suffix()).substr(0, close_match.position() - open_match.end_position()); } }; @@ -169,9 +169,9 @@ inline MatchClosed search_closed_on_level(const std::string& input, const Regex& current_position = match_delimiter.end_position(); const std::string inner = match_delimiter.str(1); - if (std::regex_match(inner, regex_search) and level == 0) { break; } - if (std::regex_match(inner, regex_level_up)) { level += 1; } - else if (std::regex_match(inner, regex_level_down)) { level -= 1; } + if (std::regex_match(inner.cbegin(), inner.cend(), regex_search) and level == 0) { break; } + if (std::regex_match(inner.cbegin(), inner.cend(), regex_level_up)) { level += 1; } + else if (std::regex_match(inner.cbegin(), inner.cend(), regex_level_down)) { level -= 1; } match_delimiter = search(input, regex_statement, current_position); } @@ -187,7 +187,7 @@ template inline MatchType match(const std::string& input, std::map regexes) { MatchType match; for (const auto e : regexes) { - if (std::regex_match(input, match, e.second)) { + if (std::regex_match(input.cbegin(), input.cend(), match, e.second)) { match.setType(e.first); match.setRegex(e.second); return match;