xmltooling  1.4.2
xmltooling::XMLToolingException Class Reference

Base exception class, supports parametrized messages and XML serialization. More...

#include <xmltooling/exceptions.h>

Inheritance diagram for xmltooling::XMLToolingException:
Collaboration diagram for xmltooling::XMLToolingException:

Public Types

typedef XMLToolingExceptionExceptionFactory ()
 A factory function that returns an empty exception object of a given type. More...
 

Public Member Functions

 XMLToolingException (const char *msg=0, const params &p=params())
 Constructs an exception using a message and positional parameters. More...
 
 XMLToolingException (const char *msg, const namedparams &p)
 Constructs an exception using a message and named parameters. More...
 
 XMLToolingException (const std::string &msg, const params &p=params())
 Constructs an exception using a message and positional parameters. More...
 
 XMLToolingException (const std::string &msg, const namedparams &p)
 Constructs an exception using a message and named parameters. More...
 
const char * getMessage () const
 Returns the error message, after processing any parameter references. More...
 
const char * what () const throw ()
 Returns the error message, after processing any parameter references. More...
 
void setMessage (const char *msg)
 Sets the error message. More...
 
void setMessage (const std::string &msg)
 Sets the error message. More...
 
void addProperties (const params &p)
 Attach a set of positional parameters to the exception. More...
 
void addProperties (const namedparams &p)
 Attach a set of named parameters to the exception. More...
 
void addProperty (const char *value)
 Attach a single positional parameter at the next available position. More...
 
void addProperty (const char *name, const char *value)
 Attach a single named parameter. More...
 
const char * getProperty (unsigned int index) const
 Returns the parameter property with the designated position (based from one). More...
 
const char * getProperty (const char *name) const
 Returns the parameter property with the designated name. More...
 
virtual void raise () const
 Raises an exception using itself. More...
 
virtual const char * getClassName () const
 Returns a unique name for the exception class. More...
 
std::string toString () const
 Returns a string containing a serialized representation of the exception. More...
 
std::string toQueryString () const
 Returns a set of query string name/value pairs, URL-encoded, representing the exception's type, message, and parameters. More...
 

Static Public Member Functions

static XMLToolingExceptiongetInstance (const char *exceptionClass)
 Builds an empty exception of the given type. More...
 
static XMLToolingExceptionfromStream (std::istream &in)
 Builds an exception from a serialized input stream. More...
 
static XMLToolingExceptionfromString (const char *s)
 Builds an exception from a serialized input buffer. More...
 
static void registerFactory (const char *exceptionClass, ExceptionFactory *factory)
 Registers a factory to create exceptions of a given class name. More...
 
static void deregisterFactory (const char *exceptionClass)
 Unregisters the factory for a given class name. More...
 
static void deregisterFactories ()
 Unregisters all factories.
 

Detailed Description

Base exception class, supports parametrized messages and XML serialization.

Parameters are prefixed with a dollar sign ($) and can be positional ($1) or named ($info).

Member Typedef Documentation

typedef XMLToolingException* xmltooling::XMLToolingException::ExceptionFactory()

A factory function that returns an empty exception object of a given type.

Constructor & Destructor Documentation

xmltooling::XMLToolingException::XMLToolingException ( const char *  msg = 0,
const params p = params() 
)

Constructs an exception using a message and positional parameters.

Parameters
msgerror message
pan ordered set of positional parameter strings
xmltooling::XMLToolingException::XMLToolingException ( const char *  msg,
const namedparams p 
)

Constructs an exception using a message and named parameters.

Parameters
msgerror message
pa set of named parameter strings
xmltooling::XMLToolingException::XMLToolingException ( const std::string &  msg,
const params p = params() 
)

Constructs an exception using a message and positional parameters.

Parameters
msgerror message
pan ordered set of positional parameter strings
xmltooling::XMLToolingException::XMLToolingException ( const std::string &  msg,
const namedparams p 
)

Constructs an exception using a message and named parameters.

Parameters
msgerror message
pa set of named parameter strings

Member Function Documentation

void xmltooling::XMLToolingException::addProperties ( const params p)

Attach a set of positional parameters to the exception.

Parameters
pan ordered set of named parameter strings
void xmltooling::XMLToolingException::addProperties ( const namedparams p)

Attach a set of named parameters to the exception.

Parameters
pa set of named parameter strings
void xmltooling::XMLToolingException::addProperty ( const char *  value)
inline

Attach a single positional parameter at the next available position.

Parameters
valuethe parameter value
void xmltooling::XMLToolingException::addProperty ( const char *  name,
const char *  value 
)
inline

Attach a single named parameter.

Parameters
namethe parameter name
valuethe parameter value
static void xmltooling::XMLToolingException::deregisterFactory ( const char *  exceptionClass)
inlinestatic

Unregisters the factory for a given class name.

Parameters
exceptionClassname of exception type
static XMLToolingException* xmltooling::XMLToolingException::fromStream ( std::istream &  in)
static

Builds an exception from a serialized input stream.

Parameters
ininput stream
Returns
the exception object found in the stream
static XMLToolingException* xmltooling::XMLToolingException::fromString ( const char *  s)
static

Builds an exception from a serialized input buffer.

Parameters
sinput buffer
Returns
the exception object found in the buffer
static XMLToolingException* xmltooling::XMLToolingException::getInstance ( const char *  exceptionClass)
static

Builds an empty exception of the given type.

Parameters
exceptionClassthe name of the exception type to build
Returns
an empty exception object
const char* xmltooling::XMLToolingException::getMessage ( ) const

Returns the error message, after processing any parameter references.

Returns
the processed message
const char* xmltooling::XMLToolingException::getProperty ( unsigned int  index) const

Returns the parameter property with the designated position (based from one).

Parameters
indexposition to access
Returns
the parameter property or nullptr
const char* xmltooling::XMLToolingException::getProperty ( const char *  name) const

Returns the parameter property with the designated name.

Parameters
namenamed parameter to access
Returns
the parameter property or nullptr
static void xmltooling::XMLToolingException::registerFactory ( const char *  exceptionClass,
ExceptionFactory factory 
)
inlinestatic

Registers a factory to create exceptions of a given class name.

Parameters
exceptionClassname of exception type
factoryfactory function to build exceptions with
void xmltooling::XMLToolingException::setMessage ( const char *  msg)

Sets the error message.

Parameters
msgthe error message
void xmltooling::XMLToolingException::setMessage ( const std::string &  msg)
inline

Sets the error message.

Parameters
msgthe error message
std::string xmltooling::XMLToolingException::toQueryString ( ) const

Returns a set of query string name/value pairs, URL-encoded, representing the exception's type, message, and parameters.

Returns
the query string representation
std::string xmltooling::XMLToolingException::toString ( ) const

Returns a string containing a serialized representation of the exception.

Returns
the serialization
const char* xmltooling::XMLToolingException::what ( ) const
throw (
)
inline

Returns the error message, after processing any parameter references.

Returns
the processed message

The documentation for this class was generated from the following file: