Add vector parameter functions to and/or matchers

This commit is contained in:
Jan 2021-11-04 20:31:20 +01:00
parent 69c08def7f
commit 38551f29de
3 changed files with 20 additions and 0 deletions

View File

@ -90,11 +90,21 @@ public:
return MatcherFactoryWrapper<TokenType>(std::make_unique<MatcherAnd<TokenType>>(matchers)); return MatcherFactoryWrapper<TokenType>(std::make_unique<MatcherAnd<TokenType>>(matchers));
} }
_NODISCARD MatcherFactoryWrapper<TokenType> And(std::vector<std::unique_ptr<AbstractMatcher<TokenType>>> matchers) const
{
return MatcherFactoryWrapper<TokenType>(std::make_unique<MatcherAnd<TokenType>>(std::move(matchers)));
}
_NODISCARD MatcherFactoryWrapper<TokenType> Or(std::initializer_list<Movable<std::unique_ptr<AbstractMatcher<TokenType>>>> matchers) const _NODISCARD MatcherFactoryWrapper<TokenType> Or(std::initializer_list<Movable<std::unique_ptr<AbstractMatcher<TokenType>>>> matchers) const
{ {
return MatcherFactoryWrapper<TokenType>(std::make_unique<MatcherOr<TokenType>>(matchers)); return MatcherFactoryWrapper<TokenType>(std::make_unique<MatcherOr<TokenType>>(matchers));
} }
_NODISCARD MatcherFactoryWrapper<TokenType> Or(std::vector<std::unique_ptr<AbstractMatcher<TokenType>>> matchers) const
{
return MatcherFactoryWrapper<TokenType>(std::make_unique<MatcherOr<TokenType>>(std::move(matchers)));
}
_NODISCARD MatcherFactoryWrapper<TokenType> Loop(std::unique_ptr<AbstractMatcher<TokenType>> matcher) const _NODISCARD MatcherFactoryWrapper<TokenType> Loop(std::unique_ptr<AbstractMatcher<TokenType>> matcher) const
{ {
return MatcherFactoryWrapper<TokenType>(std::make_unique<MatcherLoop<TokenType>>(std::move(matcher))); return MatcherFactoryWrapper<TokenType>(std::make_unique<MatcherLoop<TokenType>>(std::move(matcher)));

View File

@ -37,4 +37,9 @@ public:
: m_matchers(std::make_move_iterator(matchers.begin()), std::make_move_iterator(matchers.end())) : m_matchers(std::make_move_iterator(matchers.begin()), std::make_move_iterator(matchers.end()))
{ {
} }
explicit MatcherAnd(std::vector<std::unique_ptr<AbstractMatcher<TokenType>>> matchers)
: m_matchers(std::move(matchers))
{
}
}; };

View File

@ -35,4 +35,9 @@ public:
: m_matchers(std::make_move_iterator(matchers.begin()), std::make_move_iterator(matchers.end())) : m_matchers(std::make_move_iterator(matchers.begin()), std::make_move_iterator(matchers.end()))
{ {
} }
explicit MatcherOr(std::vector<std::unique_ptr<AbstractMatcher<TokenType>>> matchers)
: m_matchers(std::move(matchers))
{
}
}; };