Base type : untyped variable. More...
#include <luapp_var.hpp>
Public Member Functions | |
var () | |
Default constructor. | |
template<class T > | |
var (const T &mValue) | |
Value assignment constructor. | |
var (const var &mVar) | |
Copy constructor. | |
var & | operator= (const var &mVar) |
bool | operator== (const var &mVar) const |
bool | operator!= (const var &mVar) |
void | swap (var &mVar) |
Swaps this value with another. | |
template<class T > | |
const T | get () const |
Returns the contained value. | |
bool | is_empty () const |
Checks if this variable is empty. | |
const var_type & | get_type () const |
Returns the type of the contained value. | |
template<class T > | |
bool | is_of_type () const |
Checks the contained value's type. | |
std::string | to_string () const |
Converts this variable to a string. | |
Static Public Attributes | |
static const var_type & | VALUE_NONE = typeid(void) |
static const var_type & | VALUE_INT = typeid(int) |
static const var_type & | VALUE_UINT = typeid(uint) |
static const var_type & | VALUE_FLOAT = typeid(float) |
static const var_type & | VALUE_DOUBLE = typeid(double) |
static const var_type & | VALUE_BOOL = typeid(bool) |
static const var_type & | VALUE_STRING = typeid(std::string) |
static const var_type & | VALUE_POINTER = typeid(void*) |
Private Attributes | |
utils::refptr< value_base > | pValue_ |
Base type : untyped variable.
The purpose of this class is to have an untyped return value / argument. It allows simple manipulation of events, and a lot of other things.
It uses a little bit more memory than a simple object :
sizeof(void*) + sizeof(T)
... and has the overhead of using the v-table (because of inheritance). At last, var does a dynamic_cast (which is not the fastest thing in the world) each time you call get().
So this class is definatly slower than base types : use it wisely.
Definition at line 25 of file luapp_var.hpp.
lua::var::var | ( | ) |
Default constructor.
Definition at line 15 of file luapp_var.cpp.
lua::var::var | ( | const T & | mValue | ) | [inline] |
Value assignment constructor.
mValue | The value to assign |
Definition at line 36 of file luapp_var.hpp.
lua::var::var | ( | const var & | mVar | ) |
const T lua::var::get | ( | ) | const [inline] |
Returns the contained value.
Definition at line 62 of file luapp_var.hpp.
const var_type & lua::var::get_type | ( | ) | const |
Returns the type of the contained value.
Definition at line 96 of file luapp_var.cpp.
bool lua::var::is_empty | ( | ) | const |
Checks if this variable is empty.
Definition at line 90 of file luapp_var.cpp.
bool lua::var::is_of_type | ( | ) | const [inline] |
Checks the contained value's type.
Definition at line 100 of file luapp_var.hpp.
bool lua::var::operator!= | ( | const var & | mVar | ) |
Definition at line 80 of file luapp_var.cpp.
Definition at line 23 of file luapp_var.cpp.
bool lua::var::operator== | ( | const var & | mVar | ) | const |
Definition at line 33 of file luapp_var.cpp.
void lua::var::swap | ( | var & | mVar | ) |
Swaps this value with another.
mVar | the value to swap with this one |
Definition at line 85 of file luapp_var.cpp.
std::string lua::var::to_string | ( | ) | const |
Converts this variable to a string.
Definition at line 108 of file luapp_var.cpp.
utils::refptr<value_base> lua::var::pValue_ [private] |
Definition at line 173 of file luapp_var.hpp.
const var_type & lua::var::VALUE_BOOL = typeid(bool) [static] |
Definition at line 122 of file luapp_var.hpp.
const var_type & lua::var::VALUE_DOUBLE = typeid(double) [static] |
Definition at line 121 of file luapp_var.hpp.
const var_type & lua::var::VALUE_FLOAT = typeid(float) [static] |
Definition at line 120 of file luapp_var.hpp.
const var_type & lua::var::VALUE_INT = typeid(int) [static] |
Definition at line 118 of file luapp_var.hpp.
const var_type & lua::var::VALUE_NONE = typeid(void) [static] |
Definition at line 117 of file luapp_var.hpp.
const var_type & lua::var::VALUE_POINTER = typeid(void*) [static] |
Definition at line 124 of file luapp_var.hpp.
const var_type & lua::var::VALUE_STRING = typeid(std::string) [static] |
Definition at line 123 of file luapp_var.hpp.
const var_type & lua::var::VALUE_UINT = typeid(uint) [static] |
Definition at line 119 of file luapp_var.hpp.