GTP failure. More...
#include <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) |
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.
| GtpFailure | ( | ) |
Construct with no message.
Definition at line 390 of file GtpEngine.cpp.
| GtpFailure | ( | const std::string & | 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.
| 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<<().
| GtpFailure operator<< | ( | const GtpFailure & | failure, | |
| const TYPE & | type | |||
| ) | [related] |
Definition at line 118 of file GtpEngine.h.
References ResponseStream().
| GtpFailure operator<< | ( | const GtpFailure & | failure, | |
| TYPE & | type | |||
| ) | [related] |
Definition at line 128 of file GtpEngine.h.
References ResponseStream().
std::ostringstream m_response [private] |
Definition at line 112 of file GtpEngine.h.
Referenced by GtpFailure(), Response(), and ResponseStream().