libsgfc++ 2.0.1
A C++ library that uses SGFC to read and write SGF (Smart Game Format) data.
|
The SgfcSinglePropertyValue class provides an implementation of the ISgfcSinglePropertyValue interface. See the interface header file for documentation. More...
#include <SgfcSinglePropertyValue.h>
Public Member Functions | |
SgfcSinglePropertyValue (const std::string &rawValue) | |
Initializes a newly constructed SgfcSinglePropertyValue object that has the raw property string value rawValue. The value type is SgfcPropertyValueType::Unknown, HasTypedValue() returns false and GetTypeConversionErrorMessage() returns an empty string. | |
SgfcSinglePropertyValue (const std::string &rawValue, SgfcPropertyValueType valueType) | |
Initializes a newly constructed SgfcSinglePropertyValue object that has the raw property string value rawValue and the value type valueType. HasTypedValue() returns true and GetTypeConversionErrorMessage() returns an empty string. | |
SgfcSinglePropertyValue (const std::string &rawValue, SgfcPropertyValueType valueType, const std::string &typeConversionErrorMessage) | |
Initializes a newly constructed SgfcSinglePropertyValue object that has the raw property string value rawValue and the value type valueType. HasTypedValue() returns false and GetTypeConversionErrorMessage() returns typeConversionErrorMessage. | |
virtual | ~SgfcSinglePropertyValue () |
Destroys and cleans up the SgfcSinglePropertyValue object. | |
virtual bool | IsComposedValue () const override |
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 override |
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 SgfcPropertyValueType | GetValueType () const override |
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 override |
Returns true if the raw string value returned by GetRawValue() is available as a typed value. Otherwise returns false. | |
virtual std::string | GetTypeConversionErrorMessage () const override |
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 override |
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 override |
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 override |
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 override |
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 override |
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 override |
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 override |
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 override |
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 override |
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 override |
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::ISgfcSinglePropertyValue | |
ISgfcSinglePropertyValue () | |
Initializes a newly constructed ISgfcSinglePropertyValue object. | |
virtual | ~ISgfcSinglePropertyValue () |
Destroys and cleans up the ISgfcSinglePropertyValue 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 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 SgfcSinglePropertyValue class provides an implementation of the ISgfcSinglePropertyValue interface. See the interface header file for documentation.
LibSgfcPlusPlus::SgfcSinglePropertyValue::SgfcSinglePropertyValue | ( | const std::string & | rawValue, |
SgfcPropertyValueType | valueType ) |
Initializes a newly constructed SgfcSinglePropertyValue object that has the raw property string value rawValue and the value type valueType. HasTypedValue() returns true and GetTypeConversionErrorMessage() returns an empty string.
Subclasses are expected to use this constructor.
|
overridevirtual |
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:
Implements LibSgfcPlusPlus::ISgfcSinglePropertyValue.
|
overridevirtual |
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.
Implements LibSgfcPlusPlus::ISgfcSinglePropertyValue.
|
overridevirtual |
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.
Implements LibSgfcPlusPlus::ISgfcSinglePropertyValue.
|
overridevirtual |
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.
Implements LibSgfcPlusPlus::ISgfcSinglePropertyValue.
|
overridevirtual |
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.
Implements LibSgfcPlusPlus::ISgfcPropertyValue.
|
overridevirtual |
Returns an ISgfcColorPropertyValue object if GetValueType() returns SgfcPropertyValueType::Color. Returns nullptr otherwise. The caller is not the owner of the returned object.
Implements LibSgfcPlusPlus::ISgfcSinglePropertyValue.
Reimplemented in LibSgfcPlusPlus::SgfcColorPropertyValue.
|
overridevirtual |
Returns an ISgfcDoublePropertyValue object if GetValueType() returns SgfcPropertyValueType::Double. Returns nullptr otherwise. The caller is not the owner of the returned object.
Implements LibSgfcPlusPlus::ISgfcSinglePropertyValue.
Reimplemented in LibSgfcPlusPlus::SgfcDoublePropertyValue.
|
overridevirtual |
Returns an ISgfcMovePropertyValue object if GetValueType() returns SgfcPropertyValueType::Move. Returns nullptr otherwise. The caller is not the owner of the returned object.
Implements LibSgfcPlusPlus::ISgfcSinglePropertyValue.
Reimplemented in LibSgfcPlusPlus::SgfcMovePropertyValue.
|
overridevirtual |
Returns an ISgfcNumberPropertyValue object if GetValueType() returns SgfcPropertyValueType::Number. Returns nullptr otherwise. The caller is not the owner of the returned object.
Implements LibSgfcPlusPlus::ISgfcSinglePropertyValue.
Reimplemented in LibSgfcPlusPlus::SgfcNumberPropertyValue.
|
overridevirtual |
Returns an ISgfcPointPropertyValue object if GetValueType() returns SgfcPropertyValueType::Point. Returns nullptr otherwise. The caller is not the owner of the returned object.
Implements LibSgfcPlusPlus::ISgfcSinglePropertyValue.
Reimplemented in LibSgfcPlusPlus::SgfcPointPropertyValue.
|
overridevirtual |
Returns an ISgfcRealPropertyValue object if GetValueType() returns SgfcPropertyValueType::Real. Returns nullptr otherwise. The caller is not the owner of the returned object.
Implements LibSgfcPlusPlus::ISgfcSinglePropertyValue.
Reimplemented in LibSgfcPlusPlus::SgfcRealPropertyValue.
|
overridevirtual |
Returns an ISgfcSimpleTextPropertyValue object if GetValueType() returns SgfcPropertyValueType::SimpleText. Returns nullptr otherwise. The caller is not the owner of the returned object.
Implements LibSgfcPlusPlus::ISgfcSinglePropertyValue.
Reimplemented in LibSgfcPlusPlus::SgfcSimpleTextPropertyValue.
|
overridevirtual |
Returns nullptr if IsComposedValue() returns true. Returns an ISgfcSinglePropertyValue object if IsComposedValue() returns false. The caller is not the owner of the ISgfcSinglePropertyValue object.
Reimplemented from LibSgfcPlusPlus::ISgfcPropertyValue.
|
overridevirtual |
Returns an ISgfcStonePropertyValue object if GetValueType() returns SgfcPropertyValueType::Stone. Returns nullptr otherwise. The caller is not the owner of the returned object.
Implements LibSgfcPlusPlus::ISgfcSinglePropertyValue.
Reimplemented in LibSgfcPlusPlus::SgfcStonePropertyValue.
|
overridevirtual |
Returns an ISgfcTextPropertyValue object if GetValueType() returns SgfcPropertyValueType::Text. Returns nullptr otherwise. The caller is not the owner of the returned object.
Implements LibSgfcPlusPlus::ISgfcSinglePropertyValue.
Reimplemented in LibSgfcPlusPlus::SgfcTextPropertyValue.