Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

GtpFailure Class Reference

#include <GtpEngine.h>

List of all members.


Detailed Description

GTP failure.

Command handlers generate a GTP error response by throwing an instance of GtpFailure. It contains an internal string stream for building the reponse using stream output operators. To make formatting of responses with a temporary object more convenient, operator<< uses non-standard semantics, such that a new object is returned. Usage examples:

    // OK. Construct with string
    throw GtpFailure("message");

    // OK. Use temporary object
    throw GtpFailure() << message << ...;

    // NOT OK. Object is not modified, the return value of << is ignored
    GtpFailure failure;
    failure << message << ...;
    throw failure;

    // OK. Use the internal string stream
    GtpFailure failure;
    failure.ResponseStream() << message << ...;
    throw failure;
    

Definition at line 89 of file GtpEngine.h.

Public Member Functions

 GtpFailure ()
 Construct with no message.
 GtpFailure (const std::string &response)
 Construct with message.
 GtpFailure (const GtpFailure &failure)
 Copy constructor.
 ~GtpFailure () throw ()
 Destructor.
std::string Response () const
 Get the response.
std::ostream & ResponseStream ()
 Get the internal string stream.

Private Attributes

std::ostringstream m_response

Related Functions

(Note that these are not member functions.)

template<typename TYPE>
GtpFailure operator<< (const GtpFailure &failure, const TYPE &type)
template<typename TYPE>
GtpFailure operator<< (const GtpFailure &failure, TYPE &type)


Constructor & Destructor Documentation

GtpFailure (  ) 

Construct with no message.

Definition at line 398 of file GtpEngine.cpp.

GtpFailure ( const std::string &  response  ) 

Construct with message.

Definition at line 408 of file GtpEngine.cpp.

References m_response.

GtpFailure ( const GtpFailure failure  ) 

Copy constructor.

Needed for operator<<. Preserves the internal string stream format state.

Definition at line 402 of file GtpEngine.cpp.

References m_response, and Response().

~GtpFailure (  )  throw ()

Destructor.

Definition at line 413 of file GtpEngine.cpp.


Member Function Documentation

std::string Response (  )  const

Get the response.

Returns a copy of the text in the internal string stream.

Definition at line 141 of file GtpEngine.h.

References m_response.

Referenced by GtpFailure(), and GtpEngine::HandleCommand().

std::ostream & ResponseStream (  ) 

Get the internal string stream.

Definition at line 146 of file GtpEngine.h.

References m_response.

Referenced by operator<<().


Friends And Related Function Documentation

GtpFailure operator<< ( const GtpFailure failure,
TYPE &  type 
) [related]

Note:
Returns a new object, see GtpFailure

Definition at line 134 of file GtpEngine.h.

References ResponseStream().

GtpFailure operator<< ( const GtpFailure failure,
const TYPE &  type 
) [related]

Note:
Returns a new object, see GtpFailure

Definition at line 123 of file GtpEngine.h.

References ResponseStream().


Member Data Documentation

std::ostringstream m_response [private]

Definition at line 116 of file GtpEngine.h.

Referenced by GtpFailure(), Response(), and ResponseStream().


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


17 Jun 2010 Doxygen 1.4.7