SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches
RWTRegexMatchIterator< T > Class Template Reference

Iterates over matches found using RWTRegex. More...

#include <rw/tools/regex.h>

Public Member Functions

 RWTRegexMatchIterator ()
 
 RWTRegexMatchIterator (const RWTRegexMatchIterator< T > &source)
 
 RWTRegexMatchIterator (RWTRegex< T > &regex, const RChar *str, size_t start=size_t(0), size_t length=size_t(-1), bool overlap=false)
 
 RWTRegexMatchIterator (RWTRegex< T > &regex, const RString &str, size_t start=size_t(0), size_t length=size_t(-1), bool overlap=false)
 
 RWTRegexMatchIterator (RWTRegexMatchIterator< T > &&rhs)
 
 ~RWTRegexMatchIterator ()
 
bool operator!= (const RWTRegexMatchIterator &rhs) const
 
RWTRegexResult< T > operator* () const
 
RWTRegexMatchIteratoroperator++ ()
 
const RWTRegexMatchIterator operator++ (int)
 
RWTRegexMatchIteratoroperator+= (size_t count)
 
const RWTRegexResult< T > * operator-> () const
 
RWTRegexMatchIteratoroperator= (const RWTRegexMatchIterator &rhs)
 
RWTRegexMatchIteratoroperator= (RWTRegexMatchIterator< T > &&rhs)
 
bool operator== (const RWTRegexMatchIterator &rhs) const
 
void swap (RWTRegexMatchIterator< T > &rhs)
 

Detailed Description

template<class T>
class RWTRegexMatchIterator< T >

Class RWTRegexMatchIterator is an iterator class provided with RWTRegex for iteration over matches of a pattern in a given string.

Synopsis
#include <rw/cstring.h>
#include <rw/tools/regex.h>
RWTRegex<char> pattern("a+");
RWCString str("aabbccaadd");
Offers powerful and convenient facilities for manipulating strings.
Definition stdcstring.h:826
Iterates over matches found using RWTRegex.
Definition regex.h:783
Supports regular expression matching based on the POSIX.2 standard and supports both narrow and wide ...
Definition regex.h:216
Persistence
None
Example
#include <rw/cstring.h>
#include <rw/tools/regex.h>
#include <iostream>
int main() {
RWCString pattern("a+");
RWCString str("aaabaacadeaaaafgaaa");
// Compile the pattern
RWTRegex<char> r(pattern);
// Iterate over all occurrences of the "pattern" string in
// "str"
for (RWTRegex<char>::iterator i(r, str);
i != RWTRegex<char>::iterator(); ++i) {
std::cout << "Found match at index, " << i->getStart() << ":"
<< i->subString(str) << std::endl;
}
return 0;
}
RWTRegexMatchIterator< T > iterator
Definition regex.h:239

Program Output:

Found match at index, 0 :aaa
Found match at index, 4 :aa
Found match at index, 7 :a
Found match at index, 10 :aaaa
Found match at index, 16 :aaa

Constructor & Destructor Documentation

◆ RWTRegexMatchIterator() [1/5]

template<class T >
RWTRegexMatchIterator< T >::RWTRegexMatchIterator ( )

Default constructor

◆ RWTRegexMatchIterator() [2/5]

template<class T >
RWTRegexMatchIterator< T >::RWTRegexMatchIterator ( const RWTRegexMatchIterator< T > & source)

Copy constructor

◆ RWTRegexMatchIterator() [3/5]

Move constructor. The constructed instance takes ownership of the data owned by rhs.

Condition:
This method is available only on platforms with rvalue reference support.

◆ RWTRegexMatchIterator() [4/5]

template<class T >
RWTRegexMatchIterator< T >::RWTRegexMatchIterator ( RWTRegex< T > & regex,
const RChar * str,
size_t start = size_t(0),
size_t length = size_t(-1),
bool overlap = false )

Constructor. Initializes a match iterator to the first match in str, starting from the start character offset, of the regular expression pattern given in regex. The parameter length defines the length of str. If not specified, the length is calculated as the number of characters up to the first NULL character, according to the character traits.

◆ RWTRegexMatchIterator() [5/5]

template<class T >
RWTRegexMatchIterator< T >::RWTRegexMatchIterator ( RWTRegex< T > & regex,
const RString & str,
size_t start = size_t(0),
size_t length = size_t(-1),
bool overlap = false )

Constructor. Initializes a match iterator to the first match in str, starting from the start character offset, of the regular expression pattern given in regex. The parameter length identifies the length of str. If not specified, the length is assigned the length of str.

◆ ~RWTRegexMatchIterator()

template<class T >
RWTRegexMatchIterator< T >::~RWTRegexMatchIterator ( )

Destructor

Member Function Documentation

◆ operator!=()

template<class T >
bool RWTRegexMatchIterator< T >::operator!= ( const RWTRegexMatchIterator< T > & rhs) const

Determines if two iterators are unequal. The return value of this method is the same as !(*this == rhs).

◆ operator*()

template<class T >
RWTRegexResult< T > RWTRegexMatchIterator< T >::operator* ( ) const

Dereferences the iterator, giving a reference to the regular expression object represented in the iterator.

◆ operator++() [1/2]

template<class T >
RWTRegexMatchIterator & RWTRegexMatchIterator< T >::operator++ ( )

Pre-increment operator

◆ operator++() [2/2]

template<class T >
const RWTRegexMatchIterator RWTRegexMatchIterator< T >::operator++ ( int )

Post-increment operator

◆ operator+=()

template<class T >
RWTRegexMatchIterator & RWTRegexMatchIterator< T >::operator+= ( size_t count)

Advances through count matches.

◆ operator->()

template<class T >
const RWTRegexResult< T > * RWTRegexMatchIterator< T >::operator-> ( ) const

Returns a pointer to the regular expression object represented in the iterator.

◆ operator=() [1/2]

template<class T >
RWTRegexMatchIterator & RWTRegexMatchIterator< T >::operator= ( const RWTRegexMatchIterator< T > & rhs)

Assignment operator

◆ operator=() [2/2]

template<class T >
RWTRegexMatchIterator & RWTRegexMatchIterator< T >::operator= ( RWTRegexMatchIterator< T > && rhs)

Move assignment. Self takes ownership of the data owned by rhs.

Condition:
This method is available only on platforms with rvalue reference support.

◆ operator==()

template<class T >
bool RWTRegexMatchIterator< T >::operator== ( const RWTRegexMatchIterator< T > & rhs) const

Compares two iterators for equality based on the regular expression and the starting position in the string.

◆ swap()

template<class T >
void RWTRegexMatchIterator< T >::swap ( RWTRegexMatchIterator< T > & rhs)

Swaps the data owned by self with the data owned by rhs.

Copyright © 2024 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.