libsgfc++ 2.0.1
A C++ library that uses SGFC to read and write SGF (Smart Game Format) data.
|
The SgfcProperty class provides an implementation of the ISgfcProperty interface. See the interface header file for documentation. More...
#include <SgfcProperty.h>
Public Member Functions | |
SgfcProperty (SgfcPropertyType propertyType, const std::string &propertyName) | |
Initializes a newly constructed SgfcProperty object. The property has the specified type propertyType and name propertyName. The property has no values. | |
SgfcProperty (SgfcPropertyType propertyType, const std::string &propertyName, const std::vector< std::shared_ptr< ISgfcPropertyValue > > &propertyValues) | |
Initializes a newly constructed SgfcProperty object. The property has the specified type propertyType, name propertyName and property values propertyValues. | |
virtual | ~SgfcProperty () |
Destroys and cleans up the SgfcProperty object. | |
virtual SgfcPropertyType | GetPropertyType () const override |
Returns the type of the property. Returns SgfcPropertyType::Unknown if the property is a custom property that is not defined in the SGF standard. | |
virtual std::string | GetPropertyName () const override |
Returns the name of the property. | |
virtual SgfcPropertyCategory | GetPropertyCategory () const override |
Returns the category that the property is classified as. Returns SgfcPropertyCategory::Miscellaneous if the property is a custom property that is not defined in the SGF standard. | |
virtual SgfcPropertyTraits | GetTraits () const override |
Returns the property's traits. | |
virtual bool | HasTrait (SgfcPropertyTrait trait) const override |
Returns true if the property has the trait trait. Returns false if the property does not have the trait trait. | |
virtual bool | HasPropertyValues () const override |
Returns true if the property has one or more values. Returns false if the property has no values. | |
virtual std::vector< std::shared_ptr< ISgfcPropertyValue > > | GetPropertyValues () const override |
Returns a collection with the values of the property. The collection is empty if the property has no values. The order in which values appear in the collection matches the order in which values were specified when the ISgfcProperty was constructed. | |
virtual void | SetPropertyValues (const std::vector< std::shared_ptr< ISgfcPropertyValue > > &propertyValues) override |
Sets the values of the property to propertyValues. The previous values are discarded. propertyValues may not contain nullptr. propertyValues may not contain duplicates. | |
virtual void | AppendPropertyValue (std::shared_ptr< ISgfcPropertyValue > propertyValue) override |
Adds propertyValue as the last value to the property's collection of values. propertyValue may not be nullptr. | |
virtual void | RemovePropertyValue (std::shared_ptr< ISgfcPropertyValue > propertyValue) override |
Removes propertyValue from the property's collection of values. | |
virtual void | RemoveAllPropertyValues () override |
Removes all values from the property's collection of values. | |
virtual std::shared_ptr< ISgfcPropertyValue > | GetPropertyValue () const override |
Returns the property's first value if the property has any values. Returns nullptr if the property has no values. | |
virtual const ISgfcGameTypeProperty * | ToGameTypeProperty () const override |
Returns an ISgfcGameTypeProperty object if GetPropertyType() returns SgfcPropertyType::GM. Returns nullptr otherwise. The caller is not the owner of the returned object. | |
virtual const ISgfcBoardSizeProperty * | ToBoardSizeProperty () const override |
Returns an ISgfcBoardSizeProperty object if GetPropertyType() returns SgfcPropertyType::SZ. Returns nullptr otherwise. The caller is not the owner of the returned object. | |
Public Member Functions inherited from LibSgfcPlusPlus::ISgfcProperty | |
ISgfcProperty () | |
Initializes a newly constructed ISgfcProperty object. | |
virtual | ~ISgfcProperty () |
Destroys and cleans up the ISgfcProperty object. | |
The SgfcProperty class provides an implementation of the ISgfcProperty interface. See the interface header file for documentation.
LibSgfcPlusPlus::SgfcProperty::SgfcProperty | ( | SgfcPropertyType | propertyType, |
const std::string & | propertyName, | ||
const std::vector< std::shared_ptr< ISgfcPropertyValue > > & | propertyValues ) |
Initializes a newly constructed SgfcProperty object. The property has the specified type propertyType, name propertyName and property values propertyValues.
std::invalid_argument | Is thrown if propertyValues contains a nullptr element, or if propertyValues contains duplicate elements. |
|
overridevirtual |
Adds propertyValue as the last value to the property's collection of values. propertyValue may not be nullptr.
This setter makes no attempt to check the validity of the property's collection of values after adding propertyValue.
std::invalid_argument | Is thrown if propertyValue is nullptr or if propertyValue is already in the property's collection of values. |
Implements LibSgfcPlusPlus::ISgfcProperty.
|
overridevirtual |
Returns the category that the property is classified as. Returns SgfcPropertyCategory::Miscellaneous if the property is a custom property that is not defined in the SGF standard.
Implements LibSgfcPlusPlus::ISgfcProperty.
|
overridevirtual |
Returns the name of the property.
The property name cannot be changed after the ISgfcProperty has been constructed.
All properties defined in the SGF standard have a name that consists of two uppercase letters. Application-specific properties not defined in the standard may not adhere to this restriction (although the standard advises against this).
Implements LibSgfcPlusPlus::ISgfcProperty.
|
overridevirtual |
Returns the type of the property. Returns SgfcPropertyType::Unknown if the property is a custom property that is not defined in the SGF standard.
The property type cannot be changed after the ISgfcProperty has been constructed.
Implements LibSgfcPlusPlus::ISgfcProperty.
|
overridevirtual |
Returns the property's first value if the property has any values. Returns nullptr if the property has no values.
This is a convenience method for properties that can have only a single value.
Implements LibSgfcPlusPlus::ISgfcProperty.
|
overridevirtual |
Returns a collection with the values of the property. The collection is empty if the property has no values. The order in which values appear in the collection matches the order in which values were specified when the ISgfcProperty was constructed.
The EBNF in the SGF standard says that at least one value must be present. This can be a value that has the value type "None", which is defined to be an empty string. The meaning for the file content is clear: Something like XY[] is possible. In the library's object model, however, a "None" value is translated to an empty collection.
Implements LibSgfcPlusPlus::ISgfcProperty.
|
overridevirtual |
Returns the property's traits.
Returns SgfcConstants::PropertyTraitsNone if the property has no traits.
Implements LibSgfcPlusPlus::ISgfcProperty.
|
overridevirtual |
Returns true if the property has one or more values. Returns false if the property has no values.
Implements LibSgfcPlusPlus::ISgfcProperty.
|
overridevirtual |
Returns true if the property has the trait trait. Returns false if the property does not have the trait trait.
Implements LibSgfcPlusPlus::ISgfcProperty.
|
overridevirtual |
Removes all values from the property's collection of values.
This setter makes no attempt to check the validity of the property's collection of values after removing all values.
Implements LibSgfcPlusPlus::ISgfcProperty.
|
overridevirtual |
Removes propertyValue from the property's collection of values.
This setter makes no attempt to check the validity of the property's collection of values after removing propertyValue.
std::invalid_argument | Is thrown if propertyValue is not part of the property's collection of values. |
Implements LibSgfcPlusPlus::ISgfcProperty.
|
overridevirtual |
Sets the values of the property to propertyValues. The previous values are discarded. propertyValues may not contain nullptr. propertyValues may not contain duplicates.
This setter makes no attempt to check the validity of the property values. A last-ditch attempt at validation is made by SGFC later when the game tree is written to an SGF file or to an SGF content string, but this is unlikely to catch all mistakes. It is ultimately the responsibility of the library client to take care that the values are valid. The consequence of faulty values is that the library client might be unable to read in the game tree again after it has been written out.
std::invalid_argument | Is thrown if propertyValues contains a nullptr element, or if propertyValues contains duplicate elements. |
Implements LibSgfcPlusPlus::ISgfcProperty.
|
overridevirtual |
Returns an ISgfcBoardSizeProperty object if GetPropertyType() returns SgfcPropertyType::SZ. Returns nullptr otherwise. The caller is not the owner of the returned object.
Implements LibSgfcPlusPlus::ISgfcProperty.
Reimplemented in LibSgfcPlusPlus::SgfcBoardSizeProperty.
|
overridevirtual |
Returns an ISgfcGameTypeProperty object if GetPropertyType() returns SgfcPropertyType::GM. Returns nullptr otherwise. The caller is not the owner of the returned object.
Implements LibSgfcPlusPlus::ISgfcProperty.
Reimplemented in LibSgfcPlusPlus::SgfcGameTypeProperty.