Clementine
Public Types | Public Member Functions | List of all members
entt::meta_type Class Reference

Opaque wrapper for meta types. More...

#include <entt.hpp>

Public Types

using node_type = internal::meta_type_node
 Node type.
 
using size_type = typename node_type::size_type
 Unsigned integer type.
 

Public Member Functions

 meta_type (node_type *curr=nullptr) ENTT_NOEXCEPT
 Constructs an instance from a given node. More...
 
type_info info () const ENTT_NOEXCEPT
 Returns the type info object of the underlying type. More...
 
id_type id () const ENTT_NOEXCEPT
 Returns the identifier assigned to a meta object. More...
 
size_type size_of () const ENTT_NOEXCEPT
 Returns the size of the underlying type if known. More...
 
bool is_void () const ENTT_NOEXCEPT
 Checks whether a type refers to void or not. More...
 
bool is_integral () const ENTT_NOEXCEPT
 Checks whether a type refers to an integral type or not. More...
 
bool is_floating_point () const ENTT_NOEXCEPT
 Checks whether a type refers to a floating-point type or not. More...
 
bool is_array () const ENTT_NOEXCEPT
 Checks whether a type refers to an array type or not. More...
 
bool is_enum () const ENTT_NOEXCEPT
 Checks whether a type refers to an enum or not. More...
 
bool is_union () const ENTT_NOEXCEPT
 Checks whether a type refers to an union or not. More...
 
bool is_class () const ENTT_NOEXCEPT
 Checks whether a type refers to a class or not. More...
 
bool is_pointer () const ENTT_NOEXCEPT
 Checks whether a type refers to a pointer or not. More...
 
bool is_function_pointer () const ENTT_NOEXCEPT
 Checks whether a type refers to a function pointer or not. More...
 
bool is_member_object_pointer () const ENTT_NOEXCEPT
 Checks whether a type refers to a pointer to data member or not. More...
 
bool is_member_function_pointer () const ENTT_NOEXCEPT
 Checks whether a type refers to a pointer to member function or not. More...
 
bool is_pointer_like () const ENTT_NOEXCEPT
 Checks whether a type is a pointer-like type or not. More...
 
bool is_sequence_container () const ENTT_NOEXCEPT
 Checks whether a type refers to a sequence container or not. More...
 
bool is_associative_container () const ENTT_NOEXCEPT
 Checks whether a type refers to an associative container or not. More...
 
size_type rank () const ENTT_NOEXCEPT
 If a type refers to an array type, provides the number of dimensions of the array. More...
 
size_type extent (size_type dim={}) const ENTT_NOEXCEPT
 If a type refers to an array type, provides the number of elements along the given dimension of the array. More...
 
meta_type remove_pointer () const ENTT_NOEXCEPT
 Provides the meta type for which the pointer is defined. More...
 
meta_type remove_extent () const ENTT_NOEXCEPT
 Provides the meta type for which the array is defined. More...
 
meta_range< meta_basebase () const ENTT_NOEXCEPT
 Returns a range to use to visit top-level meta bases. More...
 
meta_base base (const id_type id) const
 Returns the meta base associated with a given identifier. More...
 
meta_range< meta_convconv () const ENTT_NOEXCEPT
 Returns a range to use to visit top-level meta conversion functions. More...
 
template<typename Type >
meta_conv conv () const
 Returns the meta conversion function associated with a given type. More...
 
meta_range< meta_ctorctor () const ENTT_NOEXCEPT
 Returns a range to use to visit top-level meta constructors. More...
 
template<typename... Args>
meta_ctor ctor () const
 Returns the meta constructor that accepts a given list of types of arguments. More...
 
meta_range< meta_datadata () const ENTT_NOEXCEPT
 Returns a range to use to visit top-level meta data. More...
 
meta_data data (const id_type id) const
 Returns the meta data associated with a given identifier. More...
 
meta_range< meta_funcfunc () const ENTT_NOEXCEPT
 Returns a range to use to visit top-level meta functions. More...
 
meta_func func (const id_type id) const
 Returns the meta function associated with a given identifier. More...
 
