MIRA
Public Types | Public Member Functions | Public Attributes | List of all members
TypeMeta Class Reference

Meta Type information. More...

#include <serialization/MetaSerializer.h>

Inheritance diagram for TypeMeta:
Inheritance graph
[legend]

Public Types

enum  Type {
  TYPE_INVALID = 0, TYPE_VOID, TYPE_CLASS, TYPE_ATOMIC,
  TYPE_UINT8, TYPE_INT8, TYPE_UINT16, TYPE_INT16,
  TYPE_UINT32, TYPE_INT32, TYPE_UINT64, TYPE_INT64,
  TYPE_FLOAT, TYPE_DOUBLE, TYPE_BOOL, TYPE_STRING,
  TYPE_ENUMERATION, TYPE_VERSION, LAST_TYPE_FIELD
}
 The different types (ranging from fundamental types to user-defined class). More...
 
enum  TypeQualifier {
  NO_QUALIFIER =0, FIRST_TYPE_QUALIFIER = 0x20, TYPE_COLLECTION = FIRST_TYPE_QUALIFIER, TYPE_POINTER,
  TYPE_PROPERTY
}
 Additional qualifiers. More...
 

Public Member Functions

 TypeMeta (uint8 version=2)
 
template<typename Reflector >
void reflect (Reflector &r)
 
template<typename BinaryStream >
void reflect (ConcreteBinaryDeserializer< BinaryStream, 0 > &r)
 
template<typename BinaryStream >
void reflect (ConcreteBinarySerializer< BinaryStream, 0 > &r)
 
void addQualifier (TypeQualifier qualifier)
 Adds a type qualifier. More...
 
void setBaseAtomicType (Type type)
 Sets the datatype to one of the built-in atomic types (TYPE_INT,FLOAT, etc). More...
 
void setAtomicType (const std::string &typenam)
 Sets an atomic type with the specified typename. More...
 
template<typename T >
void setAtomicType ()
 Same as above, but typename is extracted from T. More...
 
void setClassType (const std::string &identifier)
 Sets the data type to TYPE_CLASS and sets the class identifier. More...
 
template<typename T >
void setType ()
 Sets the datatype. More...
 
Type getType () const
 Returns the type flag which is the first item in the vector. More...
 
bool hasQualifier () const
 Returns true, if the type meta contains qualifiers. More...
 
int qualifierCount () const
 Returns the number of qualifiers. More...
 
TypeQualifier getQualifier (int i=0) const
 Returns the i-th type qualifier, or NO_QUALIFIER if there is no such qualifier. More...
 
void removeQualifiers (int n)
 Removes the n last qualifiers. More...
 
const std::string & getIdentifier () const
 Returns the identifier of the user-defined atomic type or class type. More...
 
std::string getTypename () const
 Returns the typename. More...
 
std::string toString () const
 Converts the whole type information including qualifiers to a human-readable string. More...
 
int size () const
 Returns the number of items (the type item + qualifier items) More...
 
uint8 version () const
 Returns the metatype format version. More...
 

Public Attributes

elements
 STL member. More...
 

Detailed Description

Meta Type information.

This includes the datatype itself (int, float, ... string or user-defined class), in the case of a class, the class identifier, and optional qualifiers that specify if the type is a pointer, a collection, etc.

The TypeMeta is realized as vector of flags. The first item in the vector indicates the data type. This first type item can be followed by multiple qualifier items.

Member Enumeration Documentation

◆ Type

enum Type

The different types (ranging from fundamental types to user-defined class).

Only one such type flag is allowed per TypeMeta.

Enumerator
TYPE_INVALID 
TYPE_VOID 
TYPE_CLASS 
TYPE_ATOMIC 
TYPE_UINT8 
TYPE_INT8 
TYPE_UINT16 
TYPE_INT16 
TYPE_UINT32 
TYPE_INT32 
TYPE_UINT64 
TYPE_INT64 
TYPE_FLOAT 
TYPE_DOUBLE 
TYPE_BOOL 
TYPE_STRING 
TYPE_ENUMERATION 
TYPE_VERSION 
LAST_TYPE_FIELD 

◆ TypeQualifier

Additional qualifiers.

Enumerator
NO_QUALIFIER 
FIRST_TYPE_QUALIFIER 
TYPE_COLLECTION 
TYPE_POINTER 
TYPE_PROPERTY 

Constructor & Destructor Documentation

◆ TypeMeta()

TypeMeta ( uint8  version = 2)
inline

Member Function Documentation

◆ reflect() [1/3]

void reflect ( Reflector &  r)
inline

◆ reflect() [2/3]

void reflect ( ConcreteBinaryDeserializer< BinaryStream, 0 > &  r)
inline

◆ reflect() [3/3]

void reflect ( ConcreteBinarySerializer< BinaryStream, 0 > &  r)
inline

◆ addQualifier()

void addQualifier ( TypeQualifier  qualifier)
inline

Adds a type qualifier.

Note, that the data type must have been set already.

◆ setBaseAtomicType()

void setBaseAtomicType ( Type  type)
inline

Sets the datatype to one of the built-in atomic types (TYPE_INT,FLOAT, etc).

◆ setAtomicType() [1/2]

void setAtomicType ( const std::string &  typenam)

Sets an atomic type with the specified typename.

This can be a built-in atomic type like int, float, etc. or a user defined atomic type.

◆ setAtomicType() [2/2]

void setAtomicType ( )
inline

Same as above, but typename is extracted from T.

◆ setClassType()

void setClassType ( const std::string &  identifier)
inline

Sets the data type to TYPE_CLASS and sets the class identifier.

◆ setType()

void setType ( )
inline

Sets the datatype.

This automatically differentiates between atomic types and class types.

◆ getType()

Type getType ( ) const
inline

Returns the type flag which is the first item in the vector.

◆ hasQualifier()

bool hasQualifier ( ) const
inline

Returns true, if the type meta contains qualifiers.

◆ qualifierCount()

int qualifierCount ( ) const
inline

Returns the number of qualifiers.

◆ getQualifier()

TypeQualifier getQualifier ( int  i = 0) const
inline

Returns the i-th type qualifier, or NO_QUALIFIER if there is no such qualifier.

◆ removeQualifiers()

void removeQualifiers ( int  n)
inline

Removes the n last qualifiers.

If n is larger than the number of qualifiers, all qualifiers are removed.

◆ getIdentifier()

const std::string& getIdentifier ( ) const
inline

Returns the identifier of the user-defined atomic type or class type.

For built-in atomic types (int,float) this returns an empty string.

◆ getTypename()

std::string getTypename ( ) const

Returns the typename.

For user-defined atomic types and class types this is the previously set identifier. For built-in types this is the typename.

◆ toString()

std::string toString ( ) const

Converts the whole type information including qualifiers to a human-readable string.

◆ size()

int size ( ) const
inline

Returns the number of items (the type item + qualifier items)

◆ version()

uint8 version ( ) const
inline

Returns the metatype format version.

Member Data Documentation

◆ elements

T elements
inherited

STL member.


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