libsgfc++ 3.0.0
A C++ library that uses SGFC to read and write SGF (Smart Game Format) data.
Loading...
Searching...
No Matches
LibSgfcPlusPlus::SgfcOptions Class Reference

The SgfcOptions class is used to capture a snapshot of the option values in an SGFCOptions struct, and to reconfigure an SGFCOptions struct with those captured values at a later time. More...

#include <SgfcOptions.h>

Public Member Functions

 SgfcOptions ()
 Initializes a newly constructed SgfcOptions object. The object holds default option values.
virtual ~SgfcOptions ()
 Destroys and cleans up the SgfcOptions object.
void CaptureOptions (const SGFCOptions *sourceOptions)
 Captures a snapshot of the option values in sourceOptions.
void RestoreOptions (SGFCOptions *targetOptions) const
 Reconfigures targetOptions with the option values that the SgfcOption object currently holds.

Detailed Description

The SgfcOptions class is used to capture a snapshot of the option values in an SGFCOptions struct, and to reconfigure an SGFCOptions struct with those captured values at a later time.

Some notes about the internal workings of SGFC:

  • An SGFCOptions struct is part of the SGFInfo struct that is passed as a parameter to all major SGFC functions, including ParseArgs(). Thus the option values are available everywhere in SGFC.
  • When SGFInfo is created/initialized with SetupSGFInfo() a custom SGFCOptions object can be passed as a parameter. SetupSGFInfo() uses this to populate the SGFInfo object. This is the mechanism how an SGFCOptions with arbitrary values can be injected into SGFC.
  • When SetupSGFInfo() receives no custom SGFCOptions object, it invokes the SGFC global function SGFCDefaultOptions() to construct a new SGFCOptions object with default values. SGFCDefaultOptions() can also be invoked outside of the context of SetupSGFInfo().
  • When ParseArgs() is invoked it parses the command line arguments that are specified as a parameter and populates the SGFCOptions object inside the SGFInfo object with values that result from these parsing activities. The purpose of the SgfcOptions class is to capture the values in such an SGFCOptions object.

Constructor & Destructor Documentation

◆ SgfcOptions()

LibSgfcPlusPlus::SgfcOptions::SgfcOptions ( )

Initializes a newly constructed SgfcOptions object. The object holds default option values.

Exceptions
std::runtime_errorIs thrown if SGFC fails to allocate memory.

Member Function Documentation

◆ RestoreOptions()

void LibSgfcPlusPlus::SgfcOptions::RestoreOptions ( SGFCOptions * targetOptions) const

Reconfigures targetOptions with the option values that the SgfcOption object currently holds.

If CaptureOptions() has never been invoked before, this applies default option values to targetOptions.

Attention
The members SGFCOptions::forced_encoding and SGFCOptions::default_encoding in targetOptions are configured with pointers into buffers that are valid only for a limited time. The pointers become invalid as soon as CaptureOptions is invoked the next time on the same SgfcOptions object, or when the SgfcOptions object is destroyed.

The documentation for this class was generated from the following files:
  • /Users/dev/Documents/libsgfcplusplus/src/sgfc/backend/SgfcOptions.h
  • /Users/dev/Documents/libsgfcplusplus/src/sgfc/backend/SgfcOptions.cpp