meta_any construct (meta_any *const args, const size_type sz) const
 Creates an instance of the underlying type, if possible. More...
 
template<typename... Args>
meta_any construct (Args &&... args) const
 Creates an instance of the underlying type, if possible. More...
 
meta_any invoke (const id_type id, meta_handle instance, meta_any *const args, const size_type sz) const
 Invokes the function with the given identifier, if possible. More...
 
template<typename... Args>
meta_any invoke (const id_type id, meta_handle instance, Args &&... args) const
 Invokes the function with the given identifier, if possible. More...
 
template<typename Type >
bool set (const id_type id, meta_handle instance, Type &&value) const
 Sets the value of a given variable. More...
 
meta_any get (const id_type id, meta_handle instance) const
 Gets the value of a given variable. More...
 
meta_range< meta_propprop () const ENTT_NOEXCEPT
 Returns a range to use to visit top-level meta properties. More...
 
meta_prop prop (meta_any key) const
 Returns the property associated with a given key. More...
 
 operator bool () const ENTT_NOEXCEPT
 Returns true if a meta object is valid, false otherwise. More...
 
bool operator== (const meta_type &other) const ENTT_NOEXCEPT
 Checks if two meta objects refer to the same type. More...
 
void reset () ENTT_NOEXCEPT
 Resets a meta type and all its parts. More...
 

Detailed Description

Opaque wrapper for meta types.

Constructor & Destructor Documentation

◆ meta_type()

entt::meta_type::meta_type ( node_type curr = nullptr)
inline

Constructs an instance from a given node.

Parameters
currThe underlying node with which to construct the instance.

Member Function Documentation

◆ base() [1/2]

meta_range<meta_base> entt::meta_type::base ( ) const
inline

Returns a range to use to visit top-level meta bases.

Returns
An iterable range to use to visit top-level meta bases.

◆ base() [2/2]

meta_base entt::meta_type::base ( const id_type  id) const
inline

Returns the meta base associated with a given identifier.

Parameters
idUnique identifier.
Returns
The meta base associated with the given identifier, if any.

◆ construct() [1/2]

meta_any entt::meta_type::construct ( meta_any *const  args,
const size_type  sz 
) const
inline

Creates an instance of the underlying type, if possible.

To create a valid instance, the parameters must be such that a cast or conversion to the required types is possible. Otherwise, an empty and thus invalid wrapper is returned.

Parameters
argsParameters to use to construct the instance.
szNumber of parameters to use to construct the instance.
Returns
A meta any containing the new instance, if any.

◆ construct() [2/2]

template<typename... Args>
meta_any entt::meta_type::construct ( Args &&...  args) const
inline

Creates an instance of the underlying type, if possible.

See also
construct
Template Parameters
ArgsTypes of arguments to use to construct the instance.
Parameters
argsParameters to use to construct the instance.
Returns
A meta any containing the new instance, if any.

◆ conv() [1/2]

meta_range<meta_conv> entt::meta_type::conv ( ) const
inline

Returns a range to use to visit top-level meta conversion functions.

Returns
An iterable range to use to visit top-level meta conversion functions.

◆ conv() [2/2]

template<typename Type >
meta_conv entt::meta_type::conv ( ) const
inline

Returns the meta conversion function associated with a given type.

Template Parameters
TypeThe type to use to search for a meta conversion function.
Returns
The meta conversion function associated with the given type, if any.

◆ ctor() [1/2]

meta_range<meta_ctor> entt::meta_type::ctor ( ) const
inline

Returns a range to use to visit top-level meta constructors.

Returns
An iterable range to use to visit top-level meta constructors.

◆ ctor() [2/2]

template<typename... Args>
meta_ctor entt::meta_type::ctor ( ) const
inline

Returns the meta constructor that accepts a given list of types of arguments.

Returns
The requested meta constructor, if any.

◆ data() [1/2]

meta_range<meta_data> entt::meta_type::data ( ) const
inline

Returns a range to use to visit top-level meta data.

Returns
An iterable range to use to visit top-level meta data.

