|
typedef std::vector< std::string > | result_t |
| Native result type, also for external result object.
|
|
|
| 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 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.
|
|
|
const std::vector< std::string > & | result |
| Public interface for the result.
|
|
int | flags |
|
|
regex_t | regExpBinary |
|
std::string | regExpString |
|
result_t | writableResult |
|
◆ RegExp()
RegExp |
( |
const std::string & |
str = "" , |
|
|
int |
flags = REG_EXTENDED |
|
) |
| |
◆ execute()
int execute |
( |
const std::string & |
str, |
|
|
T & |
result |
|
) |
| const |
Apply regexp matching in a string. Returns 0 on success, REG_NOMATCH on failure.
- Template Parameters
-
T | - A class implementing clear() and push_back() like STL Sequence, eg. std::vector or std::list |
- Parameters
-
str | - source string |
result | - result of the match (STL Sequence) |
- Returns
- - 0 on success, REG_NOMATCH on failure
Allocates space for the matches.
Allocates temp array for <regex.h> processing.
The essential <regex.h> wrapper. (Notice the negation of boolean return values.) In success, indices (rm_so,rm_eo) will point to matching segments of toStr. e-flags not implemented (yet?).
◆ replace() [1/2]
void replace |
( |
const std::string & |
src, |
|
|
const std::string & |
replacement, |
|
|
std::ostream & |
ostr |
|
) |
| const |
Like test, but stores the matches. Attempts to match given std::string against the (compiled) regexp.
- Returns
- REG_NOMATCH if match fails, resultcode otherwise. TODO consider returning bool, saving return code.
Allocates temp array for <regex.h> processing.
The essential <regex.h> wrapper. (Notice the negation of boolean return values.) In success, indices (rm_so,rm_eo) will point to matching segments of toStr. Eflags not implemented (yet?).
◆ replace() [2/2]
void replace |
( |
const std::string & |
src, |
|
|
const std::string & |
replacement, |
|
|
std::string & |
dst |
|
) |
| const |
|
inline |
Replaces std::string segment matching search regexp to the given std::string.
- See also
- StringTools::replace.
◆ test()
bool test |
( |
const std::string & |
str | ) |
const |
Tests if the regular expression accepts the given std::string.
Attempts to match given std::string against the (compiled) regexp.
- toStr - std::string to pe tested
- Returns
- - true in success.
The documentation for this class was generated from the following files: