Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

lfc::RegexpPattern Class Reference

Inheritance diagram for lfc::RegexpPattern::

lfc::Object List of all members.

Public Methods

 RegexpPattern (string pattern)
 Constructor.
Exceptions:
RegexpException  If there is an error with the pattern.
More...


 ~RegexpPattern () throw ()
virtual bool match (string s, RegexpMatch &match) const
virtual bool match (PutbackTextInput &in, RegexpMatch &match) const
virtual void setAnchorAtStart (bool anchorStart)
virtual bool anchorAtStart () const throw ()
 \brief Indicates whether this pattern is anchored at the start. More...

virtual void setAnchorAtEnd (bool anchorEnd)
virtual bool anchorAtEnd () const throw ()
 \brief Indicates whether this pattern is anchored at the start. More...


Static Public Methods

bool match (string pattern, string s, RegexpMatch &match)

Protected Methods

 RegexpPattern (string pattern, bool topLevel)
virtual void init (string pattern)
 Internal constructor. More...

void parsePattern (const char *pattern)
 \brief Does the actual pattern parsing. More...

bool isSpecialChar (char c) const throw ()
 Indicates whether the given character has special meaning in a regular expression. More...

char getEscapeChar (const char *&src) const throw ()
 Reads an escape character from the string. More...

void parseCharacterClassBlock (const char *&src)
void parseParensBlock (const char *&src)
void parseOrBlock (const char *&src)
void parseMultiplicityBlock (const char *&src)
void parseAnyCharBlock (const char *&src)
void parseEndAnchorBlock (const char *&src)
void parseStringBlock (const char *&src)

Protected Attributes

RegexpPatternBlockm_headBlock
 The start of the compiled subexpressions. More...

RegexpPatternBlockm_tailBlock
 The end of the compiled subexpressions. More...

RegexpPatternBlockm_beforeAnchor
 The block that precedes the end anchor, if it exists. More...

bool m_anchorStart
bool m_anchorEnd
bool m_topLevel

Detailed Description

This class represents a precompiled regular expression that can be used to match substrings of strings or can be passed to a RegexpTextInput stream to read tokens from a character stream.

Note:
Provided is a convenience function to do a match of a pattern to a string without handling a RegexpPattern object. This is not suggested for anything besides special cases, as recompilation of the pattern has to be done with each call.


Constructor & Destructor Documentation

lfc::RegexpPattern::RegexpPattern string    pattern
 

Constructor.

Exceptions:
RegexpException  If there is an error with the pattern.

lfc::RegexpPattern::~RegexpPattern   throw ()
 

lfc::RegexpPattern::RegexpPattern string    pattern,
bool    topLevel
[protected]
 


Member Function Documentation

void lfc::RegexpPattern::init string    pattern [protected, virtual]
 

Internal constructor.

Parameters:
pattern  The pattern.
topLevel  This indicates that this is an user-level pattern, not internal.

bool lfc::RegexpPattern::match string    s,
RegexpMatch   match
const [virtual]
 

A function which tests whether this pattern matches a substring of the given string.

Parameters:
s  The string to match
match  The RegexpMatch object to put the result into.
Exceptions:
RegexpException  in case of error.
Returns:
True if there was a match, false otherwise.

bool lfc::RegexpPattern::match PutbackTextInput   in,
RegexpMatch   match
const [virtual]
 

A function which tests whether this pattern matches the string represented by the given stream data. The stream is moved beyond the matched string.

Parameters:
in  The Putback stream to match
match  The RegexpPmatch object to put the result into.
Exceptions:
RegexpException  in case of error.
Note:
It is the user's responsibility to ensure that the putback stream has enough of a buffer to handle the unreads that are required.

void lfc::RegexpPattern::setAnchorAtStart bool    anchorStart [virtual]
 

Lets the user set programmatically whether this pattern is anchored to the beginning of the string/current stream position or not.

Parameters:
anchorStart  Indicates whether to anchor at the start or not.

virtual bool lfc::RegexpPattern::anchorAtStart   const throw () [inline, virtual]
 

\brief Indicates whether this pattern is anchored at the start.

void lfc::RegexpPattern::setAnchorAtEnd bool    anchorEnd [virtual]
 

Lets the user set programmatically whether this pattern is anchored to the end of the string/end of line or not.

Parameters:
anchorEnd  Indicates whether to anchor at the end or not.

virtual bool lfc::RegexpPattern::anchorAtEnd   const throw () [inline, virtual]
 

\brief Indicates whether this pattern is anchored at the start.

bool lfc::RegexpPattern::match string    pattern,
string    s,
RegexpMatch   match
[static]
 

A static convenience function used to do a test on the fly for a given pattern.

Parameters:
pattern  The regular expression
s  The string to match
match  The RegexpMatch obejct to put the result into.
Exceptions:
RegexpException  in case of error.
Returns:
True if there was a match, false otherwise.

void lfc::RegexpPattern::parsePattern const char *    pattern [protected]
 

\brief Does the actual pattern parsing.

bool lfc::RegexpPattern::isSpecialChar char    c const throw () [protected]
 

Indicates whether the given character has special meaning in a regular expression.

char lfc::RegexpPattern::getEscapeChar const char *&    src const throw () [protected]
 

Reads an escape character from the string.

void lfc::RegexpPattern::parseCharacterClassBlock const char *&    src [protected]
 

void lfc::RegexpPattern::parseParensBlock const char *&    src [protected]
 

void lfc::RegexpPattern::parseOrBlock const char *&    src [protected]
 

void lfc::RegexpPattern::parseMultiplicityBlock const char *&    src [protected]
 

void lfc::RegexpPattern::parseAnyCharBlock const char *&    src [protected]
 

void lfc::RegexpPattern::parseEndAnchorBlock const char *&    src [protected]
 

void lfc::RegexpPattern::parseStringBlock const char *&    src [protected]
 


Member Data Documentation

RegexpPatternBlock* lfc::RegexpPattern::m_headBlock [protected]
 

The start of the compiled subexpressions.

RegexpPatternBlock* lfc::RegexpPattern::m_tailBlock [protected]
 

The end of the compiled subexpressions.

RegexpPatternBlock* lfc::RegexpPattern::m_beforeAnchor [protected]
 

The block that precedes the end anchor, if it exists.

bool lfc::RegexpPattern::m_anchorStart [protected]
 

Indicates that this pattern must be hooked to be beginning of the string, i.e., the '^' was specified at the start of the pattern.

bool lfc::RegexpPattern::m_anchorEnd [protected]
 

Indicates that this pattern must be hooked to be end of the string, i.e., the '$' was specified at the end of the pattern.

bool lfc::RegexpPattern::m_topLevel [protected]
 

Indicates that this pattern is a top-level pattern (that is, one created by the user). This is only used internally, as non-top level patterns are reduced to their blocks and are destroyed in one of the parseXXX methods after construction.


The documentation for this class was generated from the following files:
Generated on Fri Jan 25 03:13:36 2002 for LFC2 by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001