rwlogo
SourcePro C++ 12.0

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

RWTRegexResult< T > Class Template Reference
[String Processing]

Encapsulates the results from a search using RWTRegex<T>. More...

#include <rw/tools/regexresult.h>

List of all members.

Public Member Functions

 RWTRegexResult ()
 RWTRegexResult (const RWTRegexResult< T > &source)
 RWTRegexResult (RWTRegexResult< T > &&rhs)
 ~RWTRegexResult ()
RWTRegexResult< T > & operator= (const RWTRegexResult< T > &rhs)
RWTRegexResult< T > & operator= (RWTRegexResult< T > &&rhs)
 operator bool () const
size_t size () const
size_t getStart (size_t matchID=0) const
size_t getLength (size_t matchID=0) 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<T> is a class template that encapsulates the result of a RWTRegex<T>::matchAt() or RWTRegex<T>::search() operation executed on an instance of RWTRegex<T>.

Synopsis

 #include <rw/tools/regex.h>
 #include <rw/cstring.h>

 RWTRegex<char> pattern("a+");
 RWTRegexResult<char> result = pattern.search("aabbccaadd");

Persistence

None

Examples

 #include <rw/tools/regex.h>
 #include <rw/cstring.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;
 }

Constructor & Destructor Documentation

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

Default constructor

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

Copy constructor

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 only available on platforms with rvalue reference support.
template<class T>
RWTRegexResult< T >::~RWTRegexResult (  ) 

Destructor


Member Function Documentation

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

Returns the length of the requested match.

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

Returns the offset of the start of the requested match.

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

Match operator

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 only available on platforms with rvalue reference support.
template<class T>
RWTRegexResult<T>& RWTRegexResult< T >::operator= ( const RWTRegexResult< T > &  rhs  ) 

Assignment operator

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.

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

Returns a substring containing the requested match. Available only in C++ Standard Library builds.

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

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

 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.