EnTT 3.14.0
Loading...
Searching...
No Matches
Public Member Functions | List of all members
entt::meta_any Class Reference

Opaque wrapper for values of any type. More...

#include <meta.hpp>

Public Member Functions

 meta_any ()=default
 
 meta_any (meta_ctx_arg_t, const meta_ctx &area)
 Context aware constructor.
 
template<typename Type , typename... Args>
 meta_any (std::in_place_type_t< Type >, Args &&...args)
 Constructs a wrapper by directly initializing the new object.
 
template<typename Type , typename... Args>
 meta_any (const meta_ctx &area, std::in_place_type_t< Type >, Args &&...args)
 Constructs a wrapper by directly initializing the new object.
 
template<typename Type , typename = std::enable_if_t<!std::is_same_v<std::decay_t<Type>, meta_any>>>
 meta_any (Type &&value)
 Constructs a wrapper from a given value.
 
template<typename Type , typename = std::enable_if_t<!std::is_same_v<std::decay_t<Type>, meta_any>>>
 meta_any (const meta_ctx &area, Type &&value)
 Constructs a wrapper from a given value.
 
 meta_any (const meta_ctx &area, const meta_any &other)
 Context aware copy constructor.
 
 meta_any (const meta_ctx &area, meta_any &&other)
 Context aware move constructor.
 
 meta_any (const meta_any &other)=default
 Copy constructor.
 
 meta_any (meta_any &&other) noexcept
 Move constructor.
 
 ~meta_any ()
 Frees the internal storage, whatever it means.
 
meta_anyoperator= (const meta_any &other)
 Copy assignment operator.
 
meta_anyoperator= (meta_any &&other) noexcept
 Move assignment operator.
 
template<typename Type , typename = std::enable_if_t<!std::is_same_v<std::decay_t<Type>, meta_any>>>
meta_anyoperator= (Type &&value)
 Value assignment operator.
 
meta_type type () const noexcept
 Returns the object type if any, type_id<void>() otherwise.
 
const voiddata () const noexcept
 Returns an opaque pointer to the contained instance.
 
voiddata () noexcept
 Returns an opaque pointer to the contained instance.
 
template<typename... Args>
meta_any invoke (id_type id, Args &&...args) const
 Invokes the underlying function, if possible.
 
template<typename... Args>
meta_any invoke (id_type id, Args &&...args)
 Invokes the underlying function, if possible.
 
template<typename Type >
bool set (id_type id, Type &&value)
 Sets the value of a given variable.
 
meta_any get (id_type id) const
 Gets the value of a given variable.
 
meta_any get (id_type id)
 Gets the value of a given variable.
 
template<typename Type >
const Type * try_cast () const
 Tries to cast an instance to a given type.
 
template<typename Type >
Type * try_cast ()
 Tries to cast an instance to a given type.
 
template<typename Type >
std::remove_const_t< Type > cast () const
 Tries to cast an instance to a given type.
 
template<typename Type >
std::remove_const_t< Type > cast ()
 Tries to cast an instance to a given type.
 
meta_any allow_cast (const meta_type &type) const
 Converts an object in such a way that a given cast becomes viable.
 
bool allow_cast (const meta_type &type)
 Converts an object in such a way that a given cast becomes viable.
 
template<typename Type >
meta_any allow_cast () const
 Converts an object in such a way that a given cast becomes viable.
 
template<typename Type >
bool allow_cast ()
 Converts an object in such a way that a given cast becomes viable.
 
template<typename Type , typename... Args>
void emplace (Args &&...args)
 Replaces the contained object by creating a new instance directly.
 
bool assign (const meta_any &other)
 Assigns a value to the contained object without replacing it.
 
bool assign (meta_any &&other)
 Assigns a value to the contained object without replacing it.
 
void reset ()
 Destroys contained object.
 
meta_sequence_container as_sequence_container () noexcept
 Returns a sequence container proxy.
 
meta_sequence_container as_sequence_container () const noexcept
 Returns a sequence container proxy.
 
meta_associative_container as_associative_container () noexcept
 Returns an associative container proxy.
 
meta_associative_container as_associative_container () const noexcept
 Returns an associative container proxy.
 
meta_any operator* () const noexcept
 Indirection operator for dereferencing opaque objects.
 
 operator bool () const noexcept
 Returns false if a wrapper is invalid, true otherwise.
 
bool operator== (const meta_any &other) const noexcept
 Checks if two wrappers differ in their content.
 
bool operator!= (const meta_any &other) const noexcept
 Checks if two wrappers differ in their content.
 
