Sourceforge.net - The VCF's Project Host
   The VCF Website Home   |   Online Discussion Forums   |   Sourceforge.net Project Page   

VCF::Regex::Host Class Reference

Base class for performing regex searches. More...

#include <RegExKit.h>

Inheritance diagram for VCF::Regex::Host:

VCF::Enumerator< Match > VCF::Regex::Ascii VCF::Regex::UTF_16LE List of all members.

Public Member Functions

virtual ~Host ()
virtual bool hasMoreElements (const bool &backward=false)
 indicates whether there are any more children to enumerate through
virtual Match nextElement ()
 returns the next element in the enumeration.
virtual Match prevElement ()
 returns the previous element in the enumeration.
virtual void reset (const bool &backward=false)
 Resets the Enumerator's internal iterator back to the beginning (or end, if backward is true).
Enumerator< Match > * getEnumerator ()
void compile ()
 Parses the regex search string.
Iterator find (unsigned char *pos)
 Finds the first match result at or after the specified position.
Iterator rfind (unsigned char *pos)
 Finds the first match result at or before the specified position.
Iterator find (ptrdiff_t pos)
 Finds the first match result at or after the specified position.
Iterator rfind (ptrdiff_t pos)
 Finds the first match result at or before the specified position.
MatchList findAll ()
 Finds all matches throughout the entire search range.
Iterator begin ()
 Searches from the beginning for the first match.
Iterator end ()
 Returns a past-the-end iterator.
ReverseIterator rbegin ()
 Returns a ReverseIterator to the result of end().
ReverseIterator rend ()
 Returns a ReverseIterator to the result of begin().
unsigned char * changeRangeBeginning (unsigned char *newBeginning)
 Moves the pointer that marks the beginning of the search range.
unsigned char * changeRangeEnd (unsigned char *newEnd)
 Moves the pointer that marks the end of the search range.
String changeSearchExpression (const String &newExpression)
 Changes the regular expression for the search.
void clearCache ()
 Deletes information about previously found matches.

Protected Types

typedef std::set< MatchMatchContainerT
typedef MatchContainerT::iterator InternalIterator
typedef MatchContainerT::const_iterator InternalConstIterator

Protected Member Functions

 Host (const String &expression, unsigned char *first, unsigned char *last, OnigSyntaxType *syntax=ONIG_SYNTAX_DEFAULT)
 Host (const String &expression, OnigSyntaxType *syntax=ONIG_SYNTAX_DEFAULT)
virtual int init ()=0
Iterator next (Iterator current) const
Iterator prev (Iterator current) const
virtual unsigned int characterWidth (const ptrdiff_t &pos) const =0

Protected Attributes

MatchContainerT cache_
Match pastTheEnd_
String expression_
unsigned char * first_
unsigned char * last_
regex_t * reg_
OnigSyntaxType * syntax_
OnigErrorInfo error_
Iterator enumerator

Friends

class Match
class Iterator

Detailed Description

Base class for performing regex searches.

Regex classes are derived from this to process a particular encoding method. Match results are stored within the Host object to facilitate iteration.

A Host object contains two unsigned char pointers which denote a search range beyond which the regex object will not search. Adjusting these pointers or any data within the search range after matches have been found may invalidate iterators (see changeRangeBeginning and changeRangeEnd for more details).

See also:
Ascii

UTF_16LE


Member Typedef Documentation

typedef MatchContainerT::const_iterator VCF::Regex::Host::InternalConstIterator [protected]
 

typedef MatchContainerT::iterator VCF::Regex::Host::InternalIterator [protected]
 

typedef std::set<Match> VCF::Regex::Host::MatchContainerT [protected]
 


Constructor & Destructor Documentation

virtual VCF::Regex::Host::~Host  )  [virtual]
 

VCF::Regex::Host::Host const String expression,
unsigned char *  first,
unsigned char *  last,
OnigSyntaxType *  syntax = ONIG_SYNTAX_DEFAULT
[protected]
 

VCF::Regex::Host::Host const String expression,
OnigSyntaxType *  syntax = ONIG_SYNTAX_DEFAULT
[protected]
 


Member Function Documentation

Iterator VCF::Regex::Host::begin  ) 
 

Searches from the beginning for the first match.

Returns:
Iterator Either the first match or a past-the-end iterator if there are no matches.

unsigned char* VCF::Regex::Host::changeRangeBeginning unsigned char *  newBeginning  ) 
 

Moves the pointer that marks the beginning of the search range.

This will invalidate any iterators that point to matches lying outside the new search range. Also, any offset values (such as from Match::getPosAsOffset()) previously calculated will now be incorrect.

Parameters:
unsigned char* Pointer to the new range limit.
Returns:
unsigned char* Pointer to the previous range limit.

unsigned char* VCF::Regex::Host::changeRangeEnd unsigned char *  newEnd  ) 
 

Moves the pointer that marks the end of the search range.

This will invalidate any iterators that point to matches lying outside the new search range.

Parameters:
unsigned char* Pointer to the new range limit.
Returns:
unsigned char* Pointer to the previous range limit.

