E-MailRelay
|
Utility functions for lists of strings. More...
Classes | |
struct | Filter |
Filters a list of strings with allow and deny lists. More... | |
Enumerations | |
enum class | Ignore { Case , Nothing } |
Functions | |
void | keepMatch (StringArray &list, const StringArray &allow_list, Ignore=Ignore::Nothing) |
Removes items in the list that do not match any entry in the allow list. More... | |
void | applyMatch (StringArray &list, const StringArray &allow_list, Ignore=Ignore::Nothing) |
Removes items in the list that do not match any entry in the allow list and reorders the result to be the same as the allow list. More... | |
void | removeMatch (StringArray &list, const StringArray &deny_list, Ignore=Ignore::Nothing) |
Removes items in the list that match an entry in the deny list. More... | |
bool | headMatch (const StringArray &list, std::string_view head) |
Returns true if any string in the array has the given start (or 'head' is empty). More... | |
bool | tailMatch (const StringArray &list, std::string_view ending) |
Returns true if any string in the array has the given ending (or the given ending is empty). More... | |
std::string | headMatchResidue (const StringArray &list, std::string_view head) |
Returns the unmatched part of the first string in the array that has the given start. More... | |
bool | match (const StringArray &, const std::string &) |
Returns true if any string in the array matches the given string. More... | |
bool | imatch (const StringArray &, const std::string &) |
Returns true if any string in the array matches the given string, ignoring case. More... | |
Utility functions for lists of strings.
|
strong |
Definition at line 35 of file gstringlist.h.
void G::StringList::applyMatch | ( | StringArray & | list, |
const StringArray & | allow_list, | ||
Ignore | = Ignore::Nothing |
||
) |
Removes items in the list that do not match any entry in the allow list and reorders the result to be the same as the allow list.
Optionally uses a case-insensitive match.
bool G::StringList::headMatch | ( | const StringArray & | list, |
std::string_view | head | ||
) |
Returns true if any string in the array has the given start (or 'head' is empty).
Definition at line 78 of file gstringlist.cpp.
std::string G::StringList::headMatchResidue | ( | const StringArray & | list, |
std::string_view | head | ||
) |
Returns the unmatched part of the first string in the array that has the given start.
Returns the empty string if nothing matches or if the first match is an exact match for the whole string.
Definition at line 92 of file gstringlist.cpp.
bool G::StringList::imatch | ( | const StringArray & | a, |
const std::string & | b | ||
) |
Returns true if any string in the array matches the given string, ignoring case.
Definition at line 108 of file gstringlist.cpp.
void G::StringList::keepMatch | ( | StringArray & | list, |
const StringArray & | allow_list, | ||
Ignore | ignore = Ignore::Nothing |
||
) |
Removes items in the list that do not match any entry in the allow list.
Optionally uses a case-insensitive match.
Definition at line 59 of file gstringlist.cpp.
bool G::StringList::match | ( | const StringArray & | a, |
const std::string & | b | ||
) |
Returns true if any string in the array matches the given string.
Definition at line 103 of file gstringlist.cpp.
void G::StringList::removeMatch | ( | StringArray & | list, |
const StringArray & | deny_list, | ||
Ignore | ignore = Ignore::Nothing |
||
) |
Removes items in the list that match an entry in the deny list.
Optionally uses a case-insensitive match.
Definition at line 69 of file gstringlist.cpp.
bool G::StringList::tailMatch | ( | const StringArray & | list, |
std::string_view | ending | ||
) |
Returns true if any string in the array has the given ending (or the given ending is empty).
Definition at line 85 of file gstringlist.cpp.