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

The SgfcCommandLine class provides an implementation of the ISgfcCommandLine interface. See the interface header file for documentation. More...

#include <SgfcCommandLine.h>

Inheritance diagram for LibSgfcPlusPlus::SgfcCommandLine:
LibSgfcPlusPlus::ISgfcCommandLine

Public Member Functions

 SgfcCommandLine (const std::vector< std::shared_ptr< ISgfcArgument > > &arguments)
 Initializes a newly constructed SgfcCommandLine object.
 
virtual ~SgfcCommandLine ()
 Destroys and cleans up the SgfcCommandLine object.
 
virtual std::vector< std::shared_ptr< ISgfcArgument > > GetArguments () const override
 Returns the SGFC command line arguments that were used to construct the ISgfcCommandLine object.
 
virtual bool IsCommandLineValid () const override
 Returns true if the SGFC command line arguments that GetArguments() returns are valid. Returns false if they are not valid.
 
virtual std::shared_ptr< ISgfcMessageGetInvalidCommandLineReason () const override
 Returns an ISgfcMessage object with message type SgfcMessageType::FatalError that describes why the SGFC command line arguments that GetArguments() returns are not valid. This method may only be invoked if IsCommandLineValid() returns false.
 
virtual SgfcExitCode LoadSgfFile (const std::string &sgfFilePath) override
 Loads a single .sgf file from the specified path and puts it through the SGFC parser. This method may only be invoked if IsCommandLineValid() returns true.
 
virtual SgfcExitCode LoadSgfContent (const std::string &sgfContent) override
 Loads the specified SGF content and puts it through the SGFC parser. This method may only be invoked if IsCommandLineValid() returns true.
 
virtual bool IsSgfContentValid () const override
 Returns true if the SGF content that was loaded and parsed by the most recent invocation of either LoadSgfFile() or LoadSgfContent() is valid. Returns false if the SGF content is not valid, or if none of the methods have been invoked yet.
 
virtual std::vector< std::shared_ptr< ISgfcMessage > > GetParseResult () const override
 Returns a collection of ISgfcMessage objects which together form the parse result from the most recent invocation of either LoadSgfFile() or LoadSgfContent().
 
virtual SgfcExitCode SaveSgfFile (const std::string &sgfFilePath) override
 Saves the SGF content generated by SGFC after the most recent invocation of either LoadSgfFile() or LoadSgfContent() to the .sgf file at the specified path. This method may only be invoked if IsSgfContentValid() returns true.
 
virtual SgfcExitCode SaveSgfContent (std::string &sgfContent) override
 Saves the SGF content generated by SGFC after the most recent invocation of either LoadSgfFile() or LoadSgfContent() into the specified string object. This method may only be invoked if IsSgfContentValid() returns true.
 
virtual std::vector< std::shared_ptr< ISgfcMessage > > GetSaveResult () const override
 Returns a collection of ISgfcMessage objects which together form the result from the most recent invocation of either SaveSgfFile() or SaveSgfContent().
 
- Public Member Functions inherited from LibSgfcPlusPlus::ISgfcCommandLine
 ISgfcCommandLine ()
 Initializes a newly constructed ISgfcCommandLine object.
 
virtual ~ISgfcCommandLine ()
 Destroys and cleans up the ISgfcCommandLine object.
 

Detailed Description

The SgfcCommandLine class provides an implementation of the ISgfcCommandLine interface. See the interface header file for documentation.

Constructor & Destructor Documentation

◆ SgfcCommandLine()

LibSgfcPlusPlus::SgfcCommandLine::SgfcCommandLine ( const std::vector< std::shared_ptr< ISgfcArgument > > & arguments)

Initializes a newly constructed SgfcCommandLine object.

See SgfcPlusPlusFactory::CreateSgfcCommandLine() for a documentation of the contract that this constructor must fulfill (e.g. exceptions).

Member Function Documentation

◆ GetArguments()

std::vector< std::shared_ptr< ISgfcArgument > > LibSgfcPlusPlus::SgfcCommandLine::GetArguments ( ) const
overridevirtual

Returns the SGFC command line arguments that were used to construct the ISgfcCommandLine object.

Implements LibSgfcPlusPlus::ISgfcCommandLine.

◆ GetInvalidCommandLineReason()

std::shared_ptr< ISgfcMessage > LibSgfcPlusPlus::SgfcCommandLine::GetInvalidCommandLineReason ( ) const
overridevirtual

Returns an ISgfcMessage object with message type SgfcMessageType::FatalError that describes why the SGFC command line arguments that GetArguments() returns are not valid. This method may only be invoked if IsCommandLineValid() returns false.

Exceptions
std::logic_errorIs thrown if IsCommandLineValid() returns true.

Implements LibSgfcPlusPlus::ISgfcCommandLine.

◆ GetParseResult()

std::vector< std::shared_ptr< ISgfcMessage > > LibSgfcPlusPlus::SgfcCommandLine::GetParseResult ( ) const
overridevirtual

