BALL::RegularExpression Class Reference

#include <BALL/DATATYPE/regularExpression.h>

List of all members.

Public Member Functions

Constructors and Destructors
 RegularExpression ()
 Default constructor.
 RegularExpression (const RegularExpression &regular_expression)
 Copy constructor.
 RegularExpression (const String &pattern, bool wildcard_pattern=false)
virtual ~RegularExpression ()
 Destructor.
virtual void clear ()
 Reset the object attributes to their default values.
void destroy ()
 Destroy the instance.
Assignment
RegularExpressionoperator= (const RegularExpression &expression)
 Assignment operator.
void set (const RegularExpression &regular_expression)
 Assign from another instance.
void set (const String &pattern, bool wildcard_pattern=false)
 Assign from a string.
void get (RegularExpression &regular_expression) const
 Assign to another instance.
Predicates
bool isEmpty () const
bool operator== (const RegularExpression &regular_expression) const
bool operator!= (const RegularExpression &regular_expression) const
bool operator< (const RegularExpression &regular_expression) const
bool operator<= (const RegularExpression &regular_expression) const
bool operator>= (const RegularExpression &regular_expression) const
bool operator> (const RegularExpression &regular_expression) const
Debugging and Diagnostics
virtual bool isValid () const
virtual void dump (std::ostream &s=std::cout, Size depth=0) const

Static Public Attributes

String constants
static const String ALPHA
static const String ALPHANUMERIC
static const String REAL
static const String IDENTIFIER
static const String INTEGER
static const String HEXADECIMAL_INTEGER
static const String LOWERCASE
static const String NON_ALPHA
static const String NON_ALPHANUMERIC
static const String NON_NUMERIC
static const String NON_WHITESPACE
static const String UPPERCASE
static const String WHITESPACE

Private Member Functions

void compilePattern_ ()
void toExtendedRegularExpression_ ()

Private Attributes

regex_t regex_
String pattern_
bool valid_pattern_

Friends

Storers
BALL_EXPORT friend std::ostream & operator<< (std::ostream &s, const RegularExpression &regular_expression)
BALL_EXPORT friend std::istream & operator>> (std::istream &s, RegularExpression &regular_expression)

Accessors

const StringgetPattern () const
 Get the expression pattern.
Size countSubexpressions () const
 Count subexpressions.
bool match (const String &text, Index from=0, int execute_flags=0) const throw (Exception::NullPointer, Exception::IndexUnderflow, Exception::IndexOverflow)
bool match (const Substring &text, Index from=0, int execute_flags=0) const throw (Substring::InvalidSubstring, Exception::IndexUnderflow, Exception::IndexOverflow)
bool match (const char *text, int execute_flags=0) const throw (Exception::NullPointer)
bool find (const String &text, Substring &found, Index from=0, int execute_flags=0) const throw (Exception::IndexUnderflow, Exception::IndexOverflow)
bool find (const String &text, vector< Substring > &subexpressions, Index from=0, int execute_flags=0) const throw (Exception::IndexUnderflow, Exception::IndexOverflow)
static bool match (const char *text, const char *pattern, int compile_flags=0|REG_EXTENDED|REG_NOSUB, int execute_flags=0) throw (Exception::NullPointer)

Detailed Description

Regular expression class


Constructor & Destructor Documentation

BALL::RegularExpression::RegularExpression ( )

Default constructor.

BALL::RegularExpression::RegularExpression ( const RegularExpression regular_expression)

Copy constructor.

BALL::RegularExpression::RegularExpression ( const String pattern,
bool  wildcard_pattern = false 
)
virtual BALL::RegularExpression::~RegularExpression ( ) [virtual]

Destructor.


Member Function Documentation

virtual void BALL::RegularExpression::clear ( ) [virtual]

Reset the object attributes to their default values.

void BALL::RegularExpression::compilePattern_ ( ) [private]
Size BALL::RegularExpression::countSubexpressions ( ) const

Count subexpressions.

void BALL::RegularExpression::destroy ( )

Destroy the instance.

virtual void BALL::RegularExpression::dump ( std::ostream &  s = std::cout,
Size  depth = 0 
) const [virtual]

