regular_expression_replace Class Reference

lightweight encapsulation of regex lib search and replace More...

#include <op_regex.h>

List of all members.

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

Detailed Description

lightweight encapsulation of regex lib search and replace

See stl.pat for further details and examples of used syntax.


Constructor & Destructor Documentation

regular_expression_replace::regular_expression_replace ( size_t  limit = 100,
size_t  limit_defs_expansion = 100 
)
Parameters:
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 (  ) 

Member Function Documentation

void regular_expression_replace::add_definition ( std::string const &  name,
std::string const &  replace 
)
Parameters:
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 
)
Parameters:
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
Parameters:
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().


The documentation for this class was generated from the following files:

Generated on 29 Jul 2013 for oprofile by  doxygen 1.6.1