#include <regexp_parser.h>
Public Member Functions | |
basic_regexp_parser (std::basic_string< E > regular_expression) | |
bool | is_pattern_valid () |
Returns 'true', if regexp pattern passed into constructor is valid. | |
virtual unsigned long | parse (const E *buf, const unsigned long buf_length) |
Uses regexp pattern to find match in the input buffer. | |
virtual std::basic_istream< E > & | parse (std::basic_istream< E > &is) |
Uses regexp pattern to find match in the input stream. | |
unsigned long | recognized_position () |
Returns the match position in the input. | |
unsigned long | recognized_size () |
Returns the match size in the input. | |
void | assign_matches (extended_regular_expression::matches &m) |
Assigns matches of all subexpressions. | |
virtual std::basic_ostream< E > & | format (std::basic_ostream< E > &os) |
Formats the preceding characters together with match string back into output stream. | |
operator std::basic_string () | |
Returns the match as a string together with characters before match position. | |
Protected Member Functions | |
void | prepare_for_parsing () |
Protected Attributes | |
std::basic_string< E > | m_regular_expression |
basic_non_terminal< E, extended_regular_expression::ere< E > > | m_regexp |
|
Assigns matches of all subexpressions. The method retrieves all subexpressions data (position and size in original input buffer). Each subexpression is addressed by a key. In the match key, the number specifies the subexpression position, by '.' are separated levels, i.e. "a" is addresses by 1, "(a)" by 1.1, "((a))" by 1.1.1 etc. By number is specified the subexpression position on the level. Suppose we have pattern "a(a(b){1,3})" and input "aaabbbb". Now we are interested in subexression 1.1.2 = second b regexp_parser rxp("a(a(b){1,3})"); rxp.parse( "aaabbbb", 7 ); matches m; rxp.assign_matches(m); match subexpr = m.get("1.1.2"); if( subexpr.this->is_valid() ) { ulong pos = subexpr.get_pos(); // == 4 ulong size = subexpr.get_size();// == 1 // do some work } |
|
Uses regexp pattern to find match in the input stream. The constructor parameter is used as regexp pattern during parsing
|
|
Uses regexp pattern to find match in the input buffer. The constructor parameter is used as regexp pattern during parsing
|