Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members  

mpcl::text::regex::TMatcher Class Reference

#include <matcher.hh>

List of all members.

Public Methods

 TMatcher (void)
 Builds a new instance.

 TMatcher (std::basic_istream< char > &rtISTREAM)
 TMatcher (const std::string &rySTRING)
 TMatcher (const char *pkcSTRING)
 ~TMatcher (void)
 Destroys the instance.

void clearDefinitions (void)
 Clears all terminal definitions.

void define (const char *pkcTERMINAL, const char *pkcDEFINITION)
void redefine (const char *pkcTERMINAL, const char *pkcDEFINITION)
void setCaseSensitiveness (bool gTRUTH)
void setInput (const char *pkcSTRING)
void setInput (const std::string &rkySTRING)
void setInput (std::basic_istream< char > &rtISTREAM)
size_t scan (const char *pkcPATTERN_STRING...) const
bool match (const char *pkcPATTERN_STRING) const

Protected Methods

void clearStream (void)
 Clears the local stream (if any).

void checkStream (void) const
 Checks if the input stream (if any) is re-positionable.

TString instantiate (const char *pkcPATTERN_STRING) const
bool matchChars (char cSOURCE, const char *pkcPATTERN_STRING) const


Detailed Description

Very simple regular expression matcher class.

Recognized patterns:

[[:space:]]+ ::= {[[:space:]]} [[:space:]]* ::= [{[[:space:]]}] [[:space:]] ::= c / ( isspace (c) == true ) [[:blank:]]+ ::= {[[:blank:]]} [[:blank:]]* ::= [{[[:blank:]]}] [[:blank:]] ::= c / ( ( c == ' ' ) || ( c == '\t' ) ) [.]* ::= c* / text between tags c? ::= [c] d ::= d+ / ( isdigit (c) == true ) s ::= c+ / ( ( c == '_' ) || ( c == '-' ) || ( isalnum (c) == true ) ) q ::= "d+" | c+ / ( ( d != '"' ) && ( ( c == '_' ) || ( c == '-' ) || ( isalnum (c) == true ) ) t ::= c* / text between tags <<EOF>> ::= End of input

Definition at line 73 of file matcher.hh.


Constructor & Destructor Documentation

mpcl::text::regex::TMatcher::TMatcher std::basic_istream< char > &    rtISTREAM [inline]
 

Builds a new instance.

Parameters:
rtISTREAM  Source stream for loading.

Definition at line 108 of file matcher.hh.

References checkStream().

mpcl::text::regex::TMatcher::TMatcher const std::string &    rySTRING [inline]
 

Builds a new instance.

Parameters:
rySTRING  Source stream for loading.

Definition at line 121 of file matcher.hh.

References checkStream().

mpcl::text::regex::TMatcher::TMatcher const char *    pkcSTRING [inline]
 

Builds a new instance.

Parameters:
rySTRING  Source stream for loading.

Definition at line 137 of file matcher.hh.

References checkStream().


Member Function Documentation

void mpcl::text::regex::TMatcher::define const char *    pkcTERMINAL,
const char *    pkcDEFINITION
 

Defines a terminal with name pkcTERMINAL, and definition pkcDEFINITION.

Parameters:
pkcTERMINAL  Terminal to be defined.
pkcDEFINITION  Definition of the terminal.

Definition at line 150 of file matcher.cc.

mpcl::text::TString mpcl::text::regex::TMatcher::instantiate const char *    pkcPATTERN_STRING const [protected]
 

Instantiates pattern pkcPATTERN_STRING with all terminals defined, so all the appearances of terminals defined are substituted by their definitions.

Parameters:
pkcPATTERN_STRING  Pattern string.
Returns:
Instantiated string.

Definition at line 677 of file matcher.cc.

References mpcl::text::TString.

bool mpcl::text::regex::TMatcher::match const char *    pkcPATTERN_STRING const
 

Matches the string at rtSOURCE, with pattern pkcPATTERN_STRING. If there is any argument in the pattern, then it is forgotten. The matched string is not removed.

Parameters:
pkcPATTERN_STRING  Pattern string.
Returns:
True if pattern pkcPATTERN_STRING matched input from stream.

Definition at line 160 of file matcher.cc.

References scan().

bool mpcl::text::regex::TMatcher::matchChars char    cSOURCE,
const char *    pkcPATTERN_STRING
const [protected]
 

Matches the character cSOURCE, with the first in pattern pkcPATTERN_STRING.

Parameters:
cSOURCE  Source character.
pkcPATTERN_STRING  Pattern string.
Returns:
True if first character in pattern pkcPATTERN_STRING matched character cSOURCE.

Definition at line 694 of file matcher.cc.

void mpcl::text::regex::TMatcher::redefine const char *    pkcTERMINAL,
const char *    pkcDEFINITION
 

Redefines a terminal with name pkcTERMINAL, and definition pkcDEFINITION.

Parameters:
pkcTERMINAL  Terminal to be redefined.
pkcDEFINITION  Definition of the terminal.

Definition at line 191 of file matcher.cc.

std::size_t mpcl::text::regex::TMatcher::scan const char *    pkcPATTERN_STRING... const
 

Matches the input string, using pattern pkcPATTERN_STRING. If there is any argument in the pattern, then it is written in each argument after pkcPATTERN_STRING. The matched string is removed from stream.

Warning:
You must supply all arguments defined in pkcPATTERN_STRING. If you don't want to supply arguments, then use a NULL value to tell the function stopping getting arguments.
Declaration: size_t scan (const char* pkcPATTERN_STRING[[, string&]*[, NULL]]) const;
Parameters:
pkcPATTERN_STRING  Pattern string.
Returns:
Length of string matched.

Definition at line 201 of file matcher.cc.

References mpcl::text::TString.

Referenced by match().

void mpcl::text::regex::TMatcher::setCaseSensitiveness bool    gTRUTH
 

Sets case-sensitiveness state.

Parameters:
gTRUTH  True if it will be case sensitive.

Definition at line 616 of file matcher.cc.

void mpcl::text::regex::TMatcher::setInput std::basic_istream< char > &    rtISTREAM
 

Sets input stream.

Parameters:
rtISTREAM  Source stream.

Definition at line 640 of file matcher.cc.

References checkStream(), and clearStream().

void mpcl::text::regex::TMatcher::setInput const std::string &    rkySTRING [inline]
 

Sets input string.

Parameters:
rkySTRING  Source string.

Definition at line 190 of file matcher.hh.

References setInput().

void mpcl::text::regex::TMatcher::setInput const char *    pkcSTRING
 

Sets input string.

Parameters:
pkcSTRING  Source string.

Definition at line 625 of file matcher.cc.

References checkStream(), and clearStream().

Referenced by setInput().


The documentation for this class was generated from the following files:
Generated on Mon Oct 13 02:35:26 2003 for MPCL by doxygen1.2.18