|  | reflex::PatternMatcher< P > Class Template Reference updated Fri Dec 9 2016 |

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
reflex::PatternMatcher< P > Class Template Reference

The pattern matcher class template extends abstract matcher base class. More...

`#include <absmatcher.h>`

Inheritance diagram for reflex::PatternMatcher< P >:
[legend]
Collaboration diagram for reflex::PatternMatcher< P >:
[legend]

## Public Types
typedef P | Pattern
Public Types inherited from reflex::AbstractMatcher
typedef AbstractMatcher::Iterator< AbstractMatcher > | iterator
| std::input_iterator for scanning, searching, and splitting input character sequences More...
typedef AbstractMatcher::Iterator< const AbstractMatcher > | const_iterator

## Public Member Functions
| PatternMatcher (const PatternMatcher &matcher)
| Copy constructor. More...
virtual | ~PatternMatcher ()
| Delete matcher, deletes pattern when owned, deletes this matcher's internal buffer. More...
virtual PatternMatcher & | pattern (const Pattern &pat)
| Set the pattern to use with this matcher. More...
virtual PatternMatcher & | pattern (const char *regex)
| Set the pattern from a regex string to use with this matcher. More...
virtual PatternMatcher & | pattern (const std::string &regex)
| Set the pattern from a regex string to use with this matcher. More...
const Pattern & | pattern (void) const
| Returns the pattern object associated with this matcher. More...
Public Member Functions inherited from reflex::AbstractMatcher
virtual void | reset (const char *opt=NULL)
| Reset this matcher's state to the initial state and set options (when provided). More...
bool | buffer (size_t blk=0)
| Set buffer block size for reading: use 1 for interactive input, 0 (or omit argument) to buffer all input (returns true if the size of the input source is determinable). More...
void | interactive (void)
| Set buffer to 1 for interactive input. More...
void | flush (void)
| Flush the buffer's remaining content. More...
virtual AbstractMatcher & | input (const Input &inp)
| Set the input character sequence for this matcher and reset the matcher. More...
size_t | matches (void)
| Returns true if the entire input matches this matcher's pattern (and internally caches the true/false result for repeat invocations). More...
size_t | accept (void) const
| Returns a positive integer (true) indicating the capture index of the matched text in the pattern or zero (false) for a mismatch. More...
const char * | text (void) const
| Returns string with the text matched by one of the match methods of this matcher. More...
size_t | size (void) const
| Returns the length of the text matched by one of the match methods of this matcher. More...
size_t | lineno (void) const
| Returns the line number of the match in the input character sequence. More...
size_t | columno (void) const
| Returns the column number of the match in the input character sequence. More...
std::pair< size_t, std::string > | pair () const
| Returns a pair of size_t accept() and std::string text(), useful for tokenizing input into containers of pairs. More...
size_t | first (void) const
| Returns the position of the first character starting the match in the input character sequence. More...
size_t | last (void) const
| Returns the position of the last character + 1 after of the match in the input character sequence. More...
bool | at_bob (void) const
| Returns true if this matcher is at the start of an input character sequence. Use reset() to restart input. More...
bool | at_end (void)
| Returns true if this matcher has no more input to read from the input character sequence. More...
bool | hit_end (void) const
| Returns true if this matcher hit the end of the input character sequence. More...
void | set_end (bool eof)
| Set and force the end of input state. More...
bool | at_bol (void) const
| Returns true if this matcher reached the begin of a new line. More...
void | set_bol (bool bol)
| Set the begin of a new line state. More...
int | input (void)
| Returns the next character from the input character sequence while preserving the current text match. More...
void | unput (char c)
| Put back one character on the input character sequence for matching, invalidating the current match info and text. More...
const char * | rest (void)
| Fetch the rest of the input as text, useful for matching/splitting up to n times after which the rest is needed. More...
void | more (void)
| Append the next match to the currently matched text returned by AbstractMatcher::text, when the next match found is adjacent to the current match. More...
void | less (size_t n)
| Truncate the AbstractMatcher::text length of the match to n characters in length and reposition for next match. More...
| operator size_t () const
| Cast this matcher to positive integer indicating the nonzero capture index of the matched text in the pattern, same as AbstractMatcher::accept. More...
| operator std::string () const
| Cast this matcher to a std::string of the text matched by this matcher. More...
| operator std::pair< size_t, std::string > () const
| Cast this matcher to a pair of size_t accept() and std::string text(), useful for tokenization into containers. More...
bool | operator== (const char *rhs) const
| Returns true if matched text is equal to a string, useful for std::algorithm. More...
bool | operator== (const std::string &rhs) const
| Returns true if matched text is equalt to a string, useful for std::algorithm. More...
bool | operator== (size_t rhs) const
| Returns true if capture index is equal to a given size_t value, useful for std::algorithm. More...
bool | operator== (int rhs) const
| Returns true if capture index is equal to a given int value, useful for std::algorithm. More...
bool | operator!= (const char *rhs) const
| Returns true if matched text is not equal to a string, useful for std::algorithm. More...
bool | operator!= (const std::string &rhs) const
| Returns true if matched text is not equal to a string, useful for std::algorithm. More...
bool | operator!= (size_t rhs) const
| Returns true if capture index is not equal to a given size_t value, useful for std::algorithm. More...
bool | operator!= (int rhs) const
| Returns true if capture index is not equal to a given int value, useful for std::algorithm. More...

