MIRA
Public Types | Public Member Functions | Friends | List of all members
PropertyHint Class Reference

A property hint gives optional instructions to the property editor, i.e. More...

#include <serialization/PropertyHint.h>

Public Types

typedef std::list< std::pair< std::string, std::string > > AttributeValueList
 

Public Member Functions

 PropertyHint ()
 
 PropertyHint (const std::string &attribute, const std::string &value)
 Constructs a single hint from the given attribute value pair. More...
 
 PropertyHint (PropertyHint &&other) noexcept
 move constructor More...
 
 ~PropertyHint ()
 
AttributeValueList toList () const
 Returns the attributes/value list containing the property hints. More...
 
void fromList (const AttributeValueList &list)
 Sets the property hints from the specified list of attribute/value pairs. More...
 
PropertyHintoperator= (PropertyHint &&other) noexcept
 move assignment operator More...
 
PropertyHint clone () const
 Creates an explicit copy as replacement for the copy constructor. More...
 
bool has (const std::string &attribute) const
 Returns true if the specified attribute exists. More...
 
template<typename T >
get (const std::string &attribute, const T &defaultValue=T()) const
 Returns the specified value for the given attribute. More...
 

Friends

PropertyHint operator| (PropertyHint &&hint, PropertyHint &&otherHint)
 Concatenates two hints. More...
 

Detailed Description

A property hint gives optional instructions to the property editor, i.e.

minimum and maximum value and which kind of editor to use. Each property hint may consist of a list of hints and attributes that are stored as Attribute-Value pairs.

Hints can be concatenated easily using the | operator, e.g.

PropertyHints::limits(1,10) | PropertyHint("MyHint", "MyValue") | PropertyHints::step(1)
Note
This class must be inline to avoid performance penalties in serializers that are performance critical and that do NOT take care of these property hints. For the same reason the attributes are stored using a pointer, to avoid unnecessary instantiation of containers if no property hint is specified. Using these optimizations, property hints do not pose any computational overhead.

Member Typedef Documentation

◆ AttributeValueList

typedef std::list<std::pair<std::string, std::string> > AttributeValueList

Constructor & Destructor Documentation

◆ PropertyHint() [1/3]

PropertyHint ( )
inline

◆ PropertyHint() [2/3]

PropertyHint ( const std::string &  attribute,
const std::string &  value 
)
inline

Constructs a single hint from the given attribute value pair.

◆ PropertyHint() [3/3]

PropertyHint ( PropertyHint &&  other)
inlinenoexcept

move constructor

◆ ~PropertyHint()

~PropertyHint ( )
inline

Member Function Documentation

◆ toList()

AttributeValueList toList ( ) const
inline

Returns the attributes/value list containing the property hints.

◆ fromList()

void fromList ( const AttributeValueList list)
inline

Sets the property hints from the specified list of attribute/value pairs.

◆ operator=()

PropertyHint& operator= ( PropertyHint &&  other)
inlinenoexcept

move assignment operator

◆ clone()

PropertyHint clone ( ) const
inline

Creates an explicit copy as replacement for the copy constructor.

The copy constructor was made private do avoid any performance penalties within the serialization framework whenever property hints are used.

◆ has()

bool has ( const std::string &  attribute) const
inline

Returns true if the specified attribute exists.

◆ get()

T get ( const std::string &  attribute,
const T &  defaultValue = T() 
) const
inline

Returns the specified value for the given attribute.

If no such attribute is set in this hint, then the defaultValue is returned.

Friends And Related Function Documentation

◆ operator|

PropertyHint operator| ( PropertyHint &&  hint,
PropertyHint &&  otherHint 
)
friend

Concatenates two hints.

NOTE: to increase performance this operator takes the content of the second hint and moves it into the first hint. Therefore, after calling this operator the second hint will be empty.


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