EnTT 4.0.0
Loading...
Searching...
No Matches
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>
 meta_any (stl::in_place_type_t< Type >, auto &&...args)
 Constructs a wrapper by directly initializing the new object.
template<typename Type>
 meta_any (const meta_ctx &area, stl::in_place_type_t< Type >, auto &&...args)
 Constructs a wrapper by directly initializing the new object.
 meta_any (stl::in_place_t, auto *value)
 Constructs a wrapper taking ownership of the passed object.
 meta_any (const meta_ctx &area, stl::in_place_t, auto *value)
 Constructs a wrapper taking ownership of the passed object.
 meta_any (auto &&value)
 Constructs a wrapper from a given value.
 meta_any (const meta_ctx &area, auto &&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)
 Copy constructor.
 meta_any (meta_any &&other) noexcept
 Move constructor.
 ~meta_any ()=default
 Default destructor.
meta_anyoperator= (const meta_any &other)
 Copy assignment operator.
meta_anyoperator= (meta_any &&other) noexcept
 Move assignment operator.
meta_anyoperator= (auto &&value)
 Value assignment operator.
meta_type type () const noexcept
 Returns the meta type associated with the contained instance.
void type (const meta_type &alias) noexcept
 Sets a meta type for the contained instance.
meta_any invoke (id_type id, auto &&...args) const
 Invokes the underlying function, if possible.
meta_any invoke (id_type id, auto &&...args)
 Invokes the underlying function, if possible.
bool set (id_type id, auto &&...args)
 Sets the value of a given variable.
meta_any get (id_type id, auto &&...args) const
 Gets the value of a given variable.
meta_any get (id_type id, auto &&...args)
 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>
stl::remove_const_t< Type > cast () const
 Tries to cast an instance to a given type.