## Protected Member Functions
| PatternMatcher (const Pattern &pat, const Input &inp=Input(), const char *opt=NULL)
| Construct a base abstract matcher from a pattern object and an input character sequence. More...
| PatternMatcher (const Pattern *pat, const Input &inp=Input(), const char *opt=NULL)
| Construct a base abstract matcher from a pattern object pointer and an input character sequence. More...
| PatternMatcher (const char *regex, const Input &inp=Input(), const char *opt=NULL)
| Construct a base abstract matcher from a regex pattern string and an input character sequence. More...
| PatternMatcher (const std::string &regex, const Input &inp=Input(), const char *opt=NULL)
| Construct a base abstract matcher from a regex pattern string and an input character sequence. More...
Protected Member Functions inherited from reflex::AbstractMatcher
| AbstractMatcher (const Input &inp, const char *opt)
| Construct a base abstract matcher. More...
void | init (const char *opt)
| Initialize the base abstract matcher at construction. More...
virtual size_t | get (char *s, size_t n)
| Returns more input (method can be overriden as by reflex::FlexLexer::get to invoke reflex::FlexLexer::LexerInput). More...
virtual bool | wrap (void)
| Returns true if wrapping of input after EOF is supported. More...
virtual size_t | match (Method method)=0
| The abstract match operation implemented by pattern matching engines derived from AbstractMatcher. More...
bool | grow (size_t need=Const::BLOCK)
| Shift or expand the internal buffer when it is too small to accommodate more input, where the buffer size is doubled when needed. More...
int | get (void)
| Returns the next character from the buffered input character sequence. More...
int | peek (void)
| Peek at the next character in the buffered input without consuming it. More...
void | set_current (size_t loc)
| Set the current position to advance to the next match. More...

## Protected Attributes
bool | own_
| true if PatternMatcher::pat_ was internally allocated More...
const Pattern * | pat_
| points to the pattern object used by the matcher More...
Protected Attributes inherited from reflex::AbstractMatcher
Option | opt_
| options for matcher engines More...
char * | buf_
| input character sequence buffer More...
const char * | txt_
| points to the matched text in buffer AbstractMatcher::buf_ More...
size_t | len_
| size of the matched text More...
size_t | cap_
| nonzero capture index of an accepted match or zero More...
size_t | cur_
| next position in AbstractMatcher::buf_ to assign to AbstractMatcher::txt_ More...
size_t | pos_
| position in AbstractMatcher::buf_ after AbstractMatcher::txt_ More...
size_t | end_
| ending position of the input buffered in AbstractMatcher::buf_ More...
size_t | max_
| total buffer size and max position + 1 to fill More...
size_t | ind_
| current indent position More...
size_t | blk_
| block size for block-based input reading, as set by AbstractMatcher::buffer More...
int | got_
| last unsigned character we looked at (to determine anchors and boundaries) More...
int | chr_
| the character located at AbstractMatcher::buf_[AbstractMatcher::pos_] More...
size_t | lno_
| line number count (prior to this buffered input) More...
size_t | cno_
| column number count (prior to this buffered input) More...
size_t | num_
| character count (number of characters flushed prior to this buffered input) More...
bool | eof_
| input has reached EOF More...
bool | mat_
| true if AbstractMatcher::matches() was successful More...

