#include <SgGtpClient.h>
Usage example:
// Run GNU Go and send a GTP command try { SgProcess process("gnugo --mode gtp"); SgGtpClient gtp(process.Input(), process.Output()); string result = gtp.Send("version"); SgDebug() << "Success response: " << result << '\n'; } catch (const SgGtpFailure& e) { SgDebug() << "Error response: " << e.what() << '\n'; } catch (const SgException& e) { SgDebug() << "Error running GNU Go: " << e.what() << '\n'; }
Definition at line 52 of file SgGtpClient.h.
Public Member Functions | |
| SgGtpClient (std::istream &in, std::ostream &out, bool verbose=false) | |
| Constructor. | |
| virtual | ~SgGtpClient () |
| std::string | Send (const std::string &command) |
| Send a command. | |
Private Attributes | |
| bool | m_verbose |
| std::istream & | m_in |
| std::ostream & | m_out |
| SgGtpClient::SgGtpClient | ( | std::istream & | in, | |
| std::ostream & | out, | |||
| bool | verbose = false | |||
| ) |
Constructor.
| in | Input stream. | |
| out | Output stream. | |
| verbose | Log stream to SgDebug() |
Definition at line 24 of file SgGtpClient.cpp.
| SgGtpClient::~SgGtpClient | ( | ) | [virtual] |
Definition at line 31 of file SgGtpClient.cpp.
| string SgGtpClient::Send | ( | const std::string & | command | ) |
Send a command.
| SgGtpFailure | If command fails or connection is broken. |
Definition at line 35 of file SgGtpClient.cpp.
std::istream& SgGtpClient::m_in [private] |
std::ostream& SgGtpClient::m_out [private] |
bool SgGtpClient::m_verbose [private] |