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) const
 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) const
 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 (const unsigned char *const pos) const
 Finds the first match result at or after the specified position.
Iterator rfind (const unsigned char *const pos) const
 Finds the first match result at or before the specified position.
Iterator find (const ptrdiff_t pos) const
 Finds the first match result at or after the specified position.
Iterator rfind (const ptrdiff_t pos) const
 Finds the first match result at or before the specified position.
MatchList findAll () const
 Finds all matches throughout the entire search range.
Iterator begin () const
 Searches from the beginning for the first match.
Iterator end () const
 Returns a past-the-end iterator.
ReverseIterator rbegin () const
 Returns a ReverseIterator to the result of end().
ReverseIterator rend () const
 Returns a ReverseIterator to the result of begin().
const unsigned char * changeRangeBeginning (const unsigned char *const newBeginning)
 Moves the pointer that marks the beginning of the search range.
const unsigned char * changeRangeEnd (const unsigned char *const newEnd)
 Moves the pointer that marks the end of the search range.
String changeSearchExpression (const String &newExpression)
 Changes the regular expression for the search.
virtual void setRangeAsString (const String &newExpression)=0
 Sets the search range pointers to the beginning and end of a VCF::String object.
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, const unsigned char *first, const unsigned char *last, const RegExKit::Syntax &syntax=RegExKit::sDefault)
 Host (const String &expression, const RegExKit::Syntax &syntax=RegExKit::sDefault)
virtual int init ()=0
Iterator next (Iterator current) const
Iterator prev (Iterator current) const
virtual unsigned int characterWidth (const unsigned char *const location) const =0
unsigned int characterWidth (const ptrdiff_t &pos) const
virtual Match createMatch (const OnigRegion *region, const ptrdiff_t pos) const =0
virtual String::size_type countCharacters (const unsigned char *const start, const unsigned char *const end) const =0

Protected Attributes

MatchContainerT cache_
Match pastTheEnd_
String expression_
const unsigned char * first_
const 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,
const unsigned char *  first,
const unsigned char *  last,
const RegExKit::Syntax syntax = RegExKit::sDefault
[protected]
 

VCF::Regex::Host::Host const String expression,
const RegExKit::Syntax syntax = RegExKit::sDefault
[protected]
 


Member Function Documentation

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

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.

const unsigned char* VCF::Regex::Host::changeRangeBeginning const unsigned char *const   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. Further calls to Match::getPosAsOffset() from Iterators which are still valid will give correct results.

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

const unsigned char* VCF::Regex::Host::changeRangeEnd const unsigned char *const   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

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

virtual unsigned int VCF::Regex::Host::characterWidth const unsigned char *const   location  )  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.

virtual String::size_type VCF::Regex::Host::countCharacters const unsigned char *const   start,
const unsigned char *const   end
const [protected, pure virtual]
 

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

virtual Match VCF::Regex::Host::createMatch const OnigRegion *  region,
const ptrdiff_t  pos
const [protected, pure virtual]
 

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

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

Returns a past-the-end iterator.

Iterator VCF::Regex::Host::find const ptrdiff_t  pos  )  const [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 const unsigned char *const   pos  )  const
 

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  )  const
 

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  )  const [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  )  const [inline]
 

Returns a ReverseIterator to the result of end().

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

Returns a ReverseIterator to the result of begin().

virtual void VCF::Regex::Host::reset const bool &  backward = false  )  const [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 const ptrdiff_t  pos  )  const [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 const unsigned char *const   pos  )  const
 

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.

virtual void VCF::Regex::Host::setRangeAsString const String newExpression  )  [pure virtual]
 

Sets the search range pointers to the beginning and end of a VCF::String object.

This is implemented by classes derived from Host as the result depends on the character width and representation.

Parameters:
String Data to be searched

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


Friends And Related Function Documentation

friend class Iterator [friend]
 

friend class Match [friend]
 


Member Data Documentation

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

Iterator VCF::Regex::Host::enumerator_ [mutable, protected]
 

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

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

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

const 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