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::SgfcDocumentWriter Class Reference

The SgfcDocumentWriter class provides an implementation of the ISgfcDocumentWriter interface. See the interface header file for documentation. More...

#include <SgfcDocumentWriter.h>

Inheritance diagram for LibSgfcPlusPlus::SgfcDocumentWriter:
LibSgfcPlusPlus::ISgfcDocumentWriter

Public Member Functions

virtual std::shared_ptr< ISgfcArgumentsGetArguments () const override
 Returns an object with the collection of arguments that ISgfcDocumentWriter passes on to SGFC whenever it performs a write operation.
 
virtual std::shared_ptr< ISgfcDocumentWriteResultWriteSgfFile (std::shared_ptr< ISgfcDocument > document, const std::string &sgfFilePath) const override
 Writes the content of document to a single .sgf file located at the specified path, using the arguments that GetArguments() currently returns.
 
virtual std::shared_ptr< ISgfcDocumentWriteResultWriteSgfContent (std::shared_ptr< ISgfcDocument > document, std::string &sgfContent) const override
 Writes the content of document into the specified string object sgfContent, using the arguments that GetArguments() currently returns.
 
virtual std::shared_ptr< ISgfcDocumentWriteResultValidateDocument (std::shared_ptr< ISgfcDocument > document) const override
 Validates the content of document by simulating a write operation, using the arguments that GetArguments() currently returns.
 
virtual void DebugPrintToConsole (std::shared_ptr< ISgfcDocument > document) const override
 Encodes the content of document into an SGF content stream and prints that stream to stdout for debugging purposes.
 
- Public Member Functions inherited from LibSgfcPlusPlus::ISgfcDocumentWriter
 ISgfcDocumentWriter ()
 Initializes a newly constructed ISgfcDocumentWriter object.
 
virtual ~ISgfcDocumentWriter ()
 Destroys and cleans up the ISgfcDocumentWriter object.
 

Detailed Description

The SgfcDocumentWriter class provides an implementation of the ISgfcDocumentWriter interface. See the interface header file for documentation.

Member Function Documentation

◆ DebugPrintToConsole()

void LibSgfcPlusPlus::SgfcDocumentWriter::DebugPrintToConsole ( std::shared_ptr< ISgfcDocument > document) const
overridevirtual

Encodes the content of document into an SGF content stream and prints that stream to stdout for debugging purposes.

This is useful to see the SGF content that the writer would pass to SGFC for parsing and writing.

Implements LibSgfcPlusPlus::ISgfcDocumentWriter.

◆ GetArguments()

std::shared_ptr< ISgfcArguments > LibSgfcPlusPlus::SgfcDocumentWriter::GetArguments ( ) const
overridevirtual

Returns an object with the collection of arguments that ISgfcDocumentWriter passes on to SGFC whenever it performs a write operation.

The collection of arguments initially contains SgfcArgumentType::DefaultEncoding with the parameter "UTF-8". This allows an ISgfcDocument to be passed to ISgfcDocumentWriter for writing whose game trees don't contain an SgfcPropertyType::CA property value. Read the class documentation for details about encodings.

Add arguments to the collection to change the way how SGFC writes SGF content. The collection retains its state between write operations so that repeated write operations use the same arguments.

Implements LibSgfcPlusPlus::ISgfcDocumentWriter.

◆ ValidateDocument()

std::shared_ptr< ISgfcDocumentWriteResult > LibSgfcPlusPlus::SgfcDocumentWriter::ValidateDocument ( std::shared_ptr< ISgfcDocument > document) const
overridevirtual

Validates the content of document by simulating a write operation, using the arguments that GetArguments() currently returns.

Before ISgfcDocumentWriter can invoke the SGFC backend's write function, it needs to pass the SGF content through the SGFC backend's load/parse functions. The messages in the result object therefore are a combination of a full cycle of SGFC backend load/parse/write operations.

Attention
Read the class documentation for a note about encodings.
Returns
An ISgfcDocumentWriteResult object that provides the result of the validation operation.
Exceptions
std::logic_erroris thrown if document 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.

Implements LibSgfcPlusPlus::ISgfcDocumentWriter.

◆ WriteSgfContent()

std::shared_ptr< ISgfcDocumentWriteResult > LibSgfcPlusPlus::SgfcDocumentWriter::WriteSgfContent ( std::shared_ptr< ISgfcDocument > document,
std::string & sgfContent ) const
overridevirtual

Writes the content of document into the specified string object sgfContent, using the arguments that GetArguments() currently returns.

Before ISgfcDocumentWriter can invoke the SGFC backend's write function, it needs to pass the SGF content through the SGFC backend's load/parse functions. The messages in the result object therefore are a combination of a full cycle of SGFC backend load/parse/write operations.

Attention
Read the class documentation for a note about encodings.
Returns
An ISgfcDocumentWriteResult object that provides the result of the write operation.
Exceptions
std::logic_erroris thrown if document 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.

Implements LibSgfcPlusPlus::ISgfcDocumentWriter.

◆ WriteSgfFile()

std::shared_ptr< ISgfcDocumentWriteResult > LibSgfcPlusPlus::SgfcDocumentWriter::WriteSgfFile ( std::shared_ptr< ISgfcDocument > document,
const std::string & sgfFilePath ) const
overridevirtual

Writes the content of document to a single .sgf file located at the specified path, using the arguments that GetArguments() currently returns.

Before ISgfcDocumentWriter can invoke the SGFC backend's write function, it needs to pass the SGF content through the SGFC backend's load/parse functions. The messages in the result object therefore are a combination of a full cycle of SGFC backend load/parse/write operations.

Attention
Read the class documentation for a note about encodings.
Returns
An ISgfcDocumentWriteResult object that provides the result of the write operation.
Exceptions
std::logic_erroris thrown if document 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.

Implements LibSgfcPlusPlus::ISgfcDocumentWriter.


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