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::ISgfcSinglePropertyValue Class Referenceabstract

The ISgfcSinglePropertyValue interface provides access to one of the values of a property of an SGF node. The value is a single value of a basic value type. Some properties allow composed values - see ISgfcComposedPropertyValue for details. More...

#include <ISgfcSinglePropertyValue.h>

Inheritance diagram for LibSgfcPlusPlus::ISgfcSinglePropertyValue:
LibSgfcPlusPlus::ISgfcPropertyValue LibSgfcPlusPlus::ISgfcColorPropertyValue LibSgfcPlusPlus::ISgfcDoublePropertyValue LibSgfcPlusPlus::ISgfcMovePropertyValue LibSgfcPlusPlus::ISgfcNumberPropertyValue LibSgfcPlusPlus::ISgfcPointPropertyValue LibSgfcPlusPlus::ISgfcRealPropertyValue LibSgfcPlusPlus::ISgfcSimpleTextPropertyValue LibSgfcPlusPlus::ISgfcStonePropertyValue LibSgfcPlusPlus::ISgfcTextPropertyValue LibSgfcPlusPlus::SgfcSinglePropertyValue

Public Member Functions

 ISgfcSinglePropertyValue ()
 Initializes a newly constructed ISgfcSinglePropertyValue object.
 
virtual ~ISgfcSinglePropertyValue ()
 Destroys and cleans up the ISgfcSinglePropertyValue object.
 
virtual SgfcPropertyValueType GetValueType () const =0
 Returns the concrete type of the property value object. Depending on the value returned, a caller then knows which one of the convenience casting methods to use.
 
virtual bool HasTypedValue () const =0
 Returns true if the raw string value returned by GetRawValue() is available as a typed value. Otherwise returns false.
 
virtual std::string GetTypeConversionErrorMessage () const =0
 Returns an error message that describes why the raw string value returned by GetRawValue() could not be converted to the typed value returned by GetValueType().
 
virtual std::string GetRawValue () const =0
 Returns the property value as a raw string, i.e. as close as possible as it appears in the original SGF content.
 
virtual const ISgfcNumberPropertyValueToNumberValue () const =0
 Returns an ISgfcNumberPropertyValue object if GetValueType() returns SgfcPropertyValueType::Number. Returns nullptr otherwise. The caller is not the owner of the returned object.
 
virtual const ISgfcRealPropertyValueToRealValue () const =0
 Returns an ISgfcRealPropertyValue object if GetValueType() returns SgfcPropertyValueType::Real. Returns nullptr otherwise. The caller is not the owner of the returned object.
 
virtual const ISgfcDoublePropertyValueToDoubleValue () const =0
 Returns an ISgfcDoublePropertyValue object if GetValueType() returns SgfcPropertyValueType::Double. Returns nullptr otherwise. The caller is not the owner of the returned object.
 
virtual const ISgfcColorPropertyValueToColorValue () const =0
 Returns an ISgfcColorPropertyValue object if GetValueType() returns SgfcPropertyValueType::Color. Returns nullptr otherwise. The caller is not the owner of the returned object.
 
virtual const ISgfcSimpleTextPropertyValueToSimpleTextValue () const =0
 Returns an ISgfcSimpleTextPropertyValue object if GetValueType() returns SgfcPropertyValueType::SimpleText. Returns nullptr otherwise. The caller is not the owner of the returned object.
 
virtual const ISgfcTextPropertyValueToTextValue () const =0
 Returns an ISgfcTextPropertyValue object if GetValueType() returns SgfcPropertyValueType::Text. Returns nullptr otherwise. The caller is not the owner of the returned object.
 
virtual const ISgfcPointPropertyValueToPointValue () const =0
 Returns an ISgfcPointPropertyValue object if GetValueType() returns SgfcPropertyValueType::Point. Returns nullptr otherwise. The caller is not the owner of the returned object.
 
