30 inline Foam::label Foam::wordRes::first_match
32 const UList<wordRe>& selectors,
33 const std::string& text,
38 for (
const wordRe&
select : selectors)
40 if (
select.match(text, literal))
56 const std::string& text,
62 if (
select.match(text, literal))
73 const UList<wordRe>& selectors,
74 const std::string& text
77 auto retval(wordRe::compOption::UNKNOWN);
79 for (
const wordRe&
select : selectors)
83 if (
select.match(text,
true))
85 return wordRe::compOption::LITERAL;
91 retval == wordRe::compOption::UNKNOWN
92 &&
select.match(text,
false)
95 retval = wordRe::compOption::REGEX;
103 template<
class StringType>
116 const label len =
input.size();
121 for (label i = 0; i < len; ++i)
129 indices.resize(
count);
135 template<
class StringType>
148 const label len =
input.size();
153 for (label i = 0; i < len; ++i)
161 indices.resize(
count);
182 template<
class StringType>
225 return select_.empty();
230 return (allow_.empty() && deny_.empty());
247 else if (deny_.empty())
static wordRe::compOption matched(const UList< wordRe > &selectors, const std::string &text)
Smart match across entire list, returning the best match type.
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.
bool empty() const noexcept
True if List is empty (ie, size() is zero)
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
static labelList matching(const wordRe &select, const UList< StringType > &input, const bool invert=false)
Determine the list indices for all matches.
static Istream & input(Istream &is, IntRange< T > &range)
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...
matcher(const UList< wordRe > &selectors) noexcept
Construct with select matcher(s)
labelList invert(const label len, const labelUList &map)
Create an inverse one-to-one mapping.
static bool match(const UList< wordRe > &selectors, const std::string &text, bool literal=false)
Test for a match.
bool operator()(const std::string &text) const
True if text matches ANY of the selectors. Always false if entries are empty.
filter(const UList< wordRe > &allow, const UList< wordRe > &deny) noexcept
Construct with 'allow' and 'deny' matchers.
List< label > labelList
A List of labels.
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
No selectors defined.