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::SgfcProperty Class Reference

The SgfcProperty class provides an implementation of the ISgfcProperty interface. See the interface header file for documentation. More...

#include <SgfcProperty.h>

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

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< ISgfcPropertyValueGetPropertyValue () const override
 Returns the property's first value if the property has any values. Returns nullptr if the property has no values.
 
virtual const ISgfcGameTypePropertyToGameTypeProperty () 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 ISgfcBoardSizePropertyToBoardSizeProperty () 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.
 

Detailed Description

The SgfcProperty class provides an implementation of the ISgfcProperty interface. See the interface header file for documentation.

Constructor & Destructor Documentation

◆ SgfcProperty()

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.

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

Member Function Documentation

◆ AppendPropertyValue()

void LibSgfcPlusPlus::SgfcProperty::AppendPropertyValue ( std::shared_ptr< ISgfcPropertyValue > propertyValue)
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.

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

Implements LibSgfcPlusPlus::ISgfcProperty.

◆ GetPropertyCategory()

SgfcPropertyCategory LibSgfcPlusPlus::SgfcProperty::GetPropertyCategory ( ) const
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.

◆ GetPropertyName()

std::string LibSgfcPlusPlus::SgfcProperty::GetPropertyName ( ) const
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.

◆ GetPropertyType()

SgfcPropertyType LibSgfcPlusPlus::SgfcProperty::GetPropertyType ( ) const
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.

◆ GetPropertyValue()

std::shared_ptr< ISgfcPropertyValue > LibSgfcPlusPlus::SgfcProperty::GetPropertyValue ( ) const
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.

◆ GetPropertyValues()

std::vector< std::shared_ptr< ISgfcPropertyValue > > LibSgfcPlusPlus::SgfcProperty::GetPropertyValues ( ) const
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.

◆ GetTraits()

SgfcPropertyTraits LibSgfcPlusPlus::SgfcProperty::GetTraits ( ) const
overridevirtual

Returns the property's traits.

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

See also
SgfcPropertyTraits

Implements LibSgfcPlusPlus::ISgfcProperty.

◆ HasPropertyValues()

bool LibSgfcPlusPlus::SgfcProperty::HasPropertyValues ( ) const
overridevirtual

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

Implements LibSgfcPlusPlus::ISgfcProperty.

◆ HasTrait()

bool LibSgfcPlusPlus::SgfcProperty::HasTrait ( SgfcPropertyTrait trait) const
overridevirtual

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

See also
SgfcPropertyTrait

Implements LibSgfcPlusPlus::ISgfcProperty.

◆ RemoveAllPropertyValues()

void LibSgfcPlusPlus::SgfcProperty::RemoveAllPropertyValues ( )
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.

See also
SetPropertyValues()

Implements LibSgfcPlusPlus::ISgfcProperty.

◆ RemovePropertyValue()

void LibSgfcPlusPlus::SgfcProperty::RemovePropertyValue ( std::shared_ptr< ISgfcPropertyValue > propertyValue)
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.

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

Implements LibSgfcPlusPlus::ISgfcProperty.

◆ SetPropertyValues()

void LibSgfcPlusPlus::SgfcProperty::SetPropertyValues ( const std::vector< std::shared_ptr< ISgfcPropertyValue > > & propertyValues)
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.

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

Implements LibSgfcPlusPlus::ISgfcProperty.

◆ ToBoardSizeProperty()

const ISgfcBoardSizeProperty * LibSgfcPlusPlus::SgfcProperty::ToBoardSizeProperty ( ) const
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.

◆ ToGameTypeProperty()

const ISgfcGameTypeProperty * LibSgfcPlusPlus::SgfcProperty::ToGameTypeProperty ( ) const
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.


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