SourcePro® API Reference Guide

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

Encapsulates the results from a search using RWTRegex. More...

#include <rw/tools/regexresult.h>

Public Member Functions

 RWTRegexResult ()
 
 RWTRegexResult (const RWTRegexResult< T > &source)
 
 RWTRegexResult (RWTRegexResult< T > &&rhs)
 
 ~RWTRegexResult ()
 
size_t getLength (size_t matchID=0) const
 
size_t getStart (size_t matchID=0) const
 
 operator bool () const
 
RWTRegexResult< T > & operator= (const RWTRegexResult< T > &rhs)
 
RWTRegexResult< T > & operator= (RWTRegexResult< T > &&rhs)
 
size_t size () const
 
RString subString (const RString &str, size_t matchID=0) const
 
void swap (RWTRegexResult< T > &rhs)
 

Detailed Description

template<class T>
class RWTRegexResult< T >

Class RWTRegexResult is a class template that encapsulates the result of a RWTRegex::matchAt() or RWTRegex::search() operation executed on an instance of RWTRegex.

Synopsis
#include <rw/cstring.h>
#include <rw/tools/regex.h>
RWTRegex<char> pattern("a+");
RWTRegexResult<char> result = pattern.search("aabbccaadd");
Encapsulates the results from a search using RWTRegex.
Definition regexresult.h:85
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() {
RWTRegex<char> pattern("h(t+)p");
RWCString str("http");
RWTRegexResult<char> result = pattern.search(str);
std::cout << "Overall match at offset " << result.getStart()
<< ", with length " << result.getLength() << " is "
<< result.subString(str) << std::endl;
std::cout << "First sub-expression match at offset "
<< result.getStart(1) << ", with length "
<< result.getLength(1) << " is " << result.subString(str, 1)
<< std::endl;
return 0;
}
Offers powerful and convenient facilities for manipulating strings.
Definition stdcstring.h:826
size_t getLength(size_t matchID=0) const
RString subString(const RString &str, size_t matchID=0) const
size_t getStart(size_t matchID=0) const

Constructor & Destructor Documentation

◆ RWTRegexResult() [1/3]

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

Default constructor

◆ RWTRegexResult() [2/3]

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

Copy constructor

◆ RWTRegexResult() [3/3]

template<class T >
RWTRegexResult< T >::RWTRegexResult ( RWTRegexResult< T > && rhs)

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.

◆ ~RWTRegexResult()

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

Destructor

Member Function Documentation

◆ getLength()

template<class T >
size_t RWTRegexResult< T >::getLength ( size_t matchID = 0) const

Returns the length of the requested match.

◆ getStart()

template<class T >
size_t RWTRegexResult< T >::getStart ( size_t matchID = 0) const

Returns the offset of the start of the requested match.

◆ operator bool()

template<class T >
RWTRegexResult< T >::operator bool ( ) const

Match operator

◆ operator=() [1/2]

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

Assignment operator

◆ operator=() [2/2]

template<class T >
RWTRegexResult< T > & RWTRegexResult< T >::operator= ( RWTRegexResult< 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.

◆ size()

template<class T >
size_t RWTRegexResult< T >::size ( ) const

Returns the number of match identifiers (matchID) available for request, including the 0 matchID. Hence, the largest matchID that can be requested is size() -1.

◆ subString()

template<class T >
RString RWTRegexResult< T >::subString ( const RString & str,
size_t matchID = 0 ) const

Returns a substring containing the requested match.

◆ swap()

template<class T >
void RWTRegexResult< T >::swap ( RWTRegexResult< 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.