32 return NullObjectRef<wordRes>();
36 inline Foam::label Foam::wordRes::first_match
39 const std::string& text,
46 if (
select.match(text, literal))
59 const UList<wordRe>& selectors,
60 const std::string& text
63 auto retval(wordRe::compOption::UNKNOWN);
65 for (
const wordRe&
select : selectors)
69 if (
select.match(text,
true))
71 return wordRe::compOption::LITERAL;
77 retval == wordRe::compOption::UNKNOWN
78 &&
select.match(text,
false)
81 retval = wordRe::compOption::REGEX;
93 return (first_match(*
this, text, literal) >= 0);
100 return found_matched(*
this, text);
104 template<
class StringType>
111 const label len =
input.size();
116 for (label i=0; i < len; ++i)
124 indices.resize(
count);
134 return (wordRes::first_match(*
this, text) >= 0);
162 return allow_.empty();
167 return (allow_.empty() && deny_.empty());
173 return (wordRes::first_match(allow_, text) >= 0);
182 return (deny_.empty() || (wordRes::first_match(deny_, text) < 0));
184 else if (deny_.empty())
187 return (wordRes::first_match(allow_, text) >= 0);
192 const auto result = wordRes::found_matched(allow_, text);
201 && (wordRes::first_match(deny_, text) < 0)
bool match(const UList< wordRe > &patterns, const std::string &text)
Return true if text matches one of the regular expressions.
filter(const UList< wordRe > &allow, const UList< wordRe > &deny)
Construct with 'allow' and 'deny' matchers.
labelList matching(const UList< StringType > &input, const bool invert=false) const
Return list indices for all matches.
wordRe::compOption matched(const std::string &text) const
Smart match in the list of matchers, returning the match type.
matcher(const UList< wordRe > &allow)
Construct with 'allow' matcher.
List< bool > select(const label n, const labelUList &locations)
Construct a selection list of bools (all false) with the given pre-size, subsequently add specified l...
compOption
Enumeration with compile options.
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
static const wordRes & null()
Return a null wordRes - a reference to the NullObject.
static Istream & input(Istream &is, IntRange< T > &range)
A List of wordRe with additional matching capabilities.
bool empty() const noexcept
Nothing defined.
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings...
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
labelList invert(const label len, const labelUList &map)
Create an inverse one-to-one mapping.
bool operator()(const std::string &text) const
True if text matches ANY of the entries.
bool match(const std::string &text, bool literal=false) const
Smart match as literal or regex, stopping on the first match.
bool operator()(const std::string &text) const
Identical to match(), for use as a predicate.
bool operator()(const std::string &text) const
True if matched but not blocked.
bool empty() const noexcept
Nothing defined.