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 > | |
T | getValue () const |
Get the value of the property. More... | |
bool | hasValue () const |
Check if the property has a value or not. More... | |
Class that can store a value of any type.
Definition at line 36 of file Property.h.
|
explicit |
Constructor.
name | Name of the property |
The property will be created without a value
ime::Property::Property | ( | const std::string & | name, |
T && | value | ||
) |
Constructor.
name | Name of the property |
value | Value of the property |
The value can be of any type (Primitive or custom).
const std::string& ime::Property::getName | ( | ) | const |
Get the name of the property.
T ime::Property::getValue | ( | ) | const |
Get the value of the property.
std::bad_any_cast | if the stored value is not of type T |
bool ime::Property::hasValue | ( | ) | const |
Check if the property has a value or not.
void ime::Property::setValue | ( | T && | value | ) |
Set the value of the property.
value | New 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