meta_any as_ref () noexcept
 Aliasing constructor.
 
meta_any as_ref () const noexcept
 Aliasing constructor.
 
meta_any_policy policy () const noexcept
 Returns the current mode of a meta any object.
 

Detailed Description

Opaque wrapper for values of any type.

Definition at line 179 of file meta.hpp.

Constructor & Destructor Documentation

◆ meta_any() [1/10]

entt::meta_any::meta_any ( )
default

Default constructor.

◆ meta_any() [2/10]

entt::meta_any::meta_any ( meta_ctx_arg_t ,
const meta_ctx & area )
inline

Context aware constructor.

Parameters
areaThe context from which to search for meta types.

Definition at line 235 of file meta.hpp.

◆ meta_any() [3/10]

template<typename Type , typename... Args>
entt::meta_any::meta_any ( std::in_place_type_t< Type > ,
Args &&... args )
inlineexplicit

Constructs a wrapper by directly initializing the new object.

Template Parameters
TypeType of object to use to initialize the wrapper.
ArgsTypes of arguments to use to construct the new instance.
Parameters
argsParameters to use to construct the instance.

Definition at line 245 of file meta.hpp.

◆ meta_any() [4/10]

template<typename Type , typename... Args>
entt::meta_any::meta_any ( const meta_ctx & area,
std::in_place_type_t< Type > ,
Args &&... args )
inlineexplicit

Constructs a wrapper by directly initializing the new object.

Template Parameters
TypeType of object to use to initialize the wrapper.
ArgsTypes of arguments to use to construct the new instance.
Parameters
areaThe context from which to search for meta types.
argsParameters to use to construct the instance.

Definition at line 256 of file meta.hpp.

◆ meta_any() [5/10]

template<typename Type , typename = std::enable_if_t<!std::is_same_v<std::decay_t<Type>, meta_any>>>
entt::meta_any::meta_any ( Type && value)
inline

Constructs a wrapper from a given value.

Template Parameters
TypeType of object to use to initialize the wrapper.
Parameters
valueAn instance of an object to use to initialize the wrapper.

Definition at line 268 of file meta.hpp.

◆ meta_any() [6/10]

template<typename Type , typename = std::enable_if_t<!std::is_same_v<std::decay_t<Type>, meta_any>>>
entt::meta_any::meta_any ( const meta_ctx & area,
Type && value )
inline

Constructs a wrapper from a given value.

Template Parameters
TypeType of object to use to initialize the wrapper.
Parameters
areaThe context from which to search for meta types.
valueAn instance of an object to use to initialize the wrapper.

Definition at line 278 of file meta.hpp.

◆ meta_any() [7/10]

entt::meta_any::meta_any ( const meta_ctx & area,
const meta_any & other )
inline

Context aware copy constructor.

Parameters
areaThe context from which to search for meta types.
otherThe instance to copy from.

Definition at line 286 of file meta.hpp.

◆ meta_any() [8/10]

entt::meta_any::meta_any ( const meta_ctx & area,
meta_any && other )
inline

Context aware move constructor.

Parameters
areaThe context from which to search for meta types.
otherThe instance to move from.

Definition at line 297 of file meta.hpp.

◆ meta_any() [9/10]

entt::meta_any::meta_any ( const meta_any & other)
default

Copy constructor.

Parameters
otherThe instance to copy from.

◆ meta_any() [10/10]

entt::meta_any::meta_any ( meta_any && other)
inlinenoexcept

Move constructor.

Parameters
otherThe instance to move from.

Definition at line 313 of file meta.hpp.

◆ ~meta_any()

entt::meta_any::~meta_any ( )
inline

Frees the internal storage, whatever it means.

Definition at line 320 of file meta.hpp.

Member Function Documentation

◆ allow_cast() [1/4]

template<typename Type >
bool entt::meta_any::allow_cast ( )
inline

Converts an object in such a way that a given cast becomes viable.

Template Parameters
TypeType to which the cast is requested.
Returns
True if there exists a viable conversion, false otherwise.

Definition at line 506 of file meta.hpp.

◆ allow_cast() [2/4]

template<typename Type >
meta_any entt::meta_any::allow_cast ( ) const
inline

Converts an object in such a way that a given cast becomes viable.

Template Parameters
TypeType to which the cast is requested.
Returns
A valid meta any object if there exists a viable conversion, an invalid one otherwise.

Definition at line 491 of file meta.hpp.

◆ allow_cast() [3/4]

bool entt::meta_any::allow_cast ( const meta_type & type)
inline

