Elm  2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
Type Class Reference

#include <elm/rtti/Type.h>

+ Inheritance diagram for Type:

Public Types

typedef HashMap< string, const Type * >::Iter TypeIter
 

Public Member Functions

 Type (string name="")
 
virtual ~Type (void)
 
string name (void) const
 
const PointerTypepointer (void) const
 
virtual bool canCast (const Type *t) const
 
virtual bool isVoid (void) const
 
virtual bool isBool (void) const
 
virtual bool isInt (void) const
 
virtual bool isFloat (void) const
 
virtual bool isPtr (void) const
 
virtual const PointerTypeasPtr (void) const
 
virtual bool isClass (void) const
 
virtual const AbstractClassasClass (void) const
 
virtual bool isEnum (void) const
 
virtual const EnumerableasEnum (void) const
 
virtual bool isSerial (void) const
 
virtual const SerializableasSerial (void) const
 
virtual const TemplateTypeasTemplate (void) const
 
virtual const InstanceTypeasInstance (void) const
 
virtual const ParamTypeasParam (void) const
 
void initialize (void)
 
bool operator== (const Type &t) const
 
bool operator!= (const Type &t) const
 

Static Public Member Functions

static const Typeget (string name)
 
static TypeIter types (void)
 

Static Public Attributes

static const Typeparam0
 
static const Typeparam1
 
static const Typeparam2
 
static const Typeparam3
 

Detailed Description

Materialize the concept of type. Used for serialization or with classes like variant.

Member Typedef Documentation

◆ TypeIter

typedef HashMap<string, const Type *>::Iter TypeIter

Constructor & Destructor Documentation

◆ Type()

Type ( string  name = "")

◆ ~Type()

~Type ( void  )
virtual

Member Function Documentation

◆ asClass()

const AbstractClass & asClass ( void  ) const
virtual

Get the class description corresponding to this type. If the type is not a class, an assertion failure is raised.

Returns
Corresponding class instance.

Reimplemented in AbstractClass.

References Type::name().

◆ asEnum()

const Enumerable & asEnum ( void  ) const
virtual

Get the enumeration description corresponding to this type. If the type is not enumerated, an assertion failure is raised.

Returns
Corresponding class instance.

Reimplemented in Enum.

References Type::name().

Referenced by TextSerializer::onEnum(), XOMElementSerializer::onEnum(), and XOMUnserializer::onEnum().

◆ asInstance()

const InstanceType * asInstance ( void  ) const
virtual

Get the template instance interface for this type. If this type is not a template instance, return null.

Returns
Instance interface or null.

Reimplemented in InstanceClass.

◆ asParam()

const ParamType * asParam ( void  ) const
virtual

Get the parameter interface for this type. Return null if the type is not a parameter.

Returns
Parameter interface or null.

Referenced by InstanceType::typeFor().

◆ asPtr()

const PointerType & asPtr ( void  ) const
virtual

Get the class description corresponding to this type. If the type is not a pointer, an assertion failure is raised.

Returns
Corresponding pointer instance.

Reimplemented in PointerType.

References Type::name().

Referenced by elm::rtti::operator<<().

◆ asSerial()

const Serializable & asSerial ( void  ) const
virtual

Return the serializable instance of this type.

Warning
Will raise assertion failure if the type is not serializable.
Returns
Serializable instance.

Reimplemented in CStringType, StringType, BoolType, FloatType< T >, IntType< T >, and AbstractClass.

References Type::name().

◆ asTemplate()

const TemplateType * asTemplate ( void  ) const
virtual

Get the template interface for this type. If the type is not a template, return a null pointer.

Returns
Template interface or null.

Reimplemented in TemplateClass.

◆ canCast()

bool canCast ( const Type t) const
virtual

Test if the type can be casted to the given type.

Parameters
tType to cast to.
Returns
True if the type can be casted to the given type, false else.

Reimplemented in BoolType, FloatType< T >, IntType< T >, and Enum.

◆ get()

const Type * get ( string  name)
static

Get a type by its name.

Parameters
nameName of looked type.
Returns
Found type or null.

References Type::name(), and elm::rtti::type_map.

◆ initialize()

void initialize ( void  )

For internal use only. Do not call it.

References Type::name(), and elm::rtti::type_map.

◆ isBool()

bool isBool ( void  ) const
virtual

Test if the type is a boolean.

Returns
True if the type is boolean, false else.

Reimplemented in BoolType.

Referenced by IntType< T >::canCast(), and FloatType< T >::canCast().

◆ isClass()

bool isClass ( void  ) const
virtual

Test if the type is a class. Default implementation return false.

Returns
True if the type is a class, false else.

Reimplemented in AbstractClass.

◆ isEnum()

bool isEnum ( void  ) const
virtual

Test if the type is enumerated. Default implementation return false.

Returns
True if the type is a class, false else.

Reimplemented in Enum.

◆ isFloat()

bool isFloat ( void  ) const
virtual

Test if the type is a floating-point real.

Returns
True if the type is boolean, false else.

Reimplemented in FloatType< T >.

Referenced by IntType< T >::canCast(), and FloatType< T >::canCast().

◆ isInt()

bool isInt ( void  ) const
virtual

Test if the type is a integer.

Returns
True if the type is boolean, false else.

Reimplemented in IntType< T >.

Referenced by Enum::canCast(), IntType< T >::canCast(), FloatType< T >::canCast(), and BoolType::canCast().

◆ isPtr()

bool isPtr ( void  ) const
virtual

Test if the type is a pointer.

Returns
True if the type is boolean, false else.

Reimplemented in PointerType.

Referenced by elm::rtti::operator<<().

◆ isSerial()

bool isSerial ( void  ) const
virtual

Test if the type is serializable. Default implementation return false.

Returns
True if the type is serializable, false else.

Reimplemented in CStringType, StringType, BoolType, FloatType< T >, IntType< T >, and AbstractClass.

◆ isVoid()

bool isVoid ( void  ) const
virtual

Test if the type is void. Default implementation returns false.

Returns
True if the type is void, false else.

Reimplemented in VoidType.

◆ name()

◆ operator!=()

bool operator!= ( const Type t) const
inline

References Type::operator==().

◆ operator==()

bool operator== ( const Type t) const
inline

Referenced by Type::operator!=().

◆ pointer()

const PointerType & pointer ( void  ) const

Obtain pointer type on the current type.

Returns
Corresponding pointer type.

Referenced by _type< T * >::_().

◆ types()

Type::TypeIter types ( void  )
static

Get the list of existing types.

Returns
Iterator on types.

References elm::rtti::type_map.

Member Data Documentation

◆ param0

const Type & param0
static

◆ param1

const Type & param1
static

◆ param2

const Type & param2
static

◆ param3

const Type & param3
static

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