lightweight encapsulation of regex lib search and replace More...
#include <op_regex.h>
Classes | |
| struct | replace_t |
Public Member Functions | |
| regular_expression_replace (size_t limit=100, size_t limit_defs_expansion=100) | |
| ~regular_expression_replace () | |
| void | add_definition (std::string const &name, std::string const &replace) |
| void | add_pattern (std::string const &pattern, std::string const &replace) |
| bool | execute (std::string &str) const |
lightweight encapsulation of regex lib search and replace
See stl.pat for further details and examples of used syntax.
| regular_expression_replace::regular_expression_replace | ( | size_t | limit = 100, |
|
| size_t | limit_defs_expansion = 100 | |||
| ) |
| limit | limit on number of search and replace done | |
| limit_defs_expansion | limit on number of expansion done during replacement of regular definition name by their expansion |
build an object holding regular defintion and regular expression & replace, preparing it for substitution ala sed
| regular_expression_replace::~regular_expression_replace | ( | ) |
| void regular_expression_replace::add_definition | ( | std::string const & | name, | |
| std::string const & | replace | |||
| ) |
| name | a regular definition name | |
| replace | the string to subsitute in other regular definition or regular exepression when this regular defintion name is encoutered. |
Referenced by setup_regex().
| void regular_expression_replace::add_pattern | ( | std::string const & | pattern, | |
| std::string const & | replace | |||
| ) |
| pattern | a regular expression pattern, POSIX extended notation | |
| replace | the replace string to use when this regular expression is matched |
You can imbed regular definition in pattern but not in replace.
Referenced by setup_regex().
| bool regular_expression_replace::execute | ( | std::string & | str | ) | const |
| str | the input/output string where we search pattern and replace them. |
Execute loop at max limit time on the set of regular expression
Return true if too many match occur and replacing has been stopped due to reach limit_defs_expansion. You can test if some pattern has been matched by saving the input string and comparing it to the new value. There is no way to detect s/a/a because the output string will be identical to the input string.
Referenced by demangle_symbol(), and setup_regex().
1.6.1