MetaType

Inherited: None

Description

This class is designed for retrieving of runtime type information with additional functionality.

Some of registered types can be automatically converted to different types with MetaType::convert functunction. The following conversions are predefined:

TypeConvert to

MetaType::BOOLEANMetaType::INTEGER, MetaType::FLOAT, MetaType::STRING MetaType::INTEGERMetaType::BOOLEAN, MetaType::FLOAT, MetaType::STRING, MetaType::VECTOR2, MetaType::VECTOR3, MetaType::VECTOR4 MetaType::FLOATMetaType::BOOLEAN, MetaType::INTEGER, MetaType::STRING, MetaType::VECTOR2, MetaType::VECTOR3, MetaType::VECTOR4 MetaType::STRINGMetaType::BOOLEAN, MetaType::INTEGER, MetaType::FLOAT MetaType::VARIANTMAP MetaType::VARIANTLISTMetaType::VECTOR2, MetaType::VECTOR3, MetaType::VECTOR4, MetaType::MATRIX3, MetaType::MATRIX4, MetaType::QUATERNION MetaType::VECTOR2MetaType::VARIANTLIST, MetaType::VECTOR3, MetaType::VECTOR4 MetaType::VECTOR3MetaType::VARIANTLIST, MetaType::VECTOR4 MetaType::VECTOR4MetaType::VARIANTLIST MetaType::QUATERNIONMetaType::VARIANTLIST MetaType::MATRIX3MetaType::VARIANTLIST MetaType::MATRIX4MetaType::VARIANTLIST

To convert values to other types developer should define own conversion type function using MetaType::registerConverter() function

Public Methods

MetaType (const MetaType::Table * table)

bool

compare (const void * left, const void * right) const

void

construct (void * where, const void * copy = nullptr) const

void

create (const void * copy = nullptr) const

void

destroy (void * data) const

void

destruct (void * data) const

int

flags () const

bool

isValid () const

const char

name () const

int

size () const

Public Enums

enum MetaType::converterCallback

Callback which contain address to converter function. This converter must be able to convert from value with fromType type to to value with type represented by this MetaType.

Static Methods

bool

compare (const void * left, const void * right, int type)

void

construct (int type, void * where, const void * copy = nullptr)

bool

convert (const void * from, int fromType, void * to, int toType)

void

create (int type, const void * copy = nullptr)

void

destroy (int type, void * data)

void

destruct (int type, void * data)

bool

hasConverter (int from, int to)

const char

name (int type)

bool

registerConverter (int from, int to, MetaType::converterCallback function)

int

registerType (MetaType::Table & )

int

size (int type)

MetaType::Table *

table (int type)

int

type (const char * )

int

type (const type_info & )

template <typename T> int

type ()

MetaType::TypeMap

types ()

void

unregisterType (MetaType::Table & table)

Methods Description

MetaType::MetaType (MetaType::Table * table)

Constructs MetaType object which will contain information provided in a table.


bool MetaType::compare (void * left, void * right) const

Returns true in case of left value is equal to right value; otherwise returns false.


bool MetaType::compare (void * left, void * right, int type)

Returns true in case of left value is equal to right value with type; otherwise returns false.


void MetaType::construct (void * where, void * copy = nullptr) const

Constructs a value of the given type, which represented by current MetaType object in the existing memory addressed by where, that is a copy of copy, and returns where. If copy is zero, the value is default constructed.


void MetaType::construct (int type, void * where, void * copy = nullptr)

Constructs a value of the given type in the existing memory addressed by where, that is a copy of copy, and returns where. If copy is zero, the value is default constructed.


bool MetaType::convert (void * from, int fromType, void * to, int toType)

Tries to convert value from with type from*Type *to type to*Type and place the result *to output value to. Returns true if conversion succeed; otherwise returns false.

See also hasConverter().


void MetaType::create (void * copy = nullptr) const

Returns a copy of copy value, with type, which represented by current MetaType object. If copy is null, creates a default constructed instance.


void MetaType::create (int type, void * copy = nullptr)

Returns a copy of copy value, with type. If copy is null, creates a default constructed instance.


void MetaType::destroy (void * data) const

Destroys the value with type, which represented by current MetaType object, located at data. This function calls delete operator.


void MetaType::destroy (int type, void * data)

Destroys the value with type, located at data. This function calls delete operator.


void MetaType::destruct (void * data) const

Destructs the value with type, which represented by current MetaType object, located at data. Unlike destroy(), this function only invokes the type’s destructor, it doesn’t invoke the delete operator.


void MetaType::destruct (int type, void * data)

Destructs the value with type, located at data. Unlike destroy(), this function only invokes the type’s destructor, it doesn’t invoke the delete operator.


int MetaType::flags () const

Returns flags for the type.


bool MetaType::hasConverter (int from, int to)

Returns true in case of type from can be converted to type to; otherwise returns false.


bool MetaType::isValid () const

Returns true in case of this MetaType object contain valid information; otherwise returns false.


const char MetaType::name () const

Returns the name of type.


const char MetaType::name (int type)

Returns a name of type with type ID. Returns nullptr for unregistered type.


bool MetaType::registerConverter (int from, int to, MetaType::converterCallback function)

Registers the possibility to convert value type from to type to with conversion function. Returns true in case of converter successfully registered; otherwise returns false.

See also hasConverter().


int MetaType::registerType (MetaType::Table & **)

Registers type by type MetaType::Table table. Use registerMetaType() instead this function. Returns an ID of registered type.


int MetaType::size () const

Returns the size of type.


int MetaType::size (int type)

Returns a size of type with type ID. Returns 0 for unregistered type.


:ref:`MetaType::Table<api_MetaType::Table>`* MetaType::table (int type)

Returns type information table if type registered; otherwise returns nullptr.


int MetaType::type (char * **)

Returns an ID of type with type name. Returns MetaType::INVALID for unregistered type.


int MetaType::type (type_info & **)

Returns an ID of type with type info. Returns MetaType::INVALID for unregistered type.


template <typename T> int MetaType::type ()

Returns the type ID for type T.


MetaType::TypeMap MetaType::types ()

Returns a table of registered types.


void MetaType::unregisterType (MetaType::Table & table)

Unregisters type by type MetaType::Table table. Use unregisterMetaType() instead this function.