Converts an object in such a way that a given cast becomes viable.

Parameters
typeMeta type to which the cast is requested.
Returns
True if there exists a viable conversion, false otherwise.

Definition at line 472 of file meta.hpp.

◆ allow_cast() [4/4]

meta_any entt::meta_any::allow_cast ( const meta_type & type) const
inline

Converts an object in such a way that a given cast becomes viable.

Parameters
typeMeta type to which the cast is requested.
Returns
A valid meta any object if there exists a viable conversion, an invalid one otherwise.

Definition at line 1647 of file meta.hpp.

◆ as_associative_container() [1/2]

meta_associative_container entt::meta_any::as_associative_container ( ) const
inlinenoexcept

Returns an associative container proxy.

Returns
An associative container proxy for the underlying object.

Definition at line 562 of file meta.hpp.

◆ as_associative_container() [2/2]

meta_associative_container entt::meta_any::as_associative_container ( )
inlinenoexcept

Returns an associative container proxy.

Returns
An associative container proxy for the underlying object.

Definition at line 555 of file meta.hpp.

◆ as_ref() [1/2]

meta_any entt::meta_any::as_ref ( ) const
inlinenoexcept

Aliasing constructor.

Returns
A wrapper that shares a reference to an unmanaged object.

Definition at line 603 of file meta.hpp.

◆ as_ref() [2/2]

meta_any entt::meta_any::as_ref ( )
inlinenoexcept

Aliasing constructor.

Returns
A wrapper that shares a reference to an unmanaged object.

Definition at line 598 of file meta.hpp.

◆ as_sequence_container() [1/2]

meta_sequence_container entt::meta_any::as_sequence_container ( ) const
inlinenoexcept

Returns a sequence container proxy.

Returns
A sequence container proxy for the underlying object.

Definition at line 545 of file meta.hpp.

◆ as_sequence_container() [2/2]

meta_sequence_container entt::meta_any::as_sequence_container ( )
inlinenoexcept

Returns a sequence container proxy.

Returns
A sequence container proxy for the underlying object.

Definition at line 538 of file meta.hpp.

◆ assign() [1/2]

bool entt::meta_any::assign ( const meta_any & other)
inline

Assigns a value to the contained object without replacing it.

Parameters
otherThe value to assign to the contained object.
Returns
True in case of success, false otherwise.

Definition at line 1666 of file meta.hpp.

◆ assign() [2/2]

bool entt::meta_any::assign ( meta_any && other)
inline

Assigns a value to the contained object without replacing it.

Parameters
otherThe value to assign to the contained object.
Returns
True in case of success, false otherwise.

Definition at line 1671 of file meta.hpp.

◆ cast() [1/2]

template<typename Type >
std::remove_const_t< Type > entt::meta_any::cast ( )
inline

Tries to cast an instance to a given type.

Template Parameters
TypeType to which to cast the instance.
Returns
A reference to the contained instance.

Definition at line 452 of file meta.hpp.

◆ cast() [2/2]

template<typename Type >
std::remove_const_t< Type > entt::meta_any::cast ( ) const
inline

Tries to cast an instance to a given type.

Template Parameters
TypeType to which to cast the instance.
Returns
A reference to the contained instance.

Definition at line 444 of file meta.hpp.

◆ data() [1/2]

const void * entt::meta_any::data ( ) const
inlinenoexcept

Returns an opaque pointer to the contained instance.

Returns
An opaque pointer the contained instance, if any.

Definition at line 373 of file meta.hpp.

◆ data() [2/2]

void * entt::meta_any::data ( )
inlinenoexcept

Returns an opaque pointer to the contained instance.

Returns
An opaque pointer the contained instance, if any.

Definition at line 378 of file meta.hpp.

◆ emplace()

template<typename Type , typename... Args>
void entt::meta_any::emplace ( Args &&... args)
inline

Replaces the contained object by creating a new instance directly.

Template Parameters
TypeType of object to use to initialize the wrapper.
ArgsTypes of arguments to use to construct the new instance.
Parameters
argsParameters to use to construct the instance.

Definition at line 513 of file meta.hpp.

◆ get() [1/2]

meta_any entt::meta_any::get ( id_type id)
inline

Gets the value of a given variable.

Parameters
idUnique identifier.
Returns
A wrapper containing the value of the underlying variable.

Definition at line 1643 of file meta.hpp.

◆ get() [2/2]

meta_any entt::meta_any::get ( id_type id) const
inline

Gets the value of a given variable.

Parameters
idUnique identifier.
Returns
A wrapper containing the value of the underlying variable.