virtual const ISgfcMovePropertyValueToMoveValue () const =0
 Returns an ISgfcMovePropertyValue object if GetValueType() returns SgfcPropertyValueType::Move. Returns nullptr otherwise. The caller is not the owner of the returned object.
 
virtual const ISgfcStonePropertyValueToStoneValue () const =0
 Returns an ISgfcStonePropertyValue object if GetValueType() returns SgfcPropertyValueType::Stone. Returns nullptr otherwise. The caller is not the owner of the returned object.
 
- Public Member Functions inherited from LibSgfcPlusPlus::ISgfcPropertyValue
 ISgfcPropertyValue ()
 Initializes a newly constructed ISgfcPropertyValue object.
 
virtual ~ISgfcPropertyValue ()
 Destroys and cleans up the ISgfcPropertyValue object.
 
virtual bool IsComposedValue () const =0
 Returns true if the ISgfcPropertyValue object holds a "composed" value, i.e. a value that consists of a composite of two single values. Returns false if the ISgfcPropertyValue holds only a single value.
 
virtual const ISgfcSinglePropertyValueToSingleValue () const
 Returns nullptr if IsComposedValue() returns true. Returns an ISgfcSinglePropertyValue object if IsComposedValue() returns false. The caller is not the owner of the ISgfcSinglePropertyValue object.
 
virtual const ISgfcComposedPropertyValueToComposedValue () const
 Returns an ISgfcComposedPropertyValue object if IsComposedValue() returns true. Returns nullptr if IsComposedValue() returns false. The caller is not the owner of the ISgfcComposedPropertyValue object.
 

Detailed Description

The ISgfcSinglePropertyValue interface provides access to one of the values of a property of an SGF node. The value is a single value of a basic value type. Some properties allow composed values - see ISgfcComposedPropertyValue for details.

ISgfcSinglePropertyValue contains a number of convenience methods that help casting an ISgfcSinglePropertyValue object to a concrete type (e.g. ToNumberValue()). The return value of GetValueType() provides the information which casting method to use (but check HasTypedValue() first).

Property value objects are created either programmatically by the library client by invoking a factory method, or they are created internally by libsgfc++ as part of parsing SGF content. In the latter case parsing of raw string values might fail, which is why the methods HasTypedValue(), GetTypeConversionErrorMessage() and GetRawValue() exist. Carefully read each method documentation to understand how they differ for the two creation scenarios.

ISgfcSinglePropertyValue is immutable, i.e. once the ISgfcSinglePropertyValue object is constructed it cannot be changed.

Member Function Documentation

◆ GetRawValue()

virtual std::string LibSgfcPlusPlus::ISgfcSinglePropertyValue::GetRawValue ( ) const
pure virtual

Returns the property value as a raw string, i.e. as close as possible as it appears in the original SGF content.

If the property value object was created programmatically by the library client by invoking a factory method, then GetRawValue() returns a properly stringified version of the typed property value. Color and Double values are converted to the string value as defined by the SGF standard.