String VCF::Regex::Host::changeSearchExpression const String newExpression  ) 
 

Changes the regular expression for the search.

Note that this function calls clearCache(). If you want to retain previous search results, create a new Host object instead.

Parameters:
String New regular expression
Returns:
String Old regular expression

virtual unsigned int VCF::Regex::Host::characterWidth const ptrdiff_t &  pos  )  const [protected, pure virtual]
 

Implemented in VCF::Regex::Ascii, and VCF::Regex::UTF_16LE.

void VCF::Regex::Host::clearCache  )  [inline]
 

Deletes information about previously found matches.

Use this if the contents of the search range have changed since the last search or the last time the cache was cleared. Note that this invalidates all iterators for these matches.

void VCF::Regex::Host::compile  ) 
 

Parses the regex search string.

This should always be called immediately after object creation.

Iterator VCF::Regex::Host::end  )  [inline]
 

Returns a past-the-end iterator.

Iterator VCF::Regex::Host::find ptrdiff_t  pos  )  [inline]
 

Finds the first match result at or after the specified position.

Parameters:
ptrdiff_t Offset position from beginning of the search range. If this position points outside the search range, then the search will start at the beginning of the range.
Returns:
Iterator An iterator pointing to the match result.

Iterator VCF::Regex::Host::find unsigned char *  pos  ) 
 

Finds the first match result at or after the specified position.

Parameters:
unsigned char* Pointer to location to start matching. If this position points outside the search range, then the search will start at the beginning of the range.
Returns:
Iterator An iterator pointing to the match result.

MatchList VCF::Regex::Host::findAll  ) 
 

Finds all matches throughout the entire search range.

Returns:
MatchList A std::set<Match> containing all the matches found in order of position in the search range.

Enumerator<Match>* VCF::Regex::Host::getEnumerator  )  [inline]
 

virtual bool VCF::Regex::Host::hasMoreElements const bool &  backward = false  )  [virtual]
 

indicates whether there are any more children to enumerate through

Parameters:
bool specifies whether the enumeration should be forwards or backwards. The default value is true for enumerating forwards.
Returns:
bool true if there are any elements left to enumerate, otherwise returns false.

Implements VCF::Enumerator< Match >.

virtual int VCF::Regex::Host::init  )  [protected, pure virtual]
 

Implemented in VCF::Regex::Ascii, and VCF::Regex::UTF_16LE.

Iterator VCF::Regex::Host::next Iterator  current  )  const [protected]
 

virtual Match VCF::Regex::Host::nextElement  )  [virtual]
 

returns the next element in the enumeration.

Moves the internal iterator forward

Returns:
COLLECTION_TYPE returns a COLLECTION_TYPE value of whatever type was specified in the template argument to the Enumerator

Implements VCF::Enumerator< Match >.

Iterator VCF::Regex::Host::prev Iterator  current  )  const [protected]
 

virtual Match VCF::Regex::Host::prevElement  )  [virtual]
 

returns the previous element in the enumeration.

Moves the internal iterator backward

Returns:
COLLECTION_TYPE returns a COLLECTION_TYPE value of whatever type was specified in the template argument to the Enumerator

Implements VCF::Enumerator< Match >.

ReverseIterator VCF::Regex::Host::rbegin  )  [inline]
 

Returns a ReverseIterator to the result of end().

ReverseIterator VCF::Regex::Host::rend  )  [inline]
 

Returns a ReverseIterator to the result of begin().

virtual void VCF::Regex::Host::reset const bool &  backward = false  )  [virtual]
 

Resets the Enumerator's internal iterator back to the beginning (or end, if backward is true).

Parameters:
bool specifies which direction to reset to

Implements VCF::Enumerator< Match >.

Iterator VCF::Regex::Host::rfind ptrdiff_t  pos  )  [inline]
 

Finds the first match result at or before the specified position.

Parameters:
ptrdiff_t Offset position from beginning of the search range. If this position points outside the search range, then the search will start at the end of the range.
Returns:
Iterator An iterator pointing to the match result.

Iterator VCF::Regex::Host::rfind unsigned char *  pos  ) 
 

Finds the first match result at or before the specified position.

Parameters:
unsigned char* Pointer to location to start matching. If this position points outside the search range, then the search will start at the end of the range.
Returns:
Iterator An iterator pointing to the match result.


Friends And Related Function Documentation

friend class Iterator [friend]
 

friend class Match [friend]
 


Member Data Documentation

MatchContainerT VCF::Regex::Host::cache_ [protected]
 

Iterator VCF::Regex::Host::enumerator [protected]
 

OnigErrorInfo VCF::Regex::Host::error_ [protected]
 

String VCF::Regex::Host::expression_ [protected]
 

unsigned char* VCF::Regex::Host::first_ [protected]
 

unsigned char* VCF::Regex::Host::last_ [protected]
 

Match VCF::Regex::Host::pastTheEnd_ [protected]
 

regex_t* VCF::Regex::Host::reg_ [protected]
 

OnigSyntaxType* VCF::Regex::Host::syntax_ [protected]
 


The documentation for this class was generated from the following file:
   Comments or Suggestions?    License Information