Definition at line 1639 of file meta.hpp.

◆ invoke() [1/2]

template<typename... Args>
meta_any entt::meta_any::invoke ( id_type id,
Args &&... args )

Invokes the underlying function, if possible.

Template Parameters
ArgsTypes of arguments to use to invoke the function.
Parameters
idUnique identifier.
argsParameters to use to invoke the function.
Returns
A wrapper containing the returned value, if any.

Definition at line 1630 of file meta.hpp.

◆ invoke() [2/2]

template<typename... Args>
meta_any entt::meta_any::invoke ( id_type id,
Args &&... args ) const

Invokes the underlying function, if possible.

Template Parameters
ArgsTypes of arguments to use to invoke the function.
Parameters
idUnique identifier.
argsParameters to use to invoke the function.
Returns
A wrapper containing the returned value, if any.

Definition at line 1625 of file meta.hpp.

◆ operator bool()

entt::meta_any::operator bool ( ) const
inlineexplicitnoexcept

Returns false if a wrapper is invalid, true otherwise.

Returns
False if the wrapper is invalid, true otherwise.

Definition at line 583 of file meta.hpp.

◆ operator!=()

bool entt::meta_any::operator!= ( const meta_any & other) const
inlinenoexcept

Checks if two wrappers differ in their content.

Parameters
otherWrapper with which to compare.
Returns
True if the two objects differ in their content, false otherwise.

Definition at line 593 of file meta.hpp.

◆ operator*()

meta_any entt::meta_any::operator* ( ) const
inlinenoexcept

Indirection operator for dereferencing opaque objects.

Returns
A wrapper that shares a reference to an unmanaged object if the wrapped element is dereferenceable, an invalid meta any otherwise.

Definition at line 573 of file meta.hpp.

◆ operator=() [1/3]

meta_any & entt::meta_any::operator= ( const meta_any & other)
inline

Copy assignment operator.

Parameters
otherThe instance to copy from.
Returns
This meta any object.

Definition at line 329 of file meta.hpp.

◆ operator=() [2/3]

meta_any & entt::meta_any::operator= ( meta_any && other)
inlinenoexcept

Move assignment operator.

Parameters
otherThe instance to move from.
Returns
This meta any object.

Definition at line 346 of file meta.hpp.

◆ operator=() [3/3]

template<typename Type , typename = std::enable_if_t<!std::is_same_v<std::decay_t<Type>, meta_any>>>
meta_any & entt::meta_any::operator= ( Type && value)
inline

Value assignment operator.

Template Parameters
TypeType of object to use to initialize the wrapper.
Parameters
valueAn instance of an object to use to initialize the wrapper.
Returns
This meta any object.

Definition at line 364 of file meta.hpp.

◆ operator==()

bool entt::meta_any::operator== ( const meta_any & other) const
inlinenoexcept

Checks if two wrappers differ in their content.

Parameters
otherWrapper with which to compare.
Returns
False if the two objects differ in their content, true otherwise.

Definition at line 588 of file meta.hpp.

◆ policy()

meta_any_policy entt::meta_any::policy ( ) const
inlinenoexcept

Returns the current mode of a meta any object.

Returns
The current mode of the meta any object.

Definition at line 611 of file meta.hpp.

◆ reset()

void entt::meta_any::reset ( )
inline

Destroys contained object.

Definition at line 527 of file meta.hpp.

◆ set()

template<typename Type >
bool entt::meta_any::set ( id_type id,
Type && value )

Sets the value of a given variable.

Template Parameters
TypeType of value to assign.
Parameters
idUnique identifier.
valueParameter to use to set the underlying variable.
Returns
True in case of success, false otherwise.

Definition at line 1635 of file meta.hpp.

◆ try_cast() [1/2]

template<typename Type >
Type * entt::meta_any::try_cast ( )
inline

Tries to cast an instance to a given type.

Template Parameters
TypeType to which to cast the instance.
Returns
A (possibly null) pointer to the contained instance.

Definition at line 429 of file meta.hpp.

◆ try_cast() [2/2]

template<typename Type >
const Type * entt::meta_any::try_cast ( ) const
inline

Tries to cast an instance to a given type.

Template Parameters
TypeType to which to cast the instance.
Returns
A (possibly null) pointer to the contained instance.

Definition at line 422 of file meta.hpp.

◆ type()

meta_type entt::meta_any::type ( ) const
inlinenoexcept

Returns the object type if any, type_id<void>() otherwise.

Returns
The object type if any, type_id<void>() otherwise.

Definition at line 1619 of file meta.hpp.


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