Dump this instance to an ostream depth is normaly just used for internal use.

Parameters:
sthe ostream, default is the standard output
depththe indentation depth of the output
bool BALL::RegularExpression::find ( const String text,
Substring found,
Index  from = 0,
int  execute_flags = 0 
) const throw (Exception::IndexUnderflow, Exception::IndexOverflow)

Find this expression in a string

Parameters:
fromindex in the string to start the matching
foundthe result is stored as a substring here
execute_flags?????
bool BALL::RegularExpression::find ( const String text,
vector< Substring > &  subexpressions,
Index  from = 0,
int  execute_flags = 0 
) const throw (Exception::IndexUnderflow, Exception::IndexOverflow)

Find this expression in a string

Parameters:
textto process
subexpressionsthe results are stored here
fromindex in the string to start the matching
execute_flags?????
void BALL::RegularExpression::get ( RegularExpression regular_expression) const

Assign to another instance.

const String& BALL::RegularExpression::getPattern ( ) const

Get the expression pattern.

bool BALL::RegularExpression::isEmpty ( ) const

Test if expression is empty.

virtual bool BALL::RegularExpression::isValid ( ) const [virtual]

Test if instance is valid.

static bool BALL::RegularExpression::match ( const char *  text,
const char *  pattern,
int  compile_flags = 0|REG_EXTENDED|REG_NOSUB,
int  execute_flags = 0 
) throw (Exception::NullPointer) [static]

Match a text with a given pattern.

Parameters:
textto process
patternto compare with
compile_flags?????
execute_flags?????
Exceptions:
NullPointerif text or pattern are NULL
bool BALL::RegularExpression::match ( const Substring text,
Index  from = 0,
int  execute_flags = 0 
) const throw (Substring::InvalidSubstring, Exception::IndexUnderflow, Exception::IndexOverflow)

Match a substring with this regular expression.

Parameters:
textto process
fromindex in the substring to start the matching
execute_flags?????
bool BALL::RegularExpression::match ( const String text,
Index  from = 0,
int  execute_flags = 0 
) const throw (Exception::NullPointer, Exception::IndexUnderflow, Exception::IndexOverflow)

Match a text with this regular expression.

Parameters:
textto process
fromindex in the string to start the matching
execute_flags?????
bool BALL::RegularExpression::match ( const char *  text,
int  execute_flags = 0 
) const throw (Exception::NullPointer)

Match a C-String with this regular expression.

Parameters:
textto process
execute_flags?????
bool BALL::RegularExpression::operator!= ( const RegularExpression regular_expression) const

Inequality operator

bool BALL::RegularExpression::operator< ( const RegularExpression regular_expression) const

Less operator

bool BALL::RegularExpression::operator<= ( const RegularExpression regular_expression) const

Less or equal operator

RegularExpression& BALL::RegularExpression::operator= ( const RegularExpression expression)

Assignment operator.

bool BALL::RegularExpression::operator== ( const RegularExpression regular_expression) const

Equality operator

bool BALL::RegularExpression::operator> ( const RegularExpression regular_expression) const

Greater operator

bool BALL::RegularExpression::operator>= ( const RegularExpression regular_expression) const

Greater or equal operator

void BALL::RegularExpression::set ( const RegularExpression regular_expression)

Assign from another instance.

void BALL::RegularExpression::set ( const String pattern,
bool  wildcard_pattern = false 
)

Assign from a string.

void BALL::RegularExpression::toExtendedRegularExpression_ ( ) [private]

Friends And Related Function Documentation

BALL_EXPORT friend std::ostream& operator<< ( std::ostream &  s,
const RegularExpression regular_expression 
) [friend]

output operator

BALL_EXPORT friend std::istream& operator>> ( std::istream &  s,
RegularExpression regular_expression 
) [friend]

input operator


Member Data Documentation

alphabetic letters.

alphanumeric letters

hexadecimal and integer characters

identifier characters

integer characters

lowercase letters

non alphabetic characters

non alphanumeric characters

non numeric characters

non whitespace charcters

real numbers

uppercase letters.

whitespace characters.