A class that stores a variable of arbitrary type.
More...
#include <OGF/gom/types/any.h>
|
static std::string | meta_type_name (const MetaType *mt) |
|
A class that stores a variable of arbitrary type.
Definition at line 62 of file any.h.
◆ Any()
OGF::Any::Any |
( |
const Any & |
rhs | ) |
|
|
inline |
Any copy constructor.
- Parameters
-
[in] | rhs | the Any to be copied. |
Definition at line 106 of file any.h.
◆ as_string()
std::string OGF::Any::as_string |
( |
| ) |
const |
|
inline |
Gets a string representation.
- Returns
- a string representation of the stored argument
Definition at line 128 of file any.h.
◆ convert_from_string()
static void OGF::Any::convert_from_string |
( |
MetaType * |
meta_type, |
|
|
const std::string & |
string, |
|
|
Memory::pointer |
value |
|
) |
| |
|
static |
Converts a string into an object of a given type.
It does the same thing as ogf_convert_from_string(), namely it uses the Serializer registered in the Meta repository. We cannot use ogf_convert_from_string() since it would introduce a circular dependency in Meta, that uses ArgList.
- Parameters
-
[in] | meta_type | a pointer to the MetaType |
[in] | string | a const reference to the string |
[out] | value | a pointer to the converted value |
◆ convert_to_string()
Converts an object of a given type into a string.
It does the same thing as ogf_convert_to_string(), namely it uses the Serializer registered in the Meta repository. We cannot use ogf_convert_to_string() since it would introduce a circular dependency in Meta, that uses ArgList.
- Parameters
-
[in] | meta_type | a pointer to the MetaType |
[out] | string | the string representation of the object |
[in] | value | a pointer to the object |
◆ copy()
void OGF::Any::copy |
( |
const Any & |
rhs | ) |
|
|
inlineprotected |
Copies another Any.
- Parameters
-
[in] | rhs | the Any to be copied. |
Definition at line 618 of file any.h.
◆ copy_convert_to()
Tentatively converts the value stored in this Any to a type and if successful, store it at a specified address.
- Parameters
-
[out] | addr | a memory address where to store the value |
[in] | meta_type | the MetaType |
- Return values
-
true | on success |
false | if no conversion is available. |
◆ copy_from()
Assigns a value from a specifed address and specified type to this Any.
- Parameters
-
[in] | addr | a memory address |
[in] | meta_type | the MetaType |
Definition at line 452 of file any.h.
◆ copy_to()
Copies the value stored in this Any at a specified address.
- Parameters
-
[out] | addr | a memory address where to store the value |
[in] | meta_type | the MetaType |
- Return values
-
true | on success |
false | if type mistmatches stored type and no conversion is available. |
Definition at line 479 of file any.h.
◆ create()
void OGF::Any::create |
( |
MetaType * |
meta_type | ) |
|
|
inline |
Initializes this Any with the default value of a specified MetaType.
- Parameters
-
Definition at line 433 of file any.h.
◆ get_value() [1/7]
bool OGF::Any::get_value |
( |
double & |
value | ) |
const |
|
inline |
Gets the stored value (double overload).
- Parameters
-
[out] | value | the stored value. |
- Return values
-
true | if the specified type was correct. |
false | otherwise. |
Definition at line 354 of file any.h.
◆ get_value() [2/7]
bool OGF::Any::get_value |
( |
float & |
value | ) |
const |
|
inline |
Gets the stored value (float overload).
- Parameters
-
[out] | value | the stored value. |
- Return values
-
true | if the specified type was correct. |
false | otherwise. |
Definition at line 320 of file any.h.
◆ get_value() [3/7]
bool OGF::Any::get_value |
( |
index_t & |
value | ) |
const |
|
inline |
Gets the stored value (index_t overload).
- Parameters
-
[out] | value | the stored value. |
- Return values
-
true | if the specified type was correct. |
false | otherwise. |
Definition at line 248 of file any.h.
◆ get_value() [4/7]
Gets the stored value (signed_index_t overload).
- Parameters
-
[out] | value | the stored value. |
- Return values
-
true | if the specified type was correct. |
false | otherwise. |
Definition at line 284 of file any.h.
◆ get_value() [5/7]
bool OGF::Any::get_value |
( |
std::string & |
value | ) |
const |
|
inline |
Gets the stored value (std::string overload).
- Parameters
-
[out] | value | the stored value. |
- Return values
-
true | if the specified type was correct. |
false | otherwise. |
Definition at line 237 of file any.h.
◆ get_value() [6/7]
template<class T >
bool OGF::Any::get_value |
( |
T & |
value | ) |
const |
|
inline |
Gets the stored value.
- Parameters
-
[out] | value | the stored value. |
- Return values
-
true | if the specified type was correct. |
false | otherwise. |
Definition at line 210 of file any.h.
◆ get_value() [7/7]
template<class T >
bool OGF::Any::get_value |
( |
T *& |
value | ) |
const |
|
inline |
Gets the stored value (pointers overload).
More complicated than using the default function, this is because AnyStore is not a subtype of AnyStore if B is a subclass of A (inheritance does not play well with templates).
- Parameters
-
[out] | value | the stored value. |
- Return values
-
true | if the specified type was correct. |
false | otherwise. |
Definition at line 392 of file any.h.
◆ is_null()
bool OGF::Any::is_null |
( |
| ) |
const |
|
inline |
Tests whether this Any is null.
- Return values
-
true | if the Any does not store a value. |
false | otherwise. |
Definition at line 91 of file any.h.
◆ is_pointer_type()
static bool OGF::Any::is_pointer_type |
( |
const MetaType * |
mtype | ) |
|
|
static |
Tests whether a MetaType is a pointer type.
- Return values
-
true | if MetaType is a pointer type. |
false | otherwise. |
◆ life_cycle()
◆ meta_type()
Gets the MetaType of the stored value.
- Returns
- a pointer to the MetaType or nullptr if there is no stored value.
Definition at line 141 of file any.h.
◆ operator=()
Any& OGF::Any::operator= |
( |
const Any & |
rhs | ) |
|
|
inline |
Any affectation operator.
- Parameters
-
[in] | rhs | the Any to be copied. |
- Returns
- a reference to this Any after affectation.
Definition at line 116 of file any.h.
◆ pointed_type()
Gets the deferenced type.
- Parameters
-
- Returns
- the deferenced type.
◆ pointer_can_be_casted_to()
static bool OGF::Any::pointer_can_be_casted_to |
( |
const MetaType * |
derived_pointer_type, |
|
|
const MetaType * |
base_pointer_type |
|
) |
| |
|
static |
Tests whether a pointer type can be casted to an object type.
- Parameters
-
[in] | derived_pointer_type | the MetaType of the derived pointer type. |
[in] | base_pointer_type | the MetaType of the base pointer type. |
- Return values
-
true | if pointers of type derived_pointer_type can be casted to pointers of type base_pointer_type. |
false | otherwise. |
◆ resolve_meta_type()
template<class T >
static MetaType* OGF::Any::resolve_meta_type |
( |
| ) |
|
|
inlinestatic |
◆ resolve_meta_type_by_typeid_name()
static MetaType* OGF::Any::resolve_meta_type_by_typeid_name |
( |
const std::string & |
typeid_name | ) |
|
|
static |
◆ set_value() [1/2]
void OGF::Any::set_value |
( |
const char * |
value | ) |
|
|
inline |
Sets the value of this Any (overload for string literals).
Strings literals are stored internally as std::string.
- Parameters
-
[in] | value | the string to be stored. |
Definition at line 200 of file any.h.
◆ set_value() [2/2]
template<class T >
void OGF::Any::set_value |
( |
const T & |
value | ) |
|
|
inline |
Sets the value of this Any.
- Parameters
-
[in] | value | the value to be stored. |
Definition at line 155 of file any.h.
◆ value_as()
template<class T >
const T& OGF::Any::value_as |
( |
| ) |
const |
|
inlineprotected |
Gets the value as a specific type.
- Template Parameters
-
- Returns
- a reference to the stored value as type T.
This is a brute-force cast, check before that type matches.
Definition at line 593 of file any.h.
The documentation for this class was generated from the following file: