EnTT 3.13.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 () noexcept
 
 meta_any (meta_ctx_arg_t, const meta_ctx &area) noexcept
 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 >
std::enable_if_t<!std::is_same_v< std::decay_t< Type >, meta_any >, meta_any & > operator= (Type &&value)
 Value assignment operator.
 
meta_type type () const noexcept
 Returns the object type if any, type_id<void>() otherwise.
 
const void * data () const noexcept
 Returns an opaque pointer to the contained instance.
 
void * data () noexcept
 Returns an opaque pointer to the contained instance.
 
template<typename... Args>
meta_any invoke (const id_type id, Args &&...args) const
 Invokes the underlying function, if possible.
 
template<typename... Args>
meta_any invoke (const id_type id, Args &&...args)
 Invokes the underlying function, if possible.
 
template<typename Type >
bool set (const id_type id, Type &&value)
 Sets the value of a given variable.
 
meta_any get (const id_type id) const
 Gets the value of a given variable.
 
meta_any get (const 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 >
Type cast () const
 Tries to cast an instance to a given type.
 
template<typename Type >
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.
 
bool owner () const noexcept
 Returns true if a wrapper owns its object, false otherwise.
 
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 181 of file meta.hpp.

Constructor & Destructor Documentation

◆ meta_any() [1/10]

entt::meta_any::meta_any ( )
inlinenoexcept

Default constructor.

Definition at line 231 of file meta.hpp.

◆ meta_any() [2/10]

entt::meta_any::meta_any ( meta_ctx_arg_t  ,
const meta_ctx area 
)
inlinenoexcept

Context aware constructor.

Parameters
areaThe context from which to search for meta types.

Definition at line 238 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 251 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 262 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 274 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 284 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 292 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 303 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 319 of file meta.hpp.

◆ ~meta_any()

entt::meta_any::~meta_any ( )
inline

Frees the internal storage, whatever it means.

Definition at line 326 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 508 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 493 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 474 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 1581 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 564 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 557 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 605 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 600 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 547 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 540 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 1600 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 1605 of file meta.hpp.

◆ cast() [1/2]

template<typename Type >
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 454 of file meta.hpp.

◆ cast() [2/2]

template<typename Type >
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 446 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 375 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 380 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 515 of file meta.hpp.

◆ get() [1/2]

meta_any entt::meta_any::get ( const 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 1577 of file meta.hpp.

◆ get() [2/2]

meta_any entt::meta_any::get ( const 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 1573 of file meta.hpp.

◆ invoke() [1/2]

template<typename... Args>
meta_any entt::meta_any::invoke ( const 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 1564 of file meta.hpp.

◆ invoke() [2/2]

template<typename... Args>
meta_any entt::meta_any::invoke ( const 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 1559 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 585 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 595 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 575 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 335 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 349 of file meta.hpp.

◆ operator=() [3/3]

template<typename Type >
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 366 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 590 of file meta.hpp.

◆ owner()

bool entt::meta_any::owner ( ) const
inlinenoexcept

Returns true if a wrapper owns its object, false otherwise.

Returns
True if the wrapper owns its object, false otherwise.

Definition at line 610 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 618 of file meta.hpp.

◆ reset()

void entt::meta_any::reset ( )
inline

Destroys contained object.

Definition at line 529 of file meta.hpp.

◆ set()

template<typename Type >
bool entt::meta_any::set ( const 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 1569 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 431 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 424 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 1554 of file meta.hpp.


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