Regex: Use MemoryDomain::Regex for captures and MatchResults contents
This commit is contained in:
parent
c9b43d3634
commit
5cfccad39c
10
src/regex.hh
10
src/regex.hh
|
@ -47,7 +47,7 @@ struct MatchResults
|
||||||
|
|
||||||
struct iterator : std::iterator<std::bidirectional_iterator_tag, SubMatch, size_t, SubMatch*, SubMatch>
|
struct iterator : std::iterator<std::bidirectional_iterator_tag, SubMatch, size_t, SubMatch*, SubMatch>
|
||||||
{
|
{
|
||||||
using It = typename Vector<Iterator>::const_iterator;
|
using It = typename Vector<Iterator, MemoryDomain::Regex>::const_iterator;
|
||||||
|
|
||||||
iterator() = default;
|
iterator() = default;
|
||||||
iterator(It it) : m_it{std::move(it)} {}
|
iterator(It it) : m_it{std::move(it)} {}
|
||||||
|
@ -64,7 +64,7 @@ struct MatchResults
|
||||||
};
|
};
|
||||||
|
|
||||||
MatchResults() = default;
|
MatchResults() = default;
|
||||||
MatchResults(Vector<Iterator> values) : m_values{std::move(values)} {}
|
MatchResults(Vector<Iterator, MemoryDomain::Regex> values) : m_values{std::move(values)} {}
|
||||||
|
|
||||||
iterator begin() const { return iterator{m_values.begin()}; }
|
iterator begin() const { return iterator{m_values.begin()}; }
|
||||||
iterator cbegin() const { return iterator{m_values.cbegin()}; }
|
iterator cbegin() const { return iterator{m_values.cbegin()}; }
|
||||||
|
@ -96,7 +96,7 @@ struct MatchResults
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Vector<Iterator> m_values;
|
Vector<Iterator, MemoryDomain::Regex> m_values;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline RegexExecFlags match_flags(bool bol, bool eol, bool bow, bool eow)
|
inline RegexExecFlags match_flags(bool bol, bool eol, bool bow, bool eow)
|
||||||
|
@ -116,7 +116,7 @@ bool regex_match(It begin, It end, const Regex& re)
|
||||||
template<typename It>
|
template<typename It>
|
||||||
bool regex_match(It begin, It end, MatchResults<It>& res, const Regex& re)
|
bool regex_match(It begin, It end, MatchResults<It>& res, const Regex& re)
|
||||||
{
|
{
|
||||||
Vector<It> captures;
|
Vector<It, MemoryDomain::Regex> captures;
|
||||||
const bool matched = regex_match(begin, end, captures, *re.impl());
|
const bool matched = regex_match(begin, end, captures, *re.impl());
|
||||||
res = matched ? MatchResults<It>{std::move(captures)} : MatchResults<It>{};
|
res = matched ? MatchResults<It>{std::move(captures)} : MatchResults<It>{};
|
||||||
return matched;
|
return matched;
|
||||||
|
@ -133,7 +133,7 @@ template<typename It, MatchDirection direction = MatchDirection::Forward>
|
||||||
bool regex_search(It begin, It end, MatchResults<It>& res, const Regex& re,
|
bool regex_search(It begin, It end, MatchResults<It>& res, const Regex& re,
|
||||||
RegexExecFlags flags = RegexExecFlags::None)
|
RegexExecFlags flags = RegexExecFlags::None)
|
||||||
{
|
{
|
||||||
Vector<It> captures;
|
Vector<It, MemoryDomain::Regex> captures;
|
||||||
const bool matched = regex_search<It, direction>(begin, end, captures, *re.impl(), flags);
|
const bool matched = regex_search<It, direction>(begin, end, captures, *re.impl(), flags);
|
||||||
res = matched ? MatchResults<It>{std::move(captures)} : MatchResults<It>{};
|
res = matched ? MatchResults<It>{std::move(captures)} : MatchResults<It>{};
|
||||||
return matched;
|
return matched;
|
||||||
|
|
|
@ -517,7 +517,7 @@ bool regex_match(It begin, It end, const CompiledRegex& re, RegexExecFlags flags
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename It, MatchDirection direction = MatchDirection::Forward>
|
template<typename It, MatchDirection direction = MatchDirection::Forward>
|
||||||
bool regex_match(It begin, It end, Vector<It>& captures, const CompiledRegex& re,
|
bool regex_match(It begin, It end, Vector<It, MemoryDomain::Regex>& captures, const CompiledRegex& re,
|
||||||
RegexExecFlags flags = RegexExecFlags::None)
|
RegexExecFlags flags = RegexExecFlags::None)
|
||||||
{
|
{
|
||||||
ThreadedRegexVM<It, direction> vm{re};
|
ThreadedRegexVM<It, direction> vm{re};
|
||||||
|
@ -538,7 +538,7 @@ bool regex_search(It begin, It end, const CompiledRegex& re,
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename It, MatchDirection direction = MatchDirection::Forward>
|
template<typename It, MatchDirection direction = MatchDirection::Forward>
|
||||||
bool regex_search(It begin, It end, Vector<It>& captures, const CompiledRegex& re,
|
bool regex_search(It begin, It end, Vector<It, MemoryDomain::Regex>& captures, const CompiledRegex& re,
|
||||||
RegexExecFlags flags = RegexExecFlags::None)
|
RegexExecFlags flags = RegexExecFlags::None)
|
||||||
{
|
{
|
||||||
ThreadedRegexVM<It, direction> vm{re};
|
ThreadedRegexVM<It, direction> vm{re};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user