EnTT: entt::meta_type Class Reference

EnTT 3.16.0

Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
entt::meta_type Class Reference

Opaque wrapper for types. More...

`#include <meta.hpp>`

## Public Types
using | size_type = typename internal::meta_type_node::size_type
| Unsigned integer type.

## Public Member Functions
| meta_type () noexcept=default
| Default constructor.
| meta_type (const meta_ctx &area, const internal::meta_type_node &curr) noexcept
| Context aware constructor for meta objects.
| meta_type (const meta_ctx &area, const internal::meta_base_node &curr) noexcept
| Context aware constructor for meta objects.
const type_info & | info () const noexcept
| Returns the type info object of the underlying type.
id_type | id () const noexcept
| Returns the identifier assigned to a type.
const char * | name () const noexcept
| Returns the name assigned to a type, if any.
size_type | size_of () const noexcept
| Returns the size of the underlying type if known.
bool | is_arithmetic () const noexcept
| Checks whether a type refers to an arithmetic type or not.
bool | is_integral () const noexcept
| Checks whether a type refers to an integral type or not.
bool | is_signed () const noexcept
| Checks whether a type refers to a signed type or not.
bool | is_array () const noexcept
| Checks whether a type refers to an array type or not.
bool | is_enum () const noexcept
| Checks whether a type refers to an enum or not.
bool | is_class () const noexcept
| Checks whether a type refers to a class or not.
bool | is_pointer () const noexcept
| Checks whether a type refers to a pointer or not.
meta_type | remove_pointer () const noexcept
| Provides the type for which the pointer is defined.
bool | is_pointer_like () const noexcept
| Checks whether a type is a pointer-like type or not.
bool | is_sequence_container () const noexcept
| Checks whether a type refers to a sequence container or not.
bool | is_associative_container () const noexcept
| Checks whether a type refers to an associative container or not.
bool | is_template_specialization () const noexcept
| Checks whether a type refers to a template specialization or not.
size_type | template_arity () const noexcept
| Returns the number of template arguments.
meta_type | template_type () const noexcept
| Returns a tag for the class template of the underlying type.
meta_type | template_arg (const size_type index) const noexcept
| Returns the type of the i-th template argument of a type.
bool | can_cast (const meta_type &other) const noexcept
| Checks if a type supports direct casting to another type.
bool | can_convert (const meta_type &other) const noexcept
| Checks whether a type supports conversion to another type.
meta_range< meta_type, typename decltype(internal::meta_type_descriptor::base)::const_iterator > | base () const noexcept
| Returns a range to visit registered top-level base meta types.
meta_range< meta_data, typename decltype(internal::meta_type_descriptor::data)::const_iterator > | data () const noexcept
| Returns a range to visit registered top-level meta data.
meta_data | data (const id_type id, const bool recursive=true) const
| Lookup utility for meta data (bases are also visited).
meta_range< meta_func, typename decltype(internal::meta_type_descriptor::func)::const_iterator > | func () const noexcept
| Returns a range to visit registered top-level functions.
meta_func | func (const id_type id, const bool recursive=true) const
| Lookup utility for meta functions (bases are also visited).
meta_any | construct (meta_any *const args, const size_type sz) const
| Creates an instance of the underlying type, if possible.
template<typename... Args>
meta_any | construct (Args &&...args) const
| Creates an instance of the underlying type, if possible.
meta_any | from_void (void *elem, bool transfer_ownership=false) const
| Wraps an opaque element of the underlying type.
meta_any | from_void (const void *elem) const
| Wraps an opaque element of the underlying type.
template<typename Instance = meta_handle>
meta_any | invoke (const id_type id, Instance &&instance, meta_any *const args, const size_type sz) const
| Invokes a function given an identifier, if possible.
template<typename Instance = meta_handle, typename... Args>
meta_any | invoke (const id_type id, Instance &&instance, Args &&...args) const
| Invokes a function given an identifier, if possible.
template<typename Instance = meta_handle, typename Type>
bool | set (const id_type id, Instance &&instance, Type &&value) const
| Sets the value of a given variable.
template<typename Instance = meta_handle>
meta_any | get (const id_type id, Instance &&instance) const
| Gets the value of a given variable.
template<typename Type>
Type | traits () const noexcept
| Returns all meta traits for a given meta object.
meta_custom | custom () const noexcept
| Returns user defined data for a given meta object.
| operator bool () const noexcept
| Returns true if an object is valid, false otherwise.
bool | operator== (const meta_type &other) const noexcept
| Checks if two objects refer to the same type.