◆ data() [2/2]

meta_data entt::meta_type::data ( const id_type  id) const
inline

Returns the meta data associated with a given identifier.

The meta data of the base classes will also be visited, if any.

Parameters
idUnique identifier.
Returns
The meta data associated with the given identifier, if any.

◆ extent()

size_type entt::meta_type::extent ( size_type  dim = {}) const
inline

If a type refers to an array type, provides the number of elements along the given dimension of the array.

Parameters
dimThe dimension of which to return the number of elements.
Returns
The number of elements along the given dimension of the array if the underlying type is an array type, 0 otherwise.

◆ func() [1/2]

meta_range<meta_func> entt::meta_type::func ( ) const
inline

Returns a range to use to visit top-level meta functions.

Returns
An iterable range to use to visit top-level meta functions.

◆ func() [2/2]

meta_func entt::meta_type::func ( const id_type  id) const
inline

Returns the meta function associated with a given identifier.

The meta functions of the base classes will also be visited, if any.
In the case of overloaded meta functions, the first one with the required id will be returned.

Parameters
idUnique identifier.
Returns
The meta function associated with the given identifier, if any.

◆ get()

meta_any entt::meta_type::get ( const id_type  id,
meta_handle  instance 
) const
inline

Gets the value of a given variable.

It must be possible to cast the instance to the parent type of the meta data. Otherwise, invoking the getter results in an undefined behavior.

Parameters
idUnique identifier.
instanceAn opaque instance of the underlying type.
Returns
A meta any containing the value of the underlying variable.

◆ id()

id_type entt::meta_type::id ( ) const
inline

Returns the identifier assigned to a meta object.

Returns
The identifier assigned to the meta object.

◆ info()

type_info entt::meta_type::info ( ) const
inline

Returns the type info object of the underlying type.

Returns
The type info object of the underlying type.

◆ invoke() [1/2]

meta_any entt::meta_type::invoke ( const id_type  id,
meta_handle  instance,
meta_any *const  args,
const size_type  sz 
) const
inline

Invokes the function with the given identifier, if possible.

To invoke a meta function, the parameters must be such that a cast or conversion to the required types is possible. Otherwise, an empty and thus invalid wrapper is returned.
It must be possible to cast the instance to the parent type of the meta function. Otherwise, invoking the underlying function results in an undefined behavior.

Parameters
idUnique identifier.
instanceAn opaque instance of the underlying type.
argsParameters to use to invoke the function.
szNumber of parameters to use to invoke the function.
Returns
A meta any containing the returned value, if any.

◆ invoke() [2/2]

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

Invokes the function with the given identifier, if possible.

See also
invoke
Parameters
idUnique identifier.
Template Parameters
ArgsTypes of arguments to use to invoke the function.
Parameters
instanceAn opaque instance of the underlying type.
argsParameters to use to invoke the function.
Returns
A meta any containing the new instance, if any.

◆ is_array()

bool entt::meta_type::is_array ( ) const
inline

Checks whether a type refers to an array type or not.

Returns
True if the underlying type is an array type, false otherwise.

◆ is_associative_container()

bool entt::meta_type::is_associative_container ( ) const
inline

Checks whether a type refers to an associative container or not.

Returns
True if the underlying type is an associative container, false otherwise.

◆ is_class()

bool entt::meta_type::is_class ( ) const
inline

Checks whether a type refers to a class or not.

Returns
True if the underlying type is a class, false otherwise.

◆ is_enum()

bool entt::meta_type::is_enum ( ) const
inline

Checks whether a type refers to an enum or not.

Returns
True if the underlying type is an enum, false otherwise.

◆ is_floating_point()

bool entt::meta_type::is_floating_point ( ) const
inline

Checks whether a type refers to a floating-point type or not.

Returns
True if the underlying type is a floating-point type, false otherwise.

◆ is_function_pointer()

bool entt::meta_type::is_function_pointer ( ) const
inline

Checks whether a type refers to a function pointer or not.

Returns
True if the underlying type is a function pointer, false otherwise.

◆ is_integral()

