rwlogo
SourcePro C++ 12.0

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

RWURegexMatchIterator Class Reference
[Unicode String Processing]

Iterates over matches found for a Unicode regular expression pattern. More...

#include <rw/i18n/RWURegexMatchIterator.h>

List of all members.

Public Types

typedef RWURegexResult value_type
typedef value_typepointer
typedef value_typereference
typedef std::forward_iterator_tag iterator_category

Public Member Functions

 RWURegexMatchIterator ()
 RWURegexMatchIterator (const RWURegexMatchIterator &source)
 RWURegexMatchIterator (RWURegularExpression &regex, const RWUString &str)
 RWURegexMatchIterator (RWURegularExpression &regex, const RWUString &str, const RWUConstStringIterator &start)
 RWURegexMatchIterator (RWURegularExpression &regex, const RWUString &str, const RWUConstStringIterator &start, const RWUConstStringIterator &end, bool overlap=false)
 ~RWURegexMatchIterator ()
RWURegexMatchIteratoroperator= (const RWURegexMatchIterator &rhs)
RWURegexMatchIteratoroperator++ ()
RWURegexMatchIterator operator++ (int)
RWURegexResult operator* () const
const RWURegexResultoperator-> () const
bool operator== (const RWURegexMatchIterator &rhs) const
bool operator!= (const RWURegexMatchIterator &rhs) const

Detailed Description

RWURegexMatchIterator provides a convenient interface for finding all successive matches of a particular regular expression pattern in a string. RWURegexMatchIterator is a forward iterator, allowing forward searches over the specified string using pre-increment and post-increment operators

By default, only non-overlapping matches are reported, but this behavior can be changed in the constructor.

Note:
As with many iterators, changing the item being iterated over invalidates the iterator. If the regular expression pattern or search string used by an RWURegexMatchIterator is changed, then the iterator is invalidated.

Examples

 #include <rw/i18n/RWURegularExpression.h>
 #include <rw/i18n/RWURegexMatchIterator.h>
 #include <iostream>

 using std::cout;
 using std::endl;

 int main()
 {
   RWURegularExpression r("a+");
   RWUString            str("aaabaacadeaaaafgaaa");

   // Search for all occurrences of the pattern in the string
   for (RWURegexMatchIterator i(r, str); i != RWURegexMatchIterator(); ++i)
   {
     // Show the overall match information
     cout << "Match at position: " << i->getStart()
          << ", with length: " << i->getLength() << endl;
   } // for

   return 0;
 } // main

Program output:

 Match at position: 0, with length: 3
 Match at position: 4, with length: 2
 Match at position: 7, with length: 1
 Match at position: 10, with length: 4
 Match at position: 16, with length: 3
See also:
RWURegularExpression, RWURegexResult

Member Typedef Documentation

typedef std::forward_iterator_tag RWURegexMatchIterator::iterator_category

Tags this class as a Standard C++ forward iterator.

Declares a conventional Standard C++ alias for the value pointer type.

Declares a conventional Standard C++ alias for the value reference type.

Declares a conventional Standard C++ alias for the value type returned by operator*().


Constructor & Destructor Documentation

RWURegexMatchIterator::RWURegexMatchIterator (  ) 

Default constructor. Creates an invalid iterator, which can be used to test for the end-of-iteration condition.

RWURegexMatchIterator::RWURegexMatchIterator ( const RWURegexMatchIterator source  ) 

Copy constructor.

RWURegexMatchIterator::RWURegexMatchIterator ( RWURegularExpression regex,
const RWUString str 
)

Creates a match iterator from regular expression object regex and search string str. The entire search string is considered for a match. Only non-overlapping matches are reported.

RWURegexMatchIterator::RWURegexMatchIterator ( RWURegularExpression regex,
const RWUString str,
const RWUConstStringIterator start 
)

Creates a match iterator from regular expression object regex, search string str, and starting position start. The string is searched from the specified starting position to the end of the string. Only non-overlapping matches are reported.

RWURegexMatchIterator::RWURegexMatchIterator ( RWURegularExpression regex,
const RWUString str,
const RWUConstStringIterator start,
const RWUConstStringIterator end,
bool  overlap = false 
)

Creates a match iterator from regular expression object regex, search string str, starting position start, ending position end, and an overlap flag indicating whether or not to report overlapping matches. The string is searched from the specified starting position to the specified ending position. By default, only non-overlapping matches are reported.

RWURegexMatchIterator::~RWURegexMatchIterator (  ) 

Destructor.


Member Function Documentation

bool RWURegexMatchIterator::operator!= ( const RWURegexMatchIterator rhs  )  const

Compares two iterators for inequality. Returns true if self and rhs reference different regular expression pattern or search strings, or the position in the search string is different; otherwise, false.

RWURegexResult RWURegexMatchIterator::operator* (  )  const

Dereference operator. Returns an RWURegexResult instance describing the current match.

RWURegexMatchIterator RWURegexMatchIterator::operator++ ( int   ) 

Postfix increment operator. Advances self to the next occurrence of a match of the regular expression pattern in the search string, and returns a copy of the previous value of self.

RWURegexMatchIterator& RWURegexMatchIterator::operator++ (  ) 

Prefix increment operator. Advances self to the next occurrence of a match of the regular expression pattern in the search string, and returns a reference to self.

const RWURegexResult* RWURegexMatchIterator::operator-> (  )  const

Returns a pointer to an RWURegexResult instance describing the current match. This pointer is valid only for the lifetime of the RWURegexMatchIterator instance from which it is obtained. The contents will change with any call to the prefix or postfix increment operators.

RWURegexMatchIterator& RWURegexMatchIterator::operator= ( const RWURegexMatchIterator rhs  ) 

Assignment operator. Assigns self the value of the rhs iterator. Makes a deep copy of all data, except self references the same regular expression and search string as rhs.

bool RWURegexMatchIterator::operator== ( const RWURegexMatchIterator rhs  )  const

Compares two iterators for equality. Returns true if self and rhs reference the same regular expression pattern and search strings, and the position in the search string is the same; otherwise, false.

 All Classes Functions Variables Typedefs Enumerations Enumerator Friends

© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.