Returns a collection of ISgfcMessage objects which together form the parse result from the most recent invocation of either LoadSgfFile() or LoadSgfContent().

The collection is empty if none of the methods have been invoked yet, or if the most recent load operation did not generate any messages.

If the collection is not empty, the messages appear in the order in which they were generated by SGFC.

Exceptions
std::logic_errorIs thrown if IsCommandLineValid() returns false.

Implements LibSgfcPlusPlus::ISgfcCommandLine.

◆ GetSaveResult()

std::vector< std::shared_ptr< ISgfcMessage > > LibSgfcPlusPlus::SgfcCommandLine::GetSaveResult ( ) const
overridevirtual

Returns a collection of ISgfcMessage objects which together form the result from the most recent invocation of either SaveSgfFile() or SaveSgfContent().

The collection is empty if none of the methods have been invoked yet, or if the most recent save operation did not generate any messages.

If the collection is not empty, the messages appear in the order in which they were generated by SGFC.

Exceptions
std::logic_errorIs thrown if IsCommandLineValid() returns false.

Implements LibSgfcPlusPlus::ISgfcCommandLine.

◆ IsCommandLineValid()

bool LibSgfcPlusPlus::SgfcCommandLine::IsCommandLineValid ( ) const
overridevirtual

Returns true if the SGFC command line arguments that GetArguments() returns are valid. Returns false if they are not valid.

One known case where the command line arguments can be invalid is if an illegal parameter is specified for one of the arguments that require a parameter. Example: SgfcArgumentType::BeginningOfSgfData requires an integer parameter. The argument is invalid if an integer value is specified that is not within the accepted range.

There may be other cases. Invoke GetInvalidCommandLineReason() to learn the actual reason why the command line arguments are not valid.

Implements LibSgfcPlusPlus::ISgfcCommandLine.

◆ IsSgfContentValid()

bool LibSgfcPlusPlus::SgfcCommandLine::IsSgfContentValid ( ) const
overridevirtual

Returns true if the SGF content that was loaded and parsed by the most recent invocation of either LoadSgfFile() or LoadSgfContent() is valid. Returns false if the SGF content is not valid, or if none of the methods have been invoked yet.

The SGF content is considered valid if LoadSgfFile() or LoadSgfContent() have been invoked at least once, and if their invocation did not generate a fatal error. A fatal error shows up in the collection of ISgfcMessage objects that GetParseResult() returns, as an ISgfcMessage object with message type SgfcMessageType::FatalError.

Exceptions
std::logic_errorIs thrown if IsCommandLineValid() returns false.

Implements LibSgfcPlusPlus::ISgfcCommandLine.

◆ LoadSgfContent()

SgfcExitCode LibSgfcPlusPlus::SgfcCommandLine::LoadSgfContent ( const std::string & sgfContent)
overridevirtual

Loads the specified SGF content and puts it through the SGFC parser. This method may only be invoked if IsCommandLineValid() returns true.

Returns
An SgfcExitCode value whose numeric value matches one of the exit codes of SGFC.
Exceptions
std::logic_errorIs thrown if IsCommandLineValid() returns false.

Implements LibSgfcPlusPlus::ISgfcCommandLine.

◆ LoadSgfFile()

SgfcExitCode LibSgfcPlusPlus::SgfcCommandLine::LoadSgfFile ( const std::string & sgfFilePath)
overridevirtual

Loads a single .sgf file from the specified path and puts it through the SGFC parser. This method may only be invoked if IsCommandLineValid() returns true.

Returns
An SgfcExitCode value whose numeric value matches one of the exit codes of SGFC.
Exceptions
std::logic_errorIs thrown if IsCommandLineValid() returns false.

Implements LibSgfcPlusPlus::ISgfcCommandLine.

◆ SaveSgfContent()

SgfcExitCode LibSgfcPlusPlus::SgfcCommandLine::SaveSgfContent ( std::string & sgfContent)
overridevirtual

Saves the SGF content generated by SGFC after the most recent invocation of either LoadSgfFile() or LoadSgfContent() into the specified string object. This method may only be invoked if IsSgfContentValid() returns true.

The previous content of sgfContent is overwritten.

Returns
An SgfcExitCode value whose numeric value matches one of the exit codes of SGFC.
Exceptions
std::logic_errorIs thrown if IsSgfContentValid() returns false.

Implements LibSgfcPlusPlus::ISgfcCommandLine.

◆ SaveSgfFile()

SgfcExitCode LibSgfcPlusPlus::SgfcCommandLine::SaveSgfFile ( const std::string & sgfFilePath)
overridevirtual

Saves the SGF content generated by SGFC after the most recent invocation of either LoadSgfFile() or LoadSgfContent() to the .sgf file at the specified path. This method may only be invoked if IsSgfContentValid() returns true.

If a file already exists at the specified path it is overwritten.

Returns
An SgfcExitCode value whose numeric value matches one of the exit codes of SGFC.
Exceptions
std::logic_errorIs thrown if IsSgfContentValid() returns false.

Implements LibSgfcPlusPlus::ISgfcCommandLine.


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