If the property value object was created internally by libsgfc++ as part of parsing SGF content, then the following processing is applied to the original SGF content before it is made available from this getter as raw string:

  • The escape character ("\") is stripped from SimpleText and Text values (unless it was escaped itself). - Values that are not SimpleText or Text are trimmed of leading and trailing whitespace. - In SimpleText values, whitespace characters other than space are converted to space. Exception: Escaped line breaks are removed entirely. - In Text values, whitespace characters other than line breaks are converted to space. In addition, escaped line breaks are removed entirely. - In Move values, if the game type is Go and the board size is <= 19x19, the value "tt" is converted to an empty string. This is in accord with the SGF standard that defines an empty string and value "tt" both to express a pass move, but in FF4 the "tt" representation is kept only for compatibility with FF3.

Implemented in LibSgfcPlusPlus::SgfcSinglePropertyValue.

◆ GetTypeConversionErrorMessage()

virtual std::string LibSgfcPlusPlus::ISgfcSinglePropertyValue::GetTypeConversionErrorMessage ( ) const
pure virtual

Returns an error message that describes why the raw string value returned by GetRawValue() could not be converted to the typed value returned by GetValueType().

Returns an empty string if HasTypedValue() returns true, or if it returns false but GetValueType() returns SgfcPropertyValueType::Unknown.

This method is intended for when the property value object was created internally by libsgfc++ as part of parsing SGF content, but there was an error converting the raw string value to the expected value type.

If the property value object was created programmatically by the library client by invoking a factory method, then GetTypeConversionErrorMessage() always returns an empty string because the library client is not allowed to specify untyped property values.

Implemented in LibSgfcPlusPlus::SgfcSinglePropertyValue.

◆ GetValueType()

virtual SgfcPropertyValueType LibSgfcPlusPlus::ISgfcSinglePropertyValue::GetValueType ( ) const
pure virtual

Returns the concrete type of the property value object. Depending on the value returned, a caller then knows which one of the convenience casting methods to use.

If the property value object was created internally by libsgfc++ as part of parsing SGF content, then the outcome is as follows:

If the property value object was created programmatically by the library client by invoking a factory method, then GetValueType() returns whichever SgfcPropertyValueType was requested by the library client. HasTypeValue() always returns true, unless the library client explicitly requested an untyped property value for a custom property.

Note
GetValueType() never returns SgfcPropertyValueType::None.

Implemented in LibSgfcPlusPlus::SgfcSinglePropertyValue.

◆ HasTypedValue()

virtual bool LibSgfcPlusPlus::ISgfcSinglePropertyValue::HasTypedValue ( ) const
pure virtual

Returns true if the raw string value returned by GetRawValue() is available as a typed value. Otherwise returns false.

"Available as a typed value" means that ISgfcSinglePropertyValue can be cast to a concrete type and that type can then be used to retrieve the typed value. Example: GetValueType() returns SgfcPropertyValueType::Number. ToNumberValue() can therefore be invoked to obtain an ISgfcNumberPropertyValue object, and ISgfcNumberPropertyValue::GetNumberValue() can then be invoked to retrieve the signed integer number that corresponds to the raw string value that GetRawValue() returns.

"Not available as a typed value" (i.e. HasTypedValue() returns false) means that the ISgfcSinglePropertyValue object cannot be cast to any concrete type, i.e. all of the convenience casting methods return nullptr. The interpretation of the raw property string value returned by GetRawValue() is left to the library client.

If the property value object was created internally by libsgfc++ as part of parsing SGF content, then the outcome is as follows:

  • For values of properties that are defined in the SGF standard libsgfc++ attempts to interpret the raw property string value according to the value type defined property in the SGF standard. HasTypedValue() returns true if that interpretation succeeds, otherwwise it returns false and GetTypeConversionErrorMessage() returns a description of why the interpretation failed.
  • HasTypedValue() always returns false for values of properties that are not defined in the SGF standard (aka "custom properties"). GetTypeConversionErrorMessage() returns an empty string in that case because libsgfc++ did not attempt an interpretation.

If the property value object was created programmatically by the library client by invoking a factory method, then HasTypedValue() returns true unless the library client explicitly requested an untyped property value for a custom property.

Implemented in LibSgfcPlusPlus::SgfcSinglePropertyValue.

◆ ToColorValue()

virtual const ISgfcColorPropertyValue * LibSgfcPlusPlus::ISgfcSinglePropertyValue::ToColorValue ( ) const
pure virtual

Returns an ISgfcColorPropertyValue object if GetValueType() returns SgfcPropertyValueType::Color. Returns nullptr otherwise. The caller is not the owner of the returned object.

Implemented in LibSgfcPlusPlus::SgfcSinglePropertyValue, and LibSgfcPlusPlus::SgfcColorPropertyValue.

◆ ToDoubleValue()

virtual const ISgfcDoublePropertyValue * LibSgfcPlusPlus::ISgfcSinglePropertyValue::ToDoubleValue ( ) const
pure virtual

Returns an ISgfcDoublePropertyValue object if GetValueType() returns SgfcPropertyValueType::Double. Returns nullptr otherwise. The caller is not the owner of the returned object.

Implemented in LibSgfcPlusPlus::SgfcSinglePropertyValue, and LibSgfcPlusPlus::SgfcDoublePropertyValue.

◆ ToMoveValue()

virtual const ISgfcMovePropertyValue * LibSgfcPlusPlus::ISgfcSinglePropertyValue::ToMoveValue ( ) const
pure virtual

Returns an ISgfcMovePropertyValue object if GetValueType() returns SgfcPropertyValueType::Move. Returns nullptr otherwise. The caller is not the owner of the returned object.

Implemented in LibSgfcPlusPlus::SgfcSinglePropertyValue, and LibSgfcPlusPlus::SgfcMovePropertyValue.

◆ ToNumberValue()

virtual const ISgfcNumberPropertyValue * LibSgfcPlusPlus::ISgfcSinglePropertyValue::ToNumberValue ( ) const
pure virtual

Returns an ISgfcNumberPropertyValue object if GetValueType() returns SgfcPropertyValueType::Number. Returns nullptr otherwise. The caller is not the owner of the returned object.

Implemented in LibSgfcPlusPlus::SgfcSinglePropertyValue, and LibSgfcPlusPlus::SgfcNumberPropertyValue.

◆ ToPointValue()

virtual const ISgfcPointPropertyValue * LibSgfcPlusPlus::ISgfcSinglePropertyValue::ToPointValue ( ) const
pure virtual

Returns an ISgfcPointPropertyValue object if GetValueType() returns SgfcPropertyValueType::Point. Returns nullptr otherwise. The caller is not the owner of the returned object.

Implemented in LibSgfcPlusPlus::SgfcSinglePropertyValue, and LibSgfcPlusPlus::SgfcPointPropertyValue.

◆ ToRealValue()

virtual const ISgfcRealPropertyValue * LibSgfcPlusPlus::ISgfcSinglePropertyValue::ToRealValue ( ) const
pure virtual

Returns an ISgfcRealPropertyValue object if GetValueType() returns SgfcPropertyValueType::Real. Returns nullptr otherwise. The caller is not the owner of the returned object.

Implemented in LibSgfcPlusPlus::SgfcSinglePropertyValue, and LibSgfcPlusPlus::SgfcRealPropertyValue.

◆ ToSimpleTextValue()

virtual const ISgfcSimpleTextPropertyValue * LibSgfcPlusPlus::ISgfcSinglePropertyValue::ToSimpleTextValue ( ) const
pure virtual

Returns an ISgfcSimpleTextPropertyValue object if GetValueType() returns SgfcPropertyValueType::SimpleText. Returns nullptr otherwise. The caller is not the owner of the returned object.

Implemented in LibSgfcPlusPlus::SgfcSinglePropertyValue, and LibSgfcPlusPlus::SgfcSimpleTextPropertyValue.

◆ ToStoneValue()

virtual const ISgfcStonePropertyValue * LibSgfcPlusPlus::ISgfcSinglePropertyValue::ToStoneValue ( ) const
pure virtual

Returns an ISgfcStonePropertyValue object if GetValueType() returns SgfcPropertyValueType::Stone. Returns nullptr otherwise. The caller is not the owner of the returned object.

Implemented in LibSgfcPlusPlus::SgfcSinglePropertyValue, and LibSgfcPlusPlus::SgfcStonePropertyValue.

◆ ToTextValue()

virtual const ISgfcTextPropertyValue * LibSgfcPlusPlus::ISgfcSinglePropertyValue::ToTextValue ( ) const
pure virtual

Returns an ISgfcTextPropertyValue object if GetValueType() returns SgfcPropertyValueType::Text. Returns nullptr otherwise. The caller is not the owner of the returned object.

Implemented in LibSgfcPlusPlus::SgfcSinglePropertyValue, and LibSgfcPlusPlus::SgfcTextPropertyValue.


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