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

Static Methods

bool

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

void

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

bool

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

void

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

void

destroy (uint32_t type, void * data)

void

destruct (uint32_t type, void * data)

bool

hasConverter (uint32_t from, uint32_t to)

const char

name (uint32_t type)

bool

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

uint32_t

registerType (MetaType::Table & table)

int

size (uint32_t type)

MetaType::Table *

table (uint32_t type)

uint32_t

type (const char * name)

uint32_t

type (const type_info & 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, uint32_t 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 (uint32_t 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, uint32_t fromType, void * to, uint32_t 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 (uint32_t 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 (uint32_t 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 (uint32_t 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 (uint32_t from, uint32_t 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 (uint32_t type)

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


bool MetaType::registerConverter (uint32_t from, uint32_t 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().


uint32_t MetaType::registerType (MetaType::Table & 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 (uint32_t type)

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


MetaType::Table * MetaType::table (uint32_t type)

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


uint32_t MetaType::type (char * name)

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


uint32_t MetaType::type (type_info & type)

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


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.