libsgfc++ 2.0.1
A C++ library that uses SGFC to read and write SGF (Smart Game Format) data.
|
The SgfcDocumentEncoder class encodes the content of an ISgfcDocument object into an in-memory string buffer that contains the SGF content stream as if it were read from an .sgf file, and that can be passed to SGFC for further processing (corrections and/or writing to an .sgf file in the filesystem). More...
#include <SgfcDocumentEncoder.h>
Public Member Functions | |
SgfcDocumentEncoder (std::shared_ptr< ISgfcDocument > document) | |
Initializes a newly constructed SgfcDocumentEncoder object. The object encodes the content of the specified document. | |
virtual | ~SgfcDocumentEncoder () |
Destroys and cleans up the SgfcDocumentEncoder object. | |
std::string | Encode () const |
Returns a string that contains the SGF data generated by encoding the content of the document with which the SgfcDocumentEncoder was constructed. | |
The SgfcDocumentEncoder class encodes the content of an ISgfcDocument object into an in-memory string buffer that contains the SGF content stream as if it were read from an .sgf file, and that can be passed to SGFC for further processing (corrections and/or writing to an .sgf file in the filesystem).
Implementation note: SgfcDocumentEncoder formats the SGF content that it generates with indentation and line breaks to make the content human readable. It is expected that SGFC removes that whitespace when it parses the SGF content.
The purpose of generating human readable SGF content is to debug issues.
std::string LibSgfcPlusPlus::SgfcDocumentEncoder::Encode | ( | ) | const |
Returns a string that contains the SGF data generated by encoding the content of the document with which the SgfcDocumentEncoder was constructed.
The resulting string can be used to construct an SgfcBackendDataWrapper object that can then be passed to SgfcBackendController for further processing by SGFC.
This method can be invoked any amount of times. It will return a newly allocated string object on each invocation.
std::logic_error | is thrown if the document with which the SgfcDocumentEncoder was constructed cannot be encoded into a string due to some fundamental error in the object tree. Currently the only known case is if the document contains one or more games that have no root node. |