Public Member Functions | List of all members
ime::Property Class Reference

Class that can store a value of any type. More...

#include <Property.h>

Public Member Functions

 Property (const std::string &name)
 Constructor. More...
 
template<typename T >
 Property (const std::string &name, T &&value)
 Constructor. More...
 
const std::string & getName () const
 Get the name of the property. More...
 
template<typename T >
void setValue (T &&value)
 Set the value of the property. More...
 
template<typename T >
getValue () const
 Get the value of the property. More...
 
bool hasValue () const
 Check if the property has a value or not. More...
 

Detailed Description

Class that can store a value of any type.

Definition at line 36 of file Property.h.

Constructor & Destructor Documentation

◆ Property() [1/2]

ime::Property::Property ( const std::string &  name)
explicit

Constructor.

Parameters
nameName of the property

The property will be created without a value

See also
setValue

◆ Property() [2/2]

template<typename T >
ime::Property::Property ( const std::string &  name,
T &&  value 
)

Constructor.

Parameters
nameName of the property
valueValue of the property

The value can be of any type (Primitive or custom).

Warning
the type of T must be remembered in order to retrieve the value later
See also
getValue

Member Function Documentation

◆ getName()

const std::string& ime::Property::getName ( ) const

Get the name of the property.

Returns
Name of the property

◆ getValue()

template<typename T >
T ime::Property::getValue ( ) const

Get the value of the property.

Exceptions
std::bad_any_castif the stored value is not of type T
Returns
Value of the property
Warning
Don't call this function if the property does not have a value, otherwise it will throw an exception. In addition, always make sure that the template argument T matches the type of the stored value when calling this function

◆ hasValue()

bool ime::Property::hasValue ( ) const

Check if the property has a value or not.

Returns
True if the property contains a value or false if it does not contain a value

◆ setValue()

template<typename T >
void ime::Property::setValue ( T &&  value)

Set the value of the property.

Parameters
valueNew value of the property

This function will overwrite the previous value. The new value need not be the same type as the previous value and it can be of any type (Primitive or custom). However, the type of T must be remembered in order to retrieve the value later

See also
getValue

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