## Detailed Description

Opaque wrapper for types.

Definition at line 1059 of file meta.hpp.

## Member Typedef Documentation

## ◆ size_type

using entt::meta_type::size_type = typename internal::meta_type_node::size_type

Unsigned integer type.

Definition at line 1119 of file meta.hpp.

## Constructor & Destructor Documentation

## ◆ meta_type() [1/2]

entt::meta_type::meta_type | ( | const meta_ctx & | area,
|  | const internal::meta_type_node & | curr )
| inlinenoexcept

Context aware constructor for meta objects.

Parameters

  area | The context from which to search for meta types.
  curr | The underlying node with which to construct the instance.

Definition at line 1129 of file meta.hpp.

## ◆ meta_type() [2/2]

entt::meta_type::meta_type | ( | const meta_ctx & | area,
|  | const internal::meta_base_node & | curr )
| inlinenoexcept

Context aware constructor for meta objects.

Parameters

  area | The context from which to search for meta types.
  curr | The underlying node with which to construct the instance.

Definition at line 1138 of file meta.hpp.

## Member Function Documentation

## ◆ base()

meta_range< meta_type, typename decltype(internal::meta_type_descriptor::base)::const_iterator > entt::meta_type::base | ( |  | ) | const
| inlinenodiscardnoexcept

Returns a range to visit registered top-level base meta types.

Returns
  An iterable range to visit registered top-level base meta types.

Definition at line 1333 of file meta.hpp.

## ◆ can_cast()

bool entt::meta_type::can_cast | ( | const meta_type & | other | ) | const
| inlinenodiscardnoexcept

Checks if a type supports direct casting to another type.

Parameters

  other | The meta type to test for.

Returns
  True if direct casting is allowed, false otherwise.

Definition at line 1301 of file meta.hpp.

## ◆ can_convert()

bool entt::meta_type::can_convert | ( | const meta_type & | other | ) | const
| inlinenodiscardnoexcept

Checks whether a type supports conversion to another type.

Parameters

  other | The meta type to test for.

Returns
  True if the conversion is allowed, false otherwise.

Definition at line 1311 of file meta.hpp.

## ◆ construct() [1/2]

template<typename... Args>

meta_any entt::meta_type::construct | ( | Args &&... | args | ) | const
| inlinenodiscard

Creates an instance of the underlying type, if possible.

Template Parameters

  Args | Types of arguments to use to construct the instance.

Parameters

  args | Parameters to use to construct the instance.

Returns
  A wrapper containing the new instance, if any.

Definition at line 1405 of file meta.hpp.

## ◆ construct() [2/2]

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

Creates an instance of the underlying type, if possible.

Parameters

  args | Parameters to use to construct the instance.
  sz | Number of parameters to use to construct the instance.

Returns
  A wrapper containing the new instance, if any.

Definition at line 1384 of file meta.hpp.

## ◆ custom()

meta_custom entt::meta_type::custom | ( |  | ) | const
| inlinenodiscardnoexcept

Returns user defined data for a given meta object.

Returns
  User defined arbitrary data.

Definition at line 1511 of file meta.hpp.

## ◆ data() [1/2]

meta_range< meta_data, typename decltype(internal::meta_type_descriptor::data)::const_iterator > entt::meta_type::data | ( |  | ) | const
| inlinenodiscardnoexcept

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

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

Definition at line 1342 of file meta.hpp.

## ◆ data() [2/2]

meta_data entt::meta_type::data | ( | const id_type | id,
|  | const bool | recursive = true ) const
| inlinenodiscard

Lookup utility for meta data (bases are also visited).

Parameters

  id | Unique identifier.
  recursive | True for a search in the base classes, false otherwise.

Returns
  The registered meta data for the given identifier, if any.

Definition at line 1353 of file meta.hpp.

## ◆ from_void() [1/2]

meta_any entt::meta_type::from_void | ( | const void * | elem | ) | const
| inlinenodiscard

Wraps an opaque element of the underlying type.

Parameters

  elem | A valid pointer to an element of the underlying type.

Returns
  A wrapper that references the given instance.

Definition at line 1425 of file meta.hpp.

## ◆ from_void() [2/2]

