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

The ISgfcProperty interface provides access to the data of a single property of an SGF node. One property has 0-n values. More...

#include <ISgfcProperty.h>

Inheritance diagram for LibSgfcPlusPlus::ISgfcProperty:
LibSgfcPlusPlus::ISgfcBoardSizeProperty LibSgfcPlusPlus::ISgfcGameTypeProperty LibSgfcPlusPlus::SgfcProperty LibSgfcPlusPlus::SgfcBoardSizeProperty LibSgfcPlusPlus::SgfcGameTypeProperty LibSgfcPlusPlus::SgfcBoardSizeProperty LibSgfcPlusPlus::SgfcGameTypeProperty

Public Member Functions

 ISgfcProperty ()
 Initializes a newly constructed ISgfcProperty object.
 
virtual ~ISgfcProperty ()
 Destroys and cleans up the ISgfcProperty object.
 
virtual SgfcPropertyType GetPropertyType () const =0
 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 =0
 Returns the name of the property.
 
virtual SgfcPropertyCategory GetPropertyCategory () const =0
 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 =0
 Returns the property's traits.
 
virtual bool HasTrait (SgfcPropertyTrait trait) const =0
 Returns true if the property has the trait trait. Returns false if the property does not have the trait trait.
 
virtual bool HasPropertyValues () const =0
 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 =0
 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)=0
 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)=0
 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)=0
 Removes propertyValue from the property's collection of values.
 
virtual void RemoveAllPropertyValues ()=0
 Removes all values from the property's collection of values.
 
virtual std::shared_ptr< ISgfcPropertyValueGetPropertyValue () const =0
 Returns the property's first value if the property has any values. Returns nullptr if the property has no values.
 
virtual const ISgfcGameTypePropertyToGameTypeProperty () const =0
 Returns an ISgfcGameTypeProperty object if GetPropertyType() returns SgfcPropertyType::GM. Returns nullptr otherwise. The caller is not the owner of the returned object.
 
virtual const ISgfcBoardSizePropertyToBoardSizeProperty () const =0
 Returns an ISgfcBoardSizeProperty object if GetPropertyType() returns SgfcPropertyType::SZ. Returns nullptr otherwise. The caller is not the owner of the returned object.
 

Detailed Description

The ISgfcProperty interface provides access to the data of a single property of an SGF node. One property has 0-n values.

Member Function Documentation

◆ AppendPropertyValue()

virtual void LibSgfcPlusPlus::ISgfcProperty::AppendPropertyValue ( std::shared_ptr< ISgfcPropertyValue > propertyValue)
pure virtual

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.

See also
SetPropertyValues()
Exceptions
std::invalid_argumentIs thrown if propertyValue is nullptr or if propertyValue is already in the property's collection of values.

Implemented in LibSgfcPlusPlus::SgfcProperty.

◆ GetPropertyCategory()

virtual SgfcPropertyCategory LibSgfcPlusPlus::ISgfcProperty::GetPropertyCategory ( ) const
pure virtual

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.

Implemented in LibSgfcPlusPlus::SgfcProperty.

◆ GetPropertyName()

virtual std::string LibSgfcPlusPlus::ISgfcProperty::GetPropertyName ( ) const
pure virtual

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).

Implemented in LibSgfcPlusPlus::SgfcProperty.

◆ GetPropertyType()

virtual SgfcPropertyType LibSgfcPlusPlus::ISgfcProperty::GetPropertyType ( ) const
pure virtual

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.

Implemented in LibSgfcPlusPlus::SgfcProperty.

◆ GetPropertyValue()

virtual std::shared_ptr< ISgfcPropertyValue > LibSgfcPlusPlus::ISgfcProperty::GetPropertyValue ( ) const
pure virtual

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.

Implemented in LibSgfcPlusPlus::SgfcProperty.

◆ GetPropertyValues()

virtual std::vector< std::shared_ptr< ISgfcPropertyValue > > LibSgfcPlusPlus::ISgfcProperty::GetPropertyValues ( ) const
pure virtual

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.

Implemented in LibSgfcPlusPlus::SgfcProperty.

◆ GetTraits()

virtual SgfcPropertyTraits LibSgfcPlusPlus::ISgfcProperty::GetTraits ( ) const
pure virtual

Returns the property's traits.

Returns SgfcConstants::PropertyTraitsNone if the property has no traits.

See also
SgfcPropertyTraits

Implemented in LibSgfcPlusPlus::SgfcProperty.

◆ HasPropertyValues()

virtual bool LibSgfcPlusPlus::ISgfcProperty::HasPropertyValues ( ) const
pure virtual

Returns true if the property has one or more values. Returns false if the property has no values.

Implemented in LibSgfcPlusPlus::SgfcProperty.

◆ HasTrait()

virtual bool LibSgfcPlusPlus::ISgfcProperty::HasTrait ( SgfcPropertyTrait trait) const
pure virtual

Returns true if the property has the trait trait. Returns false if the property does not have the trait trait.

See also
SgfcPropertyTrait

Implemented in LibSgfcPlusPlus::SgfcProperty.

◆ RemoveAllPropertyValues()

virtual void LibSgfcPlusPlus::ISgfcProperty::RemoveAllPropertyValues ( )
pure virtual

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.

See also
SetPropertyValues()

Implemented in LibSgfcPlusPlus::SgfcProperty.

◆ RemovePropertyValue()

virtual void LibSgfcPlusPlus::ISgfcProperty::RemovePropertyValue ( std::shared_ptr< ISgfcPropertyValue > propertyValue)
pure virtual

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.

See also
SetPropertyValues()
Exceptions
std::invalid_argumentIs thrown if propertyValue is not part of the property's collection of values.

Implemented in LibSgfcPlusPlus::SgfcProperty.

◆ SetPropertyValues()

virtual void LibSgfcPlusPlus::ISgfcProperty::SetPropertyValues ( const std::vector< std::shared_ptr< ISgfcPropertyValue > > & propertyValues)
pure virtual

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.

Exceptions
std::invalid_argumentIs thrown if propertyValues contains a nullptr element, or if propertyValues contains duplicate elements.

Implemented in LibSgfcPlusPlus::SgfcProperty.

◆ ToBoardSizeProperty()

virtual const ISgfcBoardSizeProperty * LibSgfcPlusPlus::ISgfcProperty::ToBoardSizeProperty ( ) const
pure virtual

Returns an ISgfcBoardSizeProperty object if GetPropertyType() returns SgfcPropertyType::SZ. Returns nullptr otherwise. The caller is not the owner of the returned object.

Implemented in LibSgfcPlusPlus::SgfcProperty, and LibSgfcPlusPlus::SgfcBoardSizeProperty.

◆ ToGameTypeProperty()

virtual const ISgfcGameTypeProperty * LibSgfcPlusPlus::ISgfcProperty::ToGameTypeProperty ( ) const
pure virtual

Returns an ISgfcGameTypeProperty object if GetPropertyType() returns SgfcPropertyType::GM. Returns nullptr otherwise. The caller is not the owner of the returned object.

Implemented in LibSgfcPlusPlus::SgfcProperty, and LibSgfcPlusPlus::SgfcGameTypeProperty.


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