#include <comstl/util/variant.hpp>
VARIANT
as a measure of expedience, rather than as an act of design sophistication. Any manual manipulation of the instances, or their member variables, is at the user's risk. Notwithstanding, this is helped by the fact that comstl::variant declares no member variables and no virtual member functions - for most compilers this means that the Empty Derived Optimisation (see Section 12.4 of Imperfect C++) will apply. Public Types | |
typedef variant | class_type |
Member Types. | |
typedef bool | bool_type |
typedef size_t | size_type |
Public Member Functions | |
variant () | |
Conversion. | |
variant (VARIANT const &rhs) | |
Copying constructor. | |
variant (class_type const &rhs) | |
Copy constructor. | |
class_type & | operator= (class_type const &rhs) |
Copy assignment operator. | |
variant (bool b) | |
Conversion constructor. | |
variant (stlsoft::sint8_t i) | |
Conversion constructor. | |
variant (stlsoft::uint8_t i) | |
Conversion constructor. | |
variant (stlsoft::sint16_t i) | |
Conversion constructor. | |
variant (stlsoft::uint16_t i) | |
Conversion constructor. | |
variant (stlsoft::sint32_t i) | |
Conversion constructor. | |
variant (stlsoft::uint32_t i) | |
Conversion constructor. | |
variant (float r) | |
Conversion constructor. | |
variant (double r) | |
Conversion constructor. | |
variant (CY cy) | |
Conversion constructor. | |
variant (DECIMAL const &dec) | |
Conversion constructor. | |
variant (LPUNKNOWN punk, bool_type bAddRef) | |
variant (LPDISPATCH pdisp, bool_type bAddRef) | |
variant (char const *s, int len=-1) | |
variant (wchar_t const *s, int len=-1) | |
variant (VARIANT const &var, VARTYPE vt) | |
~variant () throw () | |
Releases any resources associated with the underlying VARIANT . | |
void | clear () |
Clears the variant. | |
HRESULT | try_conversion_copy (VARIANT const &var, VARTYPE vt) |
Operations. | |
HRESULT | try_convert (VARTYPE vt) |
class_type & | convert (VARTYPE vt) |
HRESULT | QueryInterface (REFIID riid, void **ppv) const |
Returns a pointer to a specified interface on an object to which a client currently holds an interface pointer. | |
template<typename I> | |
HRESULT | QueryInterfaceValue (I **ppi) |
Returns a pointer to a specified interface on an object to which a client currently holds an interface pointer. | |
void | swap (class_type &rhs) |
Swaps the contents with another instance. | |
bool_type | equal (class_type const &rhs) const |
Comparison. | |
bool_type | equal (VARIANT const &rhs) const |
typedef variant class_type |
Member Types.
variant | ( | ) |
Conversion.
Default constructor Initialises the instance
assert(VT_EMPTY == this->vt)
- | Does not throw an exception |
variant | ( | VARIANT const & | rhs | ) |
Copying constructor.
Initialises the instance with a copy of the given VARIANT
assert(rhs == *this)
comstl::com_exception | If the copy fails |
variant | ( | class_type const & | rhs | ) |
Copy constructor.
assert(rhs == *this)
comstl::com_exception | If the copy fails |
variant | ( | bool | b | ) |
Conversion constructor.
Initialises the instance with the given boolean value
assert(VT_BOOL == this->vt)
assert(b == (VARIANT_TRUE == this->boolVal))
- | Does not throw an exception |
variant | ( | stlsoft::sint8_t | i | ) |
Conversion constructor.
Initialises the instance with the given 8-bit signed integer value
assert(VT_I1 == this->vt)
assert(i == this->cVal)
- | Does not throw an exception |
variant | ( | stlsoft::uint8_t | i | ) |
Conversion constructor.
Initialises the instance with the given 8-bit unsigned integer value
assert(VT_UI1 == this->vt)
assert(i == this->bVal)
- | Does not throw an exception |
variant | ( | stlsoft::sint16_t | i | ) |
Conversion constructor.
Initialises the instance with the given 16-bit signed integer value
assert(VT_I2 == this->vt)
assert(i == this->iVal)
- | Does not throw an exception |
variant | ( | stlsoft::uint16_t | i | ) |
Conversion constructor.
Initialises the instance with the given 16-bit unsigned integer value
assert(VT_UI2 == this->vt)
assert(i == this->uiVal)
- | Does not throw an exception |
variant | ( | stlsoft::sint32_t | i | ) |
Conversion constructor.
Initialises the instance with the given 32-bit signed integer value
assert(VT_I4 == this->vt)
assert(i == this->lVal)
- | Does not throw an exception |
variant | ( | stlsoft::uint32_t | i | ) |
Conversion constructor.
Initialises the instance with the given 32-bit unsigned integer value
assert(VT_UI4 == this->vt)
assert(i == this->ulVal)
- | Does not throw an exception |
variant | ( | float | r | ) |
Conversion constructor.
Initialises the instance with the given float
value
assert(VT_R4 == this->vt)
assert(r == this->fltVal)
- | Does not throw an exception |
variant | ( | double | r | ) |
Conversion constructor.
Initialises the instance with the given double
value
assert(VT_R8 == this->vt)
assert(r == this->dblVal)
- | Does not throw an exception |
variant | ( | CY | cy | ) |
Conversion constructor.
Initialises the instance with the given currency (CY
) value
assert(VT_CY == this->vt)
assert(r == this->cyVal)
- | Does not throw an exception |
variant | ( | DECIMAL const & | dec | ) |
Conversion constructor.
Initialises the instance with the given DECIMAL
value
assert(VT_DECIMAL == this->vt)
assert(dec == this->decVal)
- | Does not throw an exception |
~variant | ( | ) | throw () [inline] |
Releases any resources associated with the underlying VARIANT
.
class_type& operator= | ( | class_type const & | rhs | ) |
Copy assignment operator.
assert(rhs == *this)
comstl::com_exception | If the copy fails |
void clear | ( | ) |
HRESULT try_conversion_copy | ( | VARIANT const & | var, | |
VARTYPE | vt | |||
) |
Operations.
HRESULT QueryInterface | ( | REFIID | riid, | |
void ** | ppv | |||
) | const |
Returns a pointer to a specified interface on an object to which a client currently holds an interface pointer.
HRESULT
code indicating the success of the operation. <code>S_OK</code> | The interface is supported: *ppv will hold the pointer to the requested interface | |
<code>E_INTERFACE</code> | The interface is not supported: the value of *ppv is undefined. |
NULL != ppv
HRESULT QueryInterfaceValue | ( | I ** | ppi | ) | [inline] |
Returns a pointer to a specified interface on an object to which a client currently holds an interface pointer.
HRESULT
code indicating the success of the operation. <code>S_OK</code> | The interface is supported: *ppi will hold the pointer to the requested interface | |
<code>E_INTERFACE</code> | The interface is not supported: the value of *ppi is undefined. |
NULL != ppi
void swap | ( | class_type & | rhs | ) |
Swaps the contents with another instance.
bool_type equal | ( | class_type const & | rhs | ) | const |
Comparison.