libsgfc++ 2.0.1
A C++ library that uses SGFC to read and write SGF (Smart Game Format) data.
Loading...
Searching...
No Matches
Static Public Member Functions | List of all members
LibSgfcPlusPlus::SgfcGameUtility Class Reference

The SgfcGameUtility class is a container for static helper functions related to game logic. More...

#include <SgfcGameUtility.h>

Static Public Member Functions

static SgfcGameType GetGameType (const std::vector< std::shared_ptr< ISgfcPropertyValue > > &propertyValues)
 Returns the property value(s) in propertyValues interpreted as an SgfcGameType value.
 
static SgfcNumber GetGameTypeAsNumber (const std::vector< std::shared_ptr< ISgfcPropertyValue > > &propertyValues)
 Returns the property value(s) in propertyValues interpreted as an SgfcNumber value.
 
static SgfcBoardSize GetBoardSize (const std::vector< std::shared_ptr< ISgfcPropertyValue > > &propertyValues, SgfcGameType gameType)
 Returns the property values in propertyValues interpreted as an SgfcBoardSize value.
 

Detailed Description

The SgfcGameUtility class is a container for static helper functions related to game logic.

Member Function Documentation

◆ GetBoardSize()

SgfcBoardSize LibSgfcPlusPlus::SgfcGameUtility::GetBoardSize ( const std::vector< std::shared_ptr< ISgfcPropertyValue > > & propertyValues,
SgfcGameType gameType )
static

Returns the property values in propertyValues interpreted as an SgfcBoardSize value.

Return values
SgfcBoardSizeIf propertyValues contains one element that can be converted to a valid SgfcBoardSize value. The value is guaranteed not to be SgfcConstants::BoardSizeNone nor SgfcConstants::BoardSizeInvalid.
SgfcConstants::BoardSizeDefaultGoIf propertyValues has no elements, and gameType is SgfcGameType::Go.
SgfcConstants::BoardSizeDefaultChessIf propertyValues has no elements, and gameType is SgfcGameType::Chess.
SgfcConstants::BoardSizeNoneIf propertyValues has no elements, but gameType is neither SgfcGameType::Go nor SgfcGameType::Chess.
SgfcConstants::BoardSizeInvalidIf the property value(s) in propertyValues cannot be converted to an SgfcBoardSize value (propertyValues has more than one element, or the element is neither an ISgfcNumberPropertyValue object nor an ISgfcComosedPropertyValue object consisting of two ISgfcNumberPropertyValue objects), or if conversion is possible but the SgfcBoardSize value violates the constraints defined by the SGF standard. See the documentation of SgfcConstants::BoardSizeInvalid for details.

◆ GetGameType()

SgfcGameType LibSgfcPlusPlus::SgfcGameUtility::GetGameType ( const std::vector< std::shared_ptr< ISgfcPropertyValue > > & propertyValues)
static

Returns the property value(s) in propertyValues interpreted as an SgfcGameType value.

Return values
SgfcGameTypeIf propertyValues contains a single element, and that element can be converted to an SgfcNumber value, and that value is defined in the SGF standard, then the SgfcGameType value that corresponds to the SgfcNumber value is returned. The value is guaranteed not to be SgfcGameType::Unknown.
SgfcConstants::DefaultGameTypeIf propertyValues has no elements. The value is guaranteed not to be SgfcGameType::Unknown.
SgfcGameType::UnknownIf the property value(s) in propertyValues cannot be converted to an SgfcNumber value (propertyValues has more than one element, or it has a single element that is not an ISgfcNumberPropertyValue object), or if conversion is possible but the SgfcNumber value is not defined in the SGF standard. Invoke GetGameTypeAsNumber() to obtain the game type as SgfcNumber value.

◆ GetGameTypeAsNumber()

SgfcNumber LibSgfcPlusPlus::SgfcGameUtility::GetGameTypeAsNumber ( const std::vector< std::shared_ptr< ISgfcPropertyValue > > & propertyValues)
static

Returns the property value(s) in propertyValues interpreted as an SgfcNumber value.

This is useful if GetGameType() returns SgfcGameType::Unknown because the SgfcNumber value is not defined in the SGF standard and cannot be mapped to a member of the enumeration SgfcGameType.

Return values
SgfcNumberIf propertyValues contains a single element, and that element can be converted to an SgfcNumber value, then that SgfcNumber value is returned. If propertyValues has no elements, then this method returns the SgfcNumber value that corresponds to SgfcConstants::DefaultGameType.
SgfcConstants::GameTypeNaNIf the property value(s) in propertyValues cannot be converted to an SgfcNumber value, either because propertyValues has more than one element, or its single element is not an ISgfcNumberPropertyValue object.

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