Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  
Public Member Functions | Private Attributes | Related Functions

GtpFailure Class Reference

GTP failure. More...

#include <GtpEngine.h>

List of all members.

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)

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 87 of file GtpEngine.h.


Constructor & Destructor Documentation

GtpFailure (  ) 

Construct with no message.

Definition at line 390 of file GtpEngine.cpp.

GtpFailure ( const std::string &  response  ) 

Construct with message.

Definition at line 400 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 394 of file GtpEngine.cpp.

References m_response, and Response().

~GtpFailure (  )  throw ()

Destructor.

Definition at line 405 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 135 of file GtpEngine.h.

References m_response.

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

std::ostream & ResponseStream (  ) 

Get the internal string stream.

Definition at line 140 of file GtpEngine.h.

References m_response.

Referenced by operator<<().


Friends And Related Function Documentation

GtpFailure operator<< ( const GtpFailure failure,
const TYPE &  type 
) [related]
Note:
Returns a new object, see GtpFailure

Definition at line 118 of file GtpEngine.h.

References ResponseStream().

GtpFailure operator<< ( const GtpFailure failure,
TYPE &  type 
) [related]
Note:
Returns a new object, see GtpFailure

Definition at line 128 of file GtpEngine.h.

References ResponseStream().


Member Data Documentation

std::ostringstream m_response [private]

Definition at line 112 of file GtpEngine.h.

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


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


Sun Mar 13 2011 Doxygen 1.7.1