mirror of
https://github.com/pantor/inja.git
synced 2026-04-04 23:28:52 +00:00
fix warnings
This commit is contained in:
24
src/inja.hpp
24
src/inja.hpp
@@ -50,24 +50,24 @@ public:
|
||||
|
||||
|
||||
|
||||
class Match: public std::smatch {
|
||||
class Match: public std::match_results<std::string::const_iterator> {
|
||||
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<std::string::const_iterator>() { }
|
||||
explicit Match(size_t offset): std::match_results<std::string::const_iterator>(), offset_(offset) { }
|
||||
explicit Match(size_t offset, const Regex& regex): std::match_results<std::string::const_iterator>(), 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<std::string::const_iterator>::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<std::string::const_iterator>::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<std::string>(open_match.suffix()).substr(0, close_match.end_position() - open_match.end_position()); }
|
||||
std::string inner() const { return static_cast<std::string>(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<typename T>
|
||||
inline MatchType<T> match(const std::string& input, std::map<T, Regex> regexes) {
|
||||
MatchType<T> 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;
|
||||
|
||||
Reference in New Issue
Block a user