libsgfc++ 2.0.1
A C++ library that uses SGFC to read and write SGF (Smart Game Format) data.
|
The SgfcCommandLine class provides an implementation of the ISgfcCommandLine interface. See the interface header file for documentation. More...
#include <SgfcCommandLine.h>
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< ISgfcMessage > | GetInvalidCommandLineReason () 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. | |
The SgfcCommandLine class provides an implementation of the ISgfcCommandLine interface. See the interface header file for documentation.
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).
|
overridevirtual |
Returns the SGFC command line arguments that were used to construct the ISgfcCommandLine object.
Implements LibSgfcPlusPlus::ISgfcCommandLine.
|
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.
std::logic_error | Is thrown if IsCommandLineValid() returns true. |
Implements LibSgfcPlusPlus::ISgfcCommandLine.
|
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.
std::logic_error | Is thrown if IsCommandLineValid() returns false. |
Implements LibSgfcPlusPlus::ISgfcCommandLine.
|
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.
std::logic_error | Is thrown if IsCommandLineValid() returns false. |
Implements LibSgfcPlusPlus::ISgfcCommandLine.
|
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.
|
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.
std::logic_error | Is thrown if IsCommandLineValid() returns false. |
Implements LibSgfcPlusPlus::ISgfcCommandLine.
|
overridevirtual |
Loads the specified SGF content and puts it through the SGFC parser. This method may only be invoked if IsCommandLineValid() returns true.
std::logic_error | Is thrown if IsCommandLineValid() returns false. |
Implements LibSgfcPlusPlus::ISgfcCommandLine.
|
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.
std::logic_error | Is thrown if IsCommandLineValid() returns false. |
Implements LibSgfcPlusPlus::ISgfcCommandLine.
|
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.
std::logic_error | Is thrown if IsSgfContentValid() returns false. |
Implements LibSgfcPlusPlus::ISgfcCommandLine.
|
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.
std::logic_error | Is thrown if IsSgfContentValid() returns false. |
Implements LibSgfcPlusPlus::ISgfcCommandLine.