libsgfc++ 2.0.1
A C++ library that uses SGFC to read and write SGF (Smart Game Format) data.
|
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>
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 ISgfcNumberPropertyValue * | ToNumberValue () 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 ISgfcRealPropertyValue * | ToRealValue () 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 ISgfcDoublePropertyValue * | ToDoubleValue () 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 ISgfcColorPropertyValue * | ToColorValue () 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 ISgfcSimpleTextPropertyValue * | ToSimpleTextValue () 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 ISgfcTextPropertyValue * | ToTextValue () 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 ISgfcPointPropertyValue * | ToPointValue () 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 ISgfcMovePropertyValue * | ToMoveValue () 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 ISgfcStonePropertyValue * | ToStoneValue () 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 ISgfcSinglePropertyValue * | ToSingleValue () 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 ISgfcComposedPropertyValue * | ToComposedValue () 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. | |
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.
|
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:
Implemented in LibSgfcPlusPlus::SgfcSinglePropertyValue.
|
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.
|
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.
Implemented in LibSgfcPlusPlus::SgfcSinglePropertyValue.
|
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:
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.