template<typename Type>
stl::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>
void emplace (auto &&...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* () noexcept
 Indirection operator for dereferencing opaque objects.
meta_any operator* () const noexcept
 Indirection operator for dereferencing opaque objects.
 operator bool () const noexcept
 Returns false if a wrapper is empty, true otherwise.
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.
const anybase () const noexcept
 Returns the underlying storage.
const meta_ctxcontext () const noexcept
 Returns the underlying meta context.

Detailed Description

Opaque wrapper for values of any type.

Definition at line 176 of file meta.hpp.

Constructor & Destructor Documentation

◆ meta_any() [1/12]

entt::meta_any::meta_any ( )
default

Default constructor.

◆ meta_any() [2/12]

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 241 of file meta.hpp.

◆ meta_any() [3/12]

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

Constructs a wrapper by directly initializing the new object.

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

Definition at line 250 of file meta.hpp.

◆ meta_any() [4/12]

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

Constructs a wrapper by directly initializing the new object.

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

Definition at line 260 of file meta.hpp.

◆ meta_any() [5/12]

entt::meta_any::meta_any ( stl::in_place_t ,
auto * value )
inlineexplicit

Constructs a wrapper taking ownership of the passed object.

Parameters
valueA pointer to an object to take ownership of.

Definition at line 269 of file meta.hpp.

◆ meta_any() [6/12]

entt::meta_any::meta_any ( const meta_ctx & area,
stl::in_place_t ,
auto * value )
inlineexplicit

Constructs a wrapper taking ownership of the passed object.

Parameters
areaThe context from which to search for meta types.
valueA pointer to an object to take ownership of.

Definition at line 277 of file meta.hpp.

◆ meta_any() [7/12]

entt::meta_any::meta_any ( auto && value)
inline

Constructs a wrapper from a given value.

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

Definition at line 287 of file meta.hpp.

◆ meta_any() [8/12]

entt::meta_any::meta_any ( const meta_ctx & area,
auto && value )
inline

Constructs a wrapper from a given value.

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

Definition at line 296 of file meta.hpp.

◆ meta_any() [9/12]

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 305 of file meta.hpp.

◆ meta_any() [10/12]

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 316 of file meta.hpp.

◆ meta_any() [11/12]

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

Copy constructor.

Parameters
otherThe instance to copy from.

Definition at line 326 of file meta.hpp.

◆ meta_any() [12/12]

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

Move constructor.

Parameters
otherThe instance to move from.

Definition at line 337 of file meta.hpp.

Member Function Documentation

◆ allow_cast() [1/4]

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

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 convertible, false otherwise.

Definition at line 522 of file meta.hpp.

◆ allow_cast() [2/4]

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

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 object if convertible, an invalid one otherwise.

Definition at line 486 of file meta.hpp.

◆ allow_cast() [3/4]

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

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 convertible, false otherwise.

Definition at line 1521 of file meta.hpp.

◆ allow_cast() [4/4]

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

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 object if convertible, an invalid one otherwise.

Definition at line 1492 of file meta.hpp.

◆ as_associative_container() [1/2]

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

Returns an associative container proxy.

Returns
An associative container proxy for the underlying object.

Definition at line 589 of file meta.hpp.

◆ as_associative_container() [2/2]

meta_associative_container entt::meta_any::as_associative_container ( )
inlinenodiscardnoexcept

Returns an associative container proxy.

Returns
An associative container proxy for the underlying object.

Definition at line 582 of file meta.hpp.

◆ as_ref() [1/2]

meta_any entt::meta_any::as_ref ( ) const
inlinenodiscardnoexcept

Aliasing constructor.

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

Definition at line 629 of file meta.hpp.

◆ as_ref() [2/2]

meta_any entt::meta_any::as_ref ( )
inlinenodiscardnoexcept

Aliasing constructor.

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

Definition at line 624 of file meta.hpp.

◆ as_sequence_container() [1/2]

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

Returns a sequence container proxy.

Returns
A sequence container proxy for the underlying object.

Definition at line 572 of file meta.hpp.

◆ as_sequence_container() [2/2]

meta_sequence_container entt::meta_any::as_sequence_container ( )
inlinenodiscardnoexcept

Returns a sequence container proxy.

Returns
A sequence container proxy for the underlying object.

Definition at line 565 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 1535 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 1544 of file meta.hpp.

◆ base()

const any & entt::meta_any::base ( ) const
inlinenodiscardnoexcept

Returns the underlying storage.

Returns
The underlyig storage.

Definition at line 637 of file meta.hpp.

◆ cast() [1/2]

template<typename Type>
stl::remove_const_t< Type > entt::meta_any::cast ( )
inlinenodiscard

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 459 of file meta.hpp.

◆ cast() [2/2]

template<typename Type>
stl::remove_const_t< Type > entt::meta_any::cast ( ) const
inlinenodiscard

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 451 of file meta.hpp.

◆ context()

const meta_ctx & entt::meta_any::context ( ) const
inlinenodiscardnoexcept

Returns the underlying meta context.

Returns
The underlying meta context.

Definition at line 645 of file meta.hpp.

◆ emplace()

template<typename Type>
void entt::meta_any::emplace ( auto &&... 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 542 of file meta.hpp.

◆ get() [1/2]

meta_any entt::meta_any::get ( id_type id,
auto &&... args )
inlinenodiscard

Gets the value of a given variable.

Parameters
idUnique identifier.
argsParameters to use to set the underlying variable, if any.
Returns
A wrapper containing the value of the underlying variable.

Definition at line 1488 of file meta.hpp.

◆ get() [2/2]

meta_any entt::meta_any::get ( id_type id,
auto &&... args ) const
inlinenodiscard

Gets the value of a given variable.

Parameters
idUnique identifier.
argsParameters to use to set the underlying variable, if any.
Returns
A wrapper containing the value of the underlying variable.

Definition at line 1484 of file meta.hpp.

◆ invoke() [1/2]

meta_any entt::meta_any::invoke ( id_type id,
auto &&... args )

Invokes the underlying function, if possible.

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

Definition at line 1476 of file meta.hpp.

◆ invoke() [2/2]

meta_any entt::meta_any::invoke ( id_type id,
auto &&... args ) const

Invokes the underlying function, if possible.

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

Definition at line 1472 of file meta.hpp.

◆ operator bool()

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

Returns false if a wrapper is empty, true otherwise.

Returns
False if the wrapper is empty, true otherwise.

Definition at line 614 of file meta.hpp.

◆ operator*() [1/2]

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

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 607 of file meta.hpp.

◆ operator*() [2/2]

meta_any entt::meta_any::operator* ( )
inlinenodiscardnoexcept

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 600 of file meta.hpp.

◆ operator=() [1/3]

meta_any & entt::meta_any::operator= ( auto && value)
inline

Value assignment operator.

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

Definition at line 380 of file meta.hpp.

◆ operator=() [2/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 351 of file meta.hpp.

◆ operator=() [3/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 367 of file meta.hpp.

◆ operator==()

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

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 619 of file meta.hpp.

◆ reset()

void entt::meta_any::reset ( )
inline

Destroys contained object.

Definition at line 555 of file meta.hpp.

◆ set()

bool entt::meta_any::set ( id_type id,
auto &&... args )

Sets the value of a given variable.

Parameters
idUnique identifier.
argsParameters to use to set the underlying variable.
Returns
True in case of success, false otherwise.

Definition at line 1480 of file meta.hpp.

◆ try_cast() [1/2]

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

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 441 of file meta.hpp.

◆ try_cast() [2/2]

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

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 434 of file meta.hpp.

◆ type() [1/2]

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

Returns the meta type associated with the contained instance.

Returns
The meta type associated with the contained instance.

Definition at line 1461 of file meta.hpp.

◆ type() [2/2]

void entt::meta_any::type ( const meta_type & alias)
inlinenoexcept

Sets a meta type for the contained instance.

Parameters
aliasThe meta to use with the contained instance.

Definition at line 1465 of file meta.hpp.


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