mirror of
https://github.com/mawww/kakoune.git
synced 2024-12-19 09:21:30 +03:00
Regex: Remove helper functions from regex_impl.hh
They were close duplicates from the ones in regex.hh and not used anywhere else.
This commit is contained in:
parent
6c4faf2050
commit
d9e44dfacf
22
src/regex.hh
22
src/regex.hh
@ -113,21 +113,29 @@ inline RegexExecFlags match_flags(bool bol, bool eol, bool bow, bool eow, bool b
|
|||||||
template<typename It>
|
template<typename It>
|
||||||
bool regex_match(It begin, It end, const Regex& re)
|
bool regex_match(It begin, It end, const Regex& re)
|
||||||
{
|
{
|
||||||
return regex_match(begin, end, *re.impl());
|
ThreadedRegexVM<It, MatchDirection::Forward> vm{*re.impl()};
|
||||||
|
return vm.exec(begin, end, RegexExecFlags::AnyMatch | RegexExecFlags::NoSaves);
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
res.values().clear();
|
res.values().clear();
|
||||||
return regex_match(begin, end, res.values(), *re.impl());
|
ThreadedRegexVM<It, MatchDirection::Forward> vm{*re.impl()};
|
||||||
|
if (vm.exec(begin, end, RegexExecFlags::None))
|
||||||
|
{
|
||||||
|
std::copy(vm.captures().begin(), vm.captures().end(), std::back_inserter(res.values()));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename It>
|
template<typename It>
|
||||||
bool regex_search(It begin, It end, const Regex& re,
|
bool regex_search(It begin, It end, const Regex& re,
|
||||||
RegexExecFlags flags = RegexExecFlags::None)
|
RegexExecFlags flags = RegexExecFlags::None)
|
||||||
{
|
{
|
||||||
return regex_search(begin, end, *re.impl(), flags);
|
ThreadedRegexVM<It, MatchDirection::Forward> vm{*re.impl()};
|
||||||
|
return vm.exec(begin, end, flags | RegexExecFlags::Search | RegexExecFlags::AnyMatch | RegexExecFlags::NoSaves);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename It, MatchDirection direction = MatchDirection::Forward>
|
template<typename It, MatchDirection direction = MatchDirection::Forward>
|
||||||
@ -135,7 +143,13 @@ bool regex_search(It begin, It end, MatchResults<It>& res, const Regex& re,
|
|||||||
RegexExecFlags flags = RegexExecFlags::None)
|
RegexExecFlags flags = RegexExecFlags::None)
|
||||||
{
|
{
|
||||||
res.values().clear();
|
res.values().clear();
|
||||||
return regex_search<It, direction>(begin, end, res.values(), *re.impl(), flags);
|
ThreadedRegexVM<It, direction> vm{*re.impl()};
|
||||||
|
if (vm.exec(begin, end, flags | RegexExecFlags::Search))
|
||||||
|
{
|
||||||
|
std::move(vm.captures().begin(), vm.captures().end(), std::back_inserter(res.values()));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename It>
|
template<typename It>
|
||||||
|
@ -573,48 +573,6 @@ private:
|
|||||||
Saves* m_captures = nullptr;
|
Saves* m_captures = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename It, MatchDirection direction = MatchDirection::Forward>
|
|
||||||
bool regex_match(It begin, It end, const CompiledRegex& re, RegexExecFlags flags = RegexExecFlags::None)
|
|
||||||
{
|
|
||||||
ThreadedRegexVM<It, direction> vm{re};
|
|
||||||
return vm.exec(begin, end, (RegexExecFlags)(flags & ~(RegexExecFlags::Search)) |
|
|
||||||
RegexExecFlags::AnyMatch | RegexExecFlags::NoSaves);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename It, MatchDirection direction = MatchDirection::Forward>
|
|
||||||
bool regex_match(It begin, It end, Vector<It, MemoryDomain::Regex>& captures, const CompiledRegex& re,
|
|
||||||
RegexExecFlags flags = RegexExecFlags::None)
|
|
||||||
{
|
|
||||||
ThreadedRegexVM<It, direction> vm{re};
|
|
||||||
if (vm.exec(begin, end, flags & ~(RegexExecFlags::Search)))
|
|
||||||
{
|
|
||||||
std::copy(vm.captures().begin(), vm.captures().end(), std::back_inserter(captures));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename It, MatchDirection direction = MatchDirection::Forward>
|
|
||||||
bool regex_search(It begin, It end, const CompiledRegex& re,
|
|
||||||
RegexExecFlags flags = RegexExecFlags::None)
|
|
||||||
{
|
|
||||||
ThreadedRegexVM<It, direction> vm{re};
|
|
||||||
return vm.exec(begin, end, flags | RegexExecFlags::Search | RegexExecFlags::AnyMatch | RegexExecFlags::NoSaves);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename It, MatchDirection direction = MatchDirection::Forward>
|
|
||||||
bool regex_search(It begin, It end, Vector<It, MemoryDomain::Regex>& captures, const CompiledRegex& re,
|
|
||||||
RegexExecFlags flags = RegexExecFlags::None)
|
|
||||||
{
|
|
||||||
ThreadedRegexVM<It, direction> vm{re};
|
|
||||||
if (vm.exec(begin, end, flags | RegexExecFlags::Search))
|
|
||||||
{
|
|
||||||
std::move(vm.captures().begin(), vm.captures().end(), std::back_inserter(captures));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // regex_impl_hh_INCLUDED
|
#endif // regex_impl_hh_INCLUDED
|
||||||
|
Loading…
Reference in New Issue
Block a user