bool entt::meta_type::is_integral ( ) const
inline

Checks whether a type refers to an integral type or not.

Returns
True if the underlying type is an integral type, false otherwise.

◆ is_member_function_pointer()

bool entt::meta_type::is_member_function_pointer ( ) const
inline

Checks whether a type refers to a pointer to member function or not.

Returns
True if the underlying type is a pointer to member function, false otherwise.

◆ is_member_object_pointer()

bool entt::meta_type::is_member_object_pointer ( ) const
inline

Checks whether a type refers to a pointer to data member or not.

Returns
True if the underlying type is a pointer to data member, false otherwise.

◆ is_pointer()

bool entt::meta_type::is_pointer ( ) const
inline

Checks whether a type refers to a pointer or not.

Returns
True if the underlying type is a pointer, false otherwise.

◆ is_pointer_like()

bool entt::meta_type::is_pointer_like ( ) const
inline

Checks whether a type is a pointer-like type or not.

Returns
True if the underlying type is a pointer-like one, false otherwise.

◆ is_sequence_container()

bool entt::meta_type::is_sequence_container ( ) const
inline

Checks whether a type refers to a sequence container or not.

Returns
True if the underlying type is a sequence container, false otherwise.

◆ is_union()

bool entt::meta_type::is_union ( ) const
inline

Checks whether a type refers to an union or not.

Returns
True if the underlying type is an union, false otherwise.

◆ is_void()

bool entt::meta_type::is_void ( ) const
inline

Checks whether a type refers to void or not.

Returns
True if the underlying type is void, false otherwise.

◆ operator bool()

entt::meta_type::operator bool ( ) const
inlineexplicit

Returns true if a meta object is valid, false otherwise.

Returns
True if the meta object is valid, false otherwise.

◆ operator==()

bool entt::meta_type::operator== ( const meta_type other) const
inline

Checks if two meta objects refer to the same type.

Parameters
otherThe meta object with which to compare.
Returns
True if the two meta objects refer to the same type, false otherwise.

◆ prop() [1/2]

meta_range<meta_prop> entt::meta_type::prop ( ) const
inline

Returns a range to use to visit top-level meta properties.

Returns
An iterable range to use to visit top-level meta properties.

◆ prop() [2/2]

meta_prop entt::meta_type::prop ( meta_any  key) const
inline

Returns the property associated with a given key.

Properties of the base classes will also be visited, if any.

Parameters
keyThe key to use to search for a property.
Returns
The property associated with the given key, if any.

◆ rank()

size_type entt::meta_type::rank ( ) const
inline

If a type refers to an array type, provides the number of dimensions of the array.

Returns
The number of dimensions of the array if the underlying type is an array type, 0 otherwise.

◆ remove_extent()

meta_type entt::meta_type::remove_extent ( ) const
inline

Provides the meta type for which the array is defined.

Returns
The meta type for which the array is defined or this meta type if it doesn't refer to an array type.

◆ remove_pointer()

meta_type entt::meta_type::remove_pointer ( ) const
inline

Provides the meta type for which the pointer is defined.

Returns
The meta type for which the pointer is defined or this meta type if it doesn't refer to a pointer type.

◆ reset()

void entt::meta_type::reset ( )
inline

Resets a meta type and all its parts.

This function resets a meta type and all its data members, member functions and properties, as well as its constructors, destructors and conversion functions if any.
Base classes aren't reset but the link between the two types is removed.

The meta type is also removed from the list of searchable types.

◆ set()

template<typename Type >
bool entt::meta_type::set ( const id_type  id,
meta_handle  instance,
Type &&  value 
) const
inline

Sets the value of a given variable.

It must be possible to cast the instance to the parent type of the meta data. Otherwise, invoking the setter results in an undefined behavior.
The type of the value must be such that a cast or conversion to the type of the variable is possible. Otherwise, invoking the setter does nothing.

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

◆ size_of()

size_type entt::meta_type::size_of ( ) const
inline

Returns the size of the underlying type if known.

Returns
The size of the underlying type if known, 0 otherwise.

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