libRocket
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Types | Public Member Functions | List of all members
Rocket::Core::Variant Class Reference

#include <Variant.h>

Public Types

enum  Type {
  NONE = '-', BYTE = 'b', CHAR = 'c', FLOAT = 'f',
  INT = 'i', STRING = 's', WORD = 'w', VECTOR2 = '2',
  COLOURF = 'g', COLOURB = 'h', SCRIPTINTERFACE = 'p', VOIDPTR = '*'
}
 Type of data stored in the variant. More...
 

Public Member Functions

 Variant ()
 
 Variant (const Variant &)
 
template<typename T >
 Variant (const T &t)
 
 ~Variant ()
 
void Clear ()
 Clears the data structure stored by the variant. More...
 
Type GetType () const
 
void Set (const Variant &copy)
 
void Set (const byte value)
 
void Set (const char value)
 
void Set (const float value)
 
void Set (const int value)
 
void Set (const word value)
 
void Set (const char *value)
 
void Set (void *value)
 
void Set (const String &value)
 
void Set (const Vector2f &value)
 
void Set (const Colourf &value)
 
void Set (const Colourb &value)
 
void Set (ScriptInterface *value)
 
template<typename T >
T Get () const
 
template<typename T >
bool GetInto (T &value) const
 
Variant & operator= (const Variant &copy)
 

Detailed Description

Variant is a container that can store a selection of basic types. The variant will store the value in the native form corresponding to the version of Set that was called.

Get is templated to convert from the stored form to the requested form by using a TypeConverter.

Author
Lloyd Weehuizen

Member Enumeration Documentation

Type of data stored in the variant.

Enumerator
NONE 
BYTE 
CHAR 
FLOAT 
INT 
STRING 
WORD 
VECTOR2 
COLOURF 
COLOURB 
SCRIPTINTERFACE 
VOIDPTR 

Constructor & Destructor Documentation

Rocket::Core::Variant::Variant ( )
Rocket::Core::Variant::Variant ( const Variant &  )

Templatised constructors don't work for the copy constructor, so we have to define it explicitly.

template<typename T >
Rocket::Core::Variant::Variant ( const T &  t)

Constructs a variant with internal data.

Parameters
[in]tData of a supported type to set on the variant.
Rocket::Core::Variant::~Variant ( )

Member Function Documentation

void Rocket::Core::Variant::Clear ( )

Clears the data structure stored by the variant.

template<typename T >
T Rocket::Core::Variant::Get ( ) const

Templatised data accessor. TypeConverters will be used to attempt to convert from the internal representation to the requested representation.

Returns
Data in the requested type.
template<typename T >
bool Rocket::Core::Variant::GetInto ( T &  value) const

Templatised data accessor. TypeConverters will be used to attempt to convert from the internal representation to the requested representation.

Parameters
[out]valueData in the requested type.
Returns
True if the value was converted and returned, false if no data was stored in the variant.
Type Rocket::Core::Variant::GetType ( ) const

Gets the current internal representation type.

Returns
The type of data stored in the variant internally.
Variant& Rocket::Core::Variant::operator= ( const Variant &  copy)

Assigns another variant's internal data to this variant.

Parameters
[in]copyVariant to share data.
void Rocket::Core::Variant::Set ( const Variant &  copy)

Shares another variant's data with this variant.

Parameters
[in]copyVariant to share data.
void Rocket::Core::Variant::Set ( const byte  value)

Sets a byte value on this variant.

Parameters
[in]valueNew value to set.
void Rocket::Core::Variant::Set ( const char  value)

Sets a signed char value on this variant.

Parameters
[in]valueNew value to set.
void Rocket::Core::Variant::Set ( const float  value)

Sets a float value on this variant.

Parameters
[in]valueNew value to set.
void Rocket::Core::Variant::Set ( const int  value)

Sets a signed int value on this variant.

Parameters
[in]valueNew value to set.
void Rocket::Core::Variant::Set ( const word  value)

Sets a word value on this variant.

Parameters
[in]valueNew value to set.
void Rocket::Core::Variant::Set ( const char *  value)

Sets a constant C string value on this variant.

Parameters
[in]valueNew value to set.
void Rocket::Core::Variant::Set ( void *  value)

Sets a generic void* value on this variant.

Parameters
[in]valueNew value to set.
void Rocket::Core::Variant::Set ( const String &  value)

Sets an EMP string value on this variant.

Parameters
[in]valueNew value to set.
void Rocket::Core::Variant::Set ( const Vector2f &  value)

Sets a Vector2f value on this variant.

Parameters
[in]valueNew value to set.
void Rocket::Core::Variant::Set ( const Colourf &  value)

Sets a Colourf value on this variant.

Parameters
[in]valueNew value to set.
void Rocket::Core::Variant::Set ( const Colourb &  value)

Sets a Colourb value on this variant.

Parameters
[in]valueNew value to set.
void Rocket::Core::Variant::Set ( ScriptInterface *  value)

Sets a script object value on this variant.

Parameters
[in]valueNew value to set.

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