SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches

Exception class that reports errors from within RWTRegex. More...

#include <rw/rwerr.h>

Inheritance diagram for RWRegexErr:
RWInternalErr RWxmsg

Public Member Functions

 RWRegexErr (const char *msg, size_t eCode, size_t eOffset)
 
 RWRegexErr (const RWRegexErr &msg)
 
 RWRegexErr (RWRegexErr &&msg)
 
virtual ~RWRegexErr ()
 
size_t getCode () const
 
size_t getOffset () const
 
RWRegexErroperator= (const RWRegexErr &)
 
RWRegexErroperator= (RWRegexErr &&msg)
 
void swap (RWRegexErr &rhs)
 
- Public Member Functions inherited from RWxmsg
 RWxmsg (const char *msg)
 
 RWxmsg (const RWxmsg &msg)
 
 RWxmsg (RWxmsg &&msg)
 
RWxmsgoperator= (const RWxmsg &)
 
RWxmsgoperator= (RWxmsg &&msg)
 
virtual void raise () const
 
void swap (RWxmsg &rhs)
 
virtual const char * why () const
 

Additional Inherited Members

- Protected Member Functions inherited from RWxmsg
 RWxmsg (const char *msg, bool doCopy)
 

Detailed Description

Class RWRegexErr is an exception class used to report errors from within RWTRegex.

RWRegexErr is derived from RWInternalErr, and is therefore part of the RWxmsg class hierarchy. Classes in this hierarchy are used to report errors from within the Essential Tools Module.

RWRegexErr customizes RWInternalErr to provide not only an error message (inherited from RWxmsg), but also an error code and an error offset.

The error code is an RWTRegex<T>::RWTRegexStatus enumeration constant represented as a size_t, and is useful in generating error messages in the wide characters required for many non-Latin languages.

When RWTRegex generates an error, it creates an RWRegexErr object to represent the error. A copy of this object is saved in the RWTRegex object, and is available through a call to RWTRegex::getStatus().

Then, throw is used to report the error.

Synopsis
#include <rw/rwerr.h>
RWRegexErr msg("exception message");
Exception class that reports errors from within RWTRegex.
Definition rwerr.h:488
Persistence
None
Example
#include <rw/cstring.h>
#include <rw/locale.h>
#include <rw/rwerr.h>
#include <rw/tools/regex.h>
#include <iostream>
int main() {
const RWCString unmatchedParen("ab)$");
try {
// Unmatched closing parenthesis generates exception
RWTRegex<char> r(unmatchedParen);
// Use the regular expression to avoid warnings
r.index(unmatchedParen);
} catch (const RWRegexErr& err) {
std::cout << "Caught exception: " << std::endl
<< "Description : " << err.why() << std::endl
<< "Code : " << err.getCode() << std::endl
<< "Offset : " << err.getOffset() << std::endl
<< unmatchedParen << std::endl
<< RWCString('-', err.getOffset()) << '^' << std::endl;
}
return 0;
}
Offers powerful and convenient facilities for manipulating strings.
Definition stdcstring.h:826
size_t getCode() const
size_t getOffset() const
Supports regular expression matching based on the POSIX.2 standard and supports both narrow and wide ...
Definition regex.h:216
virtual const char * why() const

Constructor & Destructor Documentation

◆ RWRegexErr() [1/3]

RWRegexErr::RWRegexErr ( const char * msg,
size_t eCode,
size_t eOffset )

Initializes the error object to contain the specified error message, msg. The error code, eCode, is stored as well as the offset, eOffset, into the pattern of the error.

◆ RWRegexErr() [2/3]

RWRegexErr::RWRegexErr ( const RWRegexErr & msg)

Copy constructor.

◆ RWRegexErr() [3/3]

RWRegexErr::RWRegexErr ( RWRegexErr && msg)

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

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

◆ ~RWRegexErr()

virtual RWRegexErr::~RWRegexErr ( )
virtual

Destructor

Member Function Documentation

◆ getCode()

size_t RWRegexErr::getCode ( ) const

Returns the error code for the error. The error code is an RWTRegex<T>::RWTRegexStatus enumerator represented as a size_t.

◆ getOffset()

size_t RWRegexErr::getOffset ( ) const

Returns the offset into the pattern at which the error occurred.

◆ operator=() [1/2]

RWRegexErr & RWRegexErr::operator= ( const RWRegexErr & )

Assignment operator.

◆ operator=() [2/2]

RWRegexErr & RWRegexErr::operator= ( RWRegexErr && msg)

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

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

◆ swap()

void RWRegexErr::swap ( RWRegexErr & 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.