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

The SgfcDocument class provides an implementation of the ISgfcDocument interface. See the interface header file for documentation. More...

#include <SgfcDocument.h>

Inheritance diagram for LibSgfcPlusPlus::SgfcDocument:
LibSgfcPlusPlus::ISgfcDocument

Public Member Functions

 SgfcDocument ()
 Initializes a newly constructed SgfcDocument object. The document has no content.
 
 SgfcDocument (SGFInfo *sgfInfo)
 Initializes a newly constructed SgfcDocument object with the SGF content in sgfInfo. The initialized document contains 0-n ISgfcGame objects that represent the game trees found during parsing of sgfInfo.
 
virtual ~SgfcDocument ()
 Destroys and cleans up the SgfcDocument object.
 
virtual bool IsEmpty () const override
 Returns true if the document has no content. Returns false if the document has some content.
 
virtual std::vector< std::shared_ptr< ISgfcGame > > GetGames () const override
 Returns a collection of games that together make up the document.
 
virtual std::shared_ptr< ISgfcGameGetGame () const override
 Returns the first game from the collection of games that GetGames() returns. Returns nullptr if GetGames() returns an empty collection.
 
virtual void SetGames (const std::vector< std::shared_ptr< ISgfcGame > > &games) override
 Sets the collection of games that together make up the document to games, replacing the previous collection. games may not contain nullptr. games may not contain duplicates.
 
virtual void AppendGame (std::shared_ptr< ISgfcGame > game) override
 Adds game as the last game to the collection of games that together make up the document. game may not be nullptr.
 
virtual void RemoveGame (std::shared_ptr< ISgfcGame > game) override
 Removes game from the collection of games that together make up the document.
 
virtual void RemoveAllGames () override
 Removes all games from the collection of games that together make up the document.
 
virtual void DebugPrintToConsole () const override
 Prints the content of the ISgfcDocument to stdout for debugging purposes.
 
- Public Member Functions inherited from LibSgfcPlusPlus::ISgfcDocument
 ISgfcDocument ()
 Initializes a newly constructed ISgfcDocument object.
 
virtual ~ISgfcDocument ()
 Destroys and cleans up the ISgfcDocument object.
 

Detailed Description

The SgfcDocument class provides an implementation of the ISgfcDocument interface. See the interface header file for documentation.

Constructor & Destructor Documentation

◆ SgfcDocument()

LibSgfcPlusPlus::SgfcDocument::SgfcDocument ( SGFInfo * sgfInfo)

Initializes a newly constructed SgfcDocument object with the SGF content in sgfInfo. The initialized document contains 0-n ISgfcGame objects that represent the game trees found during parsing of sgfInfo.

Exceptions
std::invalid_argumentIs thrown if sgfInfo is nullptr. Is also thrown if an ISgfcGameTypeProperty or ISgfcBoardSizeProperty object is constructed with invalid property values.
std::domain_errorIs thrown if parsing of sgfInfo failed due to an interfacing problem with SGFC. Problems can range from simple (but fundamental) things such as an unexpected nullptr in one of the SGFC data structures, to more complex data-related issues such as when SGFC and libsgfc++ disagree about the data type(s) of a property value.

Member Function Documentation

◆ AppendGame()

void LibSgfcPlusPlus::SgfcDocument::AppendGame ( std::shared_ptr< ISgfcGame > game)
overridevirtual

Adds game as the last game to the collection of games that together make up the document. game may not be nullptr.

Exceptions
std::invalid_argumentIs thrown if game is nullptr or if game is already in the collection.

Implements LibSgfcPlusPlus::ISgfcDocument.

◆ DebugPrintToConsole()

void LibSgfcPlusPlus::SgfcDocument::DebugPrintToConsole ( ) const
overridevirtual

Prints the content of the ISgfcDocument to stdout for debugging purposes.

Implements LibSgfcPlusPlus::ISgfcDocument.

◆ GetGame()

std::shared_ptr< ISgfcGame > LibSgfcPlusPlus::SgfcDocument::GetGame ( ) const
overridevirtual

Returns the first game from the collection of games that GetGames() returns. Returns nullptr if GetGames() returns an empty collection.

This is a convenience method which simplifies the majority of cases where a document only contains a single game.

Implements LibSgfcPlusPlus::ISgfcDocument.

◆ GetGames()

std::vector< std::shared_ptr< ISgfcGame > > LibSgfcPlusPlus::SgfcDocument::GetGames ( ) const
overridevirtual

Returns a collection of games that together make up the document.

Implements LibSgfcPlusPlus::ISgfcDocument.

◆ IsEmpty()

bool LibSgfcPlusPlus::SgfcDocument::IsEmpty ( ) const
overridevirtual

Returns true if the document has no content. Returns false if the document has some content.

The document is empty if it contains no games.

Implements LibSgfcPlusPlus::ISgfcDocument.

◆ RemoveAllGames()

void LibSgfcPlusPlus::SgfcDocument::RemoveAllGames ( )
overridevirtual

Removes all games from the collection of games that together make up the document.

Implements LibSgfcPlusPlus::ISgfcDocument.

◆ RemoveGame()

void LibSgfcPlusPlus::SgfcDocument::RemoveGame ( std::shared_ptr< ISgfcGame > game)
overridevirtual

Removes game from the collection of games that together make up the document.

Exceptions
std::invalid_argumentIs thrown if game is not part of the collection of games that together make up the document.

Implements LibSgfcPlusPlus::ISgfcDocument.

◆ SetGames()

void LibSgfcPlusPlus::SgfcDocument::SetGames ( const std::vector< std::shared_ptr< ISgfcGame > > & games)
overridevirtual

Sets the collection of games that together make up the document to games, replacing the previous collection. games may not contain nullptr. games may not contain duplicates.

Exceptions
std::invalid_argumentIs thrown if games contains a nullptr element, or if games contains duplicate elements.

Implements LibSgfcPlusPlus::ISgfcDocument.


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