# Frost::s_var Class Reference

Base type : untyped variable. More...

`#include <frost_utils_var.h>`

List of all members.

## Public Member Functions

| s_var ()
| Default constructor.
template<class T >
| s_var (const T &mValue)
| Value assignment constructor.
| s_var (const s_var &mVar)
| Copy constructor.
s_var & | operator= (const s_var &mVar)
s_bool | operator== (const s_var &mVar) const
s_bool | operator!= (const s_var &mVar) const
void | Swap (s_var &mVar)
| Swaps this value with another.
template<class T >
const T | Get () const
| Returns the contained value.
s_bool | IsEmpty () const
| Checks if this variable is empty.
const s_type & | GetType () const
| Returns the type of the contained value.
template<class T >
s_bool | IsOfType () const
| Checks the contained value's type.
s_str | ToString () const
| Converts this variable to a string.

## Static Public Attributes

static const s_type & | VALUE_NONE = typeid(void)
static const s_type & | VALUE_INT = typeid(s_int)
static const s_type & | VALUE_UINT = typeid(s_uint)
static const s_type & | VALUE_FLOAT = typeid(s_float)
static const s_type & | VALUE_DOUBLE = typeid(s_double)
static const s_type & | VALUE_BOOL = typeid(s_bool)
static const s_type & | VALUE_STRING = typeid(s_str)
static const s_type & | VALUE_POINTER = typeid(void*)

## Private Attributes

s_refptr< value_base > | pValue_

## Detailed Description

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, s_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.

Note:
  This class is highly inspired from boost::any.
  The comparison operators '==' and '!=' only work with base Frost types (s_str, s_float, s_double, s_uint, s_int and s_bool), and they assume that the compared variables are of the same internal type. If you need to compare another type T, just write : v1.Get<T>() == v2.Get<T>()

Definition at line 38 of file frost_utils_var.h.

## Constructor & Destructor Documentation

Frost::s_var::s_var | ( |  | ) |

Default constructor.

Definition at line 20 of file frost_utils_var.cpp.

template<class T >

Frost::s_var::s_var | ( | const T & | mValue | ) | `[inline]`

Value assignment constructor.

Parameters:

  | mValue | The value to assign

Definition at line 49 of file frost_utils_var.h.

Frost::s_var::s_var | ( | const s_var & | mVar | ) |

Copy constructor.

Parameters:

  | mVar | The s_var to copy

Definition at line 24 of file frost_utils_var.cpp.

## Member Function Documentation

template<class T >

const T Frost::s_var::Get | ( |  | ) | const`[inline]`

Returns the contained value.

Returns:
  The contained value

Note:
  If the provided type doesn't match the contained value's, a Warning is printed in the log, and this function returns a default value.

Definition at line 75 of file frost_utils_var.h.

const s_type & Frost::s_var::GetType | ( |  | ) | const

Returns the type of the contained value.

Returns:
  The type of the contained value

Note:
  Returns typeid(void) if the variable is empty.

Definition at line 101 of file frost_utils_var.cpp.

s_bool Frost::s_var::IsEmpty | ( |  | ) | const

Checks if this variable is empty.

Returns:
  'true' if this variable is empty

Note:
  Only the default constructor of s_var returns an empty variable.

Definition at line 95 of file frost_utils_var.cpp.

template<class T >

s_bool Frost::s_var::IsOfType | ( |  | ) | const`[inline]`

Checks the contained value's type.

Returns:
  'true' if the contained value's type is the one you provided

Definition at line 113 of file frost_utils_var.h.

s_bool Frost::s_var::operator!= | ( | const s_var & | mVar | ) | const

Definition at line 85 of file frost_utils_var.cpp.

s_var & Frost::s_var::operator= | ( | const s_var & | mVar | ) |

Definition at line 28 of file frost_utils_var.cpp.

s_bool Frost::s_var::operator== | ( | const s_var & | mVar | ) | const

Definition at line 38 of file frost_utils_var.cpp.

void Frost::s_var::Swap | ( | s_var & | mVar | ) |

Swaps this value with another.

Parameters:

  | mVar | the value to swap with this one

Definition at line 90 of file frost_utils_var.cpp.

s_str Frost::s_var::ToString | ( |  | ) | const

Converts this variable to a string.

Returns:
  This variable converted to a string

Definition at line 113 of file frost_utils_var.cpp.

## Member Data Documentation

s_refptr<value_base> Frost::s_var::pValue_`[private]`

Definition at line 186 of file frost_utils_var.h.

const s_type & Frost::s_var::VALUE_BOOL = typeid(s_bool)`[static]`

Definition at line 135 of file frost_utils_var.h.

const s_type & Frost::s_var::VALUE_DOUBLE = typeid(s_double)`[static]`

Definition at line 134 of file frost_utils_var.h.

const s_type & Frost::s_var::VALUE_FLOAT = typeid(s_float)`[static]`

Definition at line 133 of file frost_utils_var.h.

const s_type & Frost::s_var::VALUE_INT = typeid(s_int)`[static]`

Definition at line 131 of file frost_utils_var.h.

const s_type & Frost::s_var::VALUE_NONE = typeid(void)`[static]`

Definition at line 130 of file frost_utils_var.h.

const s_type & Frost::s_var::VALUE_POINTER = typeid(void*)`[static]`

Definition at line 137 of file frost_utils_var.h.

const s_type & Frost::s_var::VALUE_STRING = typeid(s_str)`[static]`

Definition at line 136 of file frost_utils_var.h.

const s_type & Frost::s_var::VALUE_UINT = typeid(s_uint)`[static]`

Definition at line 132 of file frost_utils_var.h.

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

- D:/Programmation/Sources/Tensor2/Utils/include/frost_utils_var.h
- D:/Programmation/Sources/Tensor2/Utils/src/frost_utils_var.cpp