meta_any entt::meta_type::from_void | ( | void * | elem,
|  | bool | transfer_ownership = false ) const
| inlinenodiscard

Wraps an opaque element of the underlying type.

Parameters

  elem | A valid pointer to an element of the underlying type.
  transfer_ownership | True to transfer ownership, false otherwise.

Returns
  A wrapper that references the given instance.

Definition at line 1416 of file meta.hpp.

## ◆ func() [1/2]

meta_range< meta_func, typename decltype(internal::meta_type_descriptor::func)::const_iterator > entt::meta_type::func | ( |  | ) | const
| inlinenodiscardnoexcept

Returns a range to visit registered top-level functions.

Returns
  An iterable range to visit registered top-level functions.

Definition at line 1362 of file meta.hpp.

## ◆ func() [2/2]

meta_func entt::meta_type::func | ( | const id_type | id,
|  | const bool | recursive = true ) const
| inlinenodiscard

Lookup utility for meta functions (bases are also visited).

Parameters

  id | Unique identifier.
  recursive | True for a search in the base classes, false otherwise.

Returns
  The registered meta function for the given identifier, if any.

Definition at line 1373 of file meta.hpp.

## ◆ get()

template<typename Instance = meta_handle>

meta_any entt::meta_type::get | ( | const id_type | id,
|  | Instance && | instance ) const
| inlinenodiscard

Gets the value of a given variable.

Template Parameters

  Instance | Type of instance to operate on.

Parameters

  id | Unique identifier.
  instance | An instance that fits the underlying type.

Returns
  A wrapper containing the value of the underlying variable.

Definition at line 1499 of file meta.hpp.

## ◆ id()

id_type entt::meta_type::id | ( |  | ) | const
| inlinenodiscardnoexcept

Returns the identifier assigned to a type.

Returns
  The identifier assigned to the type.

Definition at line 1153 of file meta.hpp.

## ◆ info()

const type_info & entt::meta_type::info | ( |  | ) | const
| inlinenodiscardnoexcept

Returns the type info object of the underlying type.

Returns
  The type info object of the underlying type.

Definition at line 1145 of file meta.hpp.

## ◆ invoke() [1/2]

template<typename Instance = meta_handle, typename... Args>

meta_any entt::meta_type::invoke | ( | const id_type | id,
|  | Instance && | instance,
|  | Args &&... | args ) const
| inline

Invokes a function given an identifier, if possible.

Parameters

  id | Unique identifier.

Template Parameters

  Instance | Type of instance to operate on.
  Args | Types of arguments to use to invoke the function.

Parameters

  instance | An instance that fits the underlying type.
  args | Parameters to use to invoke the function.

Returns
  A wrapper containing the returned value, if any.

Definition at line 1471 of file meta.hpp.

## ◆ invoke() [2/2]

template<typename Instance = meta_handle>

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

Invokes a function given an identifier, if possible.

Template Parameters

  Instance | Type of instance to operate on.

Parameters

  id | Unique identifier.
  instance | An instance that fits the underlying type.
  args | Parameters to use to invoke the function.
  sz | Number of parameters to use to invoke the function.

Returns
  A wrapper containing the returned value, if any.

Definition at line 1440 of file meta.hpp.

## ◆ is_arithmetic()

bool entt::meta_type::is_arithmetic | ( |  | ) | const
| inlinenodiscardnoexcept

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

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

Definition at line 1178 of file meta.hpp.

## ◆ is_array()

bool entt::meta_type::is_array | ( |  | ) | const
| inlinenodiscardnoexcept

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

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

Definition at line 1202 of file meta.hpp.

## ◆ is_associative_container()

bool entt::meta_type::is_associative_container | ( |  | ) | const
| inlinenodiscardnoexcept

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

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

Definition at line 1259 of file meta.hpp.

## ◆ is_class()

bool entt::meta_type::is_class | ( |  | ) | const
| inlinenodiscardnoexcept

Checks whether a type refers to a class or not.

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

Definition at line 1218 of file meta.hpp.

## ◆ is_enum()

bool entt::meta_type::is_enum | ( |  | ) | const
| inlinenodiscardnoexcept

Checks whether a type refers to an enum or not.

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

Definition at line 1210 of file meta.hpp.

## ◆ is_integral()

bool entt::meta_type::is_integral | ( |  | ) | const
| inlinenodiscardnoexcept

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

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

