|
General-purpose key matcher: tests string equality, or regExp, if defined as such. More...
#include <StringMatcher.h>
Public Member Functions | |
StringMatcher (const std::string &s="") | |
StringMatcher (const StringMatcher &matcher) | |
void | set (const std::string &s) |
Assign string which may be literal or a regular expression. | |
bool | operator== (const std::string &s) const |
bool | operator== (const char *s) const |
bool | operator== (const StringMatcher &m) const |
bool | test (const std::string &s) const |
Test with direct string matching or regExp, if defined. | |
const std::string & | getType () const |
Public Attributes | |
const std::string & | value |
Visible reference to the RegExp. | |
Static Public Attributes | |
static const std::string | regExpSpecialChars = "^.?*[]()$" |
Protected Attributes | |
bool | isRegExp |
Checks if the key conforms to ODIM convention: DBZH, VRAD, etc. (capital letters, underscores) More... | |
Protected Attributes inherited from RegExp | |
regex_t | regExpBinary |
std::string | regExpString |
result_t | writableResult |
const std::vector< std::string > & | result |
Public interface for the result. | |
int | flags |
Additional Inherited Members | |
Protected Types inherited from RegExp | |
typedef std::vector< std::string > | result_t |
Native result type, also for external result object. | |
Protected Member Functions inherited from RegExp | |
RegExp (const std::string &str="", int flags=REG_EXTENDED) | |
Constructor. More... | |
RegExp (const RegExp &r) | |
Copy constructor. | |
virtual | ~RegExp () |
Destructor. | |
RegExp & | operator= (const std::string &str) |
RegExp & | operator= (const RegExp &r) |
bool | setExpression (const std::string &str, int flags=REG_EXTENDED) |
void | clear () |
bool | isSet () const |
void | reset () |
bool | empty () const |
Returns true, if expression is empty. | |
void | setFlags (int flags) |
bool | test (const std::string &str) const |
Tests if the regular expression accepts the given std::string. More... | |
template<class T > | |
int | execute (const std::string &str, T &result) const |
Apply regexp matching in a string. Returns 0 on success, REG_NOMATCH on failure. More... | |
int | execute (const std::string &str) const |
Variant using internal vector. | |
void | replace (const std::string &src, const std::string &replacement, std::string &dst) const |
Replaces std::string segment matching search regexp to the given std::string. More... | |
void | replace (const std::string &src, const std::string &replacement, std::ostream &sstr) const |
const std::string & | toStr () const |
Static Protected Member Functions inherited from RegExp | |
static void | replace (const std::string &src, const std::string ®exp, const std::string &replacement, std::string &dst) |
Replaces std::string segment matching search to the given std::string. | |
General-purpose key matcher: tests string equality, or regExp, if defined as such.
The internal value can be a literal string or a regular expression.
Empty string is a valid key - it accepts only an empty string. If you want to accept any string, use set(".*").
When setting the value, it is recognized as a literal if it contains no special characters.
|
protected |
Checks if the key conforms to ODIM convention: DBZH, VRAD, etc. (capital letters, underscores)
This is used for example by PaletteOp
static bool validateKey(const std::string & key);