## Additional Inherited Members
Public Attributes inherited from reflex::AbstractMatcher
Operation | scan
| functor to scan input (to tokenize input) More...
Operation | find
| functor to search input More...
Operation | split
| functor to split input More...
Input | in
| input character sequence being matched by this matcher More...
Protected Types inherited from reflex::AbstractMatcher
typedef int | Method

## Detailed Description

### template<typename P>
class reflex::PatternMatcher< P >

The pattern matcher class template extends abstract matcher base class.

More info TODO

Template Parameters

  <P> | pattern class to instantiate a matcher

## Member Typedef Documentation

template<typename P>

typedef P reflex::PatternMatcher< P >::Pattern

pattern class of this matcher, a typedef of the PatternMatcher template parameter

## Constructor & Destructor Documentation

template<typename P>

reflex::PatternMatcher< P >::PatternMatcher | ( | const PatternMatcher< P > & | matcher | ) |
| inline

Copy constructor.

template<typename P>

virtual reflex::PatternMatcher< P >::~PatternMatcher | ( |  | ) |
| inline virtual

Delete matcher, deletes pattern when owned, deletes this matcher's internal buffer.

template<typename P>

reflex::PatternMatcher< P >::PatternMatcher | ( | const Pattern & | pat,
|  | const Input & | inp = `Input()`,
|  | const char * | opt = `NULL`
| ) |  |
| inline protected

Construct a base abstract matcher from a pattern object and an input character sequence.

Parameters

  pat | pattern object for this matcher
  inp | input character sequence for this matcher
  opt | option string of the form `(A|N|T(=[[:digit:]])?|;)*`

template<typename P>

reflex::PatternMatcher< P >::PatternMatcher | ( | const Pattern * | pat,
|  | const Input & | inp = `Input()`,
|  | const char * | opt = `NULL`
| ) |  |
| inline protected

Construct a base abstract matcher from a pattern object pointer and an input character sequence.

Parameters

  pat | points to pattern object for this matcher
  inp | input character sequence for this matcher
  opt | option string of the form `(A|N|T(=[[:digit:]])?|;)*`

template<typename P>

reflex::PatternMatcher< P >::PatternMatcher | ( | const char * | regex,
|  | const Input & | inp = `Input()`,
|  | const char * | opt = `NULL`
| ) |  |
| inline protected

Construct a base abstract matcher from a regex pattern string and an input character sequence.

Parameters

  regex | regex string instantiates pattern object for this matcher
  inp | input character sequence for this matcher
  opt | option string of the form `(A|N|T(=[[:digit:]])?|;)*`

template<typename P>

reflex::PatternMatcher< P >::PatternMatcher | ( | const std::string & | regex,
|  | const Input & | inp = `Input()`,
|  | const char * | opt = `NULL`
| ) |  |
| inline protected

Construct a base abstract matcher from a regex pattern string and an input character sequence.

Parameters

  regex | regex string instantiates pattern object for this matcher
  inp | input character sequence for this matcher
  opt | option string of the form `(A|N|T(=[[:digit:]])?|;)*`

## Member Function Documentation

template<typename P>

virtual PatternMatcher& reflex::PatternMatcher< P >::pattern | ( | const Pattern & | pat | ) |
| inline virtual

Set the pattern to use with this matcher.

Returns
  this matcher.

Parameters

  pat | pattern object for this matcher

template<typename P>

virtual PatternMatcher& reflex::PatternMatcher< P >::pattern | ( | const char * | regex | ) |
| inline virtual

Set the pattern from a regex string to use with this matcher.

Returns
  this matcher.

Parameters

  regex | regex string to instantiate internal pattern object

Reimplemented in reflex::BoostMatcher.

template<typename P>

virtual PatternMatcher& reflex::PatternMatcher< P >::pattern | ( | const std::string & | regex | ) |
| inline virtual

Set the pattern from a regex string to use with this matcher.

Returns
  this matcher.

Parameters

  regex | regex string to instantiate internal pattern object

Reimplemented in reflex::BoostMatcher.

template<typename P>

const Pattern& reflex::PatternMatcher< P >::pattern | ( | void |  | ) | const
| inline

Returns the pattern object associated with this matcher.

Returns
  reference to pattern object.

## Member Data Documentation

template<typename P>

bool reflex::PatternMatcher< P >::own_
| protected

true if PatternMatcher::pat_ was internally allocated

template<typename P>

const Pattern* reflex::PatternMatcher< P >::pat_
| protected

points to the pattern object used by the matcher

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

- absmatcher.h