Definition at line 1186 of file meta.hpp.

## ◆ is_pointer()

bool entt::meta_type::is_pointer | ( |  | ) | const
| inlinenodiscardnoexcept

Checks whether a type refers to a pointer or not.

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

Definition at line 1226 of file meta.hpp.

## ◆ is_pointer_like()

bool entt::meta_type::is_pointer_like | ( |  | ) | const
| inlinenodiscardnoexcept

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

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

Definition at line 1243 of file meta.hpp.

## ◆ is_sequence_container()

bool entt::meta_type::is_sequence_container | ( |  | ) | const
| inlinenodiscardnoexcept

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

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

Definition at line 1251 of file meta.hpp.

## ◆ is_signed()

bool entt::meta_type::is_signed | ( |  | ) | const
| inlinenodiscardnoexcept

Checks whether a type refers to a signed type or not.

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

Definition at line 1194 of file meta.hpp.

## ◆ is_template_specialization()

bool entt::meta_type::is_template_specialization | ( |  | ) | const
| inlinenodiscardnoexcept

Checks whether a type refers to a template specialization or not.

Returns
  True if the type is a template specialization, false otherwise.

Definition at line 1267 of file meta.hpp.

## ◆ name()

const char * entt::meta_type::name | ( |  | ) | const
| inlinenodiscardnoexcept

Returns the name assigned to a type, if any.

Returns
  The name assigned to the type, if any.

Definition at line 1161 of file meta.hpp.

## ◆ operator bool()

entt::meta_type::operator bool | ( |  | ) | const
| inlineexplicitnodiscardnoexcept

Returns true if an object is valid, false otherwise.

Returns
  True if the object is valid, false otherwise.

Definition at line 1516 of file meta.hpp.

## ◆ operator==()

bool entt::meta_type::operator== | ( | const meta_type & | other | ) | const
| inlinenodiscardnoexcept

Checks if two objects refer to the same type.

Parameters

  other | The object with which to compare.

Returns
  True if the objects refer to the same type, false otherwise.

Definition at line 1521 of file meta.hpp.

## ◆ remove_pointer()

meta_type entt::meta_type::remove_pointer | ( |  | ) | const
| inlinenodiscardnoexcept

Provides the type for which the pointer is defined.

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

Definition at line 1235 of file meta.hpp.

## ◆ set()

template<typename Instance = meta_handle, typename Type>

bool entt::meta_type::set | ( | const id_type | id,
|  | Instance && | instance,
|  | Type && | value ) const
| inline

Sets the value of a given variable.

Template Parameters

  Instance | Type of instance to operate on.
  Type | Type of value to assign.

Parameters

  id | Unique identifier.
  instance | An instance that fits the underlying type.
  value | Parameter to use to set the underlying variable.

Returns
  True in case of success, false otherwise.

Definition at line 1486 of file meta.hpp.

## ◆ size_of()

size_type entt::meta_type::size_of | ( |  | ) | const
| inlinenodiscardnoexcept

Returns the size of the underlying type if known.

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

Definition at line 1169 of file meta.hpp.

## ◆ template_arg()

meta_type entt::meta_type::template_arg | ( | const size_type | index | ) | const
| inlinenodiscardnoexcept

Returns the type of the i-th template argument of a type.

Parameters

  index | Index of the template argument of which to return the type.

Returns
  The type of the i-th template argument of a type.

Definition at line 1292 of file meta.hpp.

## ◆ template_arity()

size_type entt::meta_type::template_arity | ( |  | ) | const
| inlinenodiscardnoexcept

Returns the number of template arguments.

Returns
  The number of template arguments.

Definition at line 1275 of file meta.hpp.

## ◆ template_type()

meta_type entt::meta_type::template_type | ( |  | ) | const
| inlinenodiscardnoexcept

Returns a tag for the class template of the underlying type.

Returns
  The tag for the class template of the underlying type.

Definition at line 1283 of file meta.hpp.

## ◆ traits()

template<typename Type>

Type entt::meta_type::traits | ( |  | ) | const
| inlinenodiscardnoexcept

Returns all meta traits for a given meta object.

Template Parameters

  Type | The type to convert the meta traits to.

Returns
  The registered meta traits, if any.

Definition at line 1506 of file meta.hpp.

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

- src/entt/meta/meta.hpp