libsgfc++ 2.0.1
A C++ library that uses SGFC to read and write SGF (Smart Game Format) data.
Loading...
Searching...
No Matches
Public Member Functions | List of all members
LibSgfcPlusPlus::SgfcDocumentEncoder Class Reference

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.
 

Detailed Description

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.

Member Function Documentation

◆ Encode()

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.

Exceptions
std::logic_erroris 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.

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