|
xlnt - community edition
|
Represents an object that can have variable type. More...
#include <variant.hpp>
Public Types | |
| enum | type { vector = 1, null = 6, i4 = 9, lpstr = 20, date = 23, boolean = 25 } |
| The possible types a variant can hold. More... | |
Public Member Functions | |
| variant () | |
| Default constructor. Creates a null-type variant. More... | |
| variant (const std::string &value) | |
| Creates a string-type variant with the given value. More... | |
| variant (const char *value) | |
| Creates a string-type variant with the given value. More... | |
| variant (std::int32_t value) | |
| Creates a i4-type variant with the given value. More... | |
| variant (bool value) | |
| Creates a bool-type variant with the given value. More... | |
| variant (const datetime &value) | |
| Creates a datetime-type variant with the given value. More... | |
| variant (const std::initializer_list< std::int32_t > &value) | |
| Creates a vector_i4-type variant with the given value. More... | |
| variant (const std::vector< std::int32_t > &value) | |
| Creates a vector_i4-type variant with the given value. More... | |
| variant (const std::initializer_list< const char *> &value) | |
| Creates a vector_string-type variant with the given value. More... | |
| variant (const std::vector< const char *> &value) | |
| Creates a vector_string-type variant with the given value. More... | |
| variant (const std::initializer_list< std::string > &value) | |
| Creates a vector_string-type variant with the given value. More... | |
| variant (const std::vector< std::string > &value) | |
| Creates a vector_string-type variant with the given value. More... | |
| variant (const std::initializer_list< bool > &value) | |
| Creates a vector_bool-type variant with the given value. More... | |
| variant (const std::vector< bool > &value) | |
| Creates a vector_bool-type variant with the given value. More... | |
| variant (const std::initializer_list< datetime > &value) | |
| Creates a vector_datetime-type variant with the given value. More... | |
| variant (const std::vector< datetime > &value) | |
| Creates a vector_datetime-type variant with the given value. More... | |
| variant (const std::initializer_list< variant > &value) | |
| Creates a vector_variant-type variant with the given value. More... | |
| variant (const std::vector< variant > &value) | |
| Creates a vector_variant-type variant with the given value. More... | |
| bool | is (type t) const |
| Returns true if this variant is of type t. More... | |
| template<typename T > | |
| T | get () const |
| Returns the value of this variant as type T. Assumes that the variant is of type T (please call is() or value_type() to check). For details on each type, please see the documentation for each get<T> function below. An xlnt::bad_variant_access exception will be thrown if the types are not convertible. More... | |
| type | value_type () const |
| Returns the type of this variant. More... | |
| bool | operator== (const variant &rhs) const |
| bool | operator!= (const variant &rhs) const |
| template<> | |
| bool | get () const |
| Returns the value of this variant as type bool. Assumes that the variant is of type::boolean (please call is() or value_type() to check). An xlnt::bad_variant_access exception will be thrown if the types are not compatible. More... | |
| template<> | |
| std::int32_t | get () const |
| Returns the value of this variant as type std::int32_t. Assumes that the variant is of type::i4 (please call is() or value_type() to check). An xlnt::bad_variant_access exception will be thrown if the types are not compatible. More... | |
| template<> | |
| std::string | get () const |
| Returns the value of this variant as type std::string. Please call is() or value_type() to check the type. The following types are compatible: More... | |
| template<> | |
| datetime | get () const |
| Returns the value of this variant as type xlnt::datetime. Assumes that the variant is of type::date (please call is() or value_type() to check). An xlnt::bad_variant_access exception will be thrown if the types are not compatible. More... | |
| template<> | |
| std::vector< variant > | get () const |
| Returns the value of this variant as type std::vector<xlnt::variant>. Please call is() or value_type() to check the type. The following types are compatible: More... | |
| template<> | |
| std::vector< bool > | get () const |
| Returns the value of this variant as type std::vector<bool>. Assumes that the variant is of type::vector (please call is() or value_type() to check) containing elements of type::boolean. An xlnt::bad_variant_access exception will be thrown if the types are not compatible. More... | |
| template<> | |
| std::vector< std::int32_t > | get () const |
| Returns the value of this variant as type std::vector<std::int32_t>. Assumes that the variant is of type::vector (please call is() or value_type() to check) containing elements of type::i4. An xlnt::bad_variant_access exception will be thrown if the types are not compatible. More... | |
| template<> | |
| std::vector< std::string > | get () const |
| Returns the value of this variant as type std::vector<std::string>. Assumes that the variant is of type::vector (please call is() or value_type() to check) containing elements of type: More... | |
| template<> | |
| std::vector< datetime > | get () const |
| Returns the value of this variant as type std::vector<xlnt::datetime>. Assumes that the variant is of type::vector (please call is() or value_type() to check) containing elements of type::date. An xlnt::bad_variant_access exception will be thrown if the types are not compatible. More... | |
Static Public Member Functions | |
| static std::string | get_type_string (type type) |
| Returns a displayable string for the specified type. More... | |
Represents an object that can have variable type.
|
strong |
The possible types a variant can hold.
| xlnt::variant::variant | ( | ) |
Default constructor. Creates a null-type variant.
| xlnt::variant::variant | ( | const std::string & | value | ) |
Creates a string-type variant with the given value.
| xlnt::variant::variant | ( | const char * | value | ) |
Creates a string-type variant with the given value.
| xlnt::variant::variant | ( | std::int32_t | value | ) |
Creates a i4-type variant with the given value.
| xlnt::variant::variant | ( | bool | value | ) |
Creates a bool-type variant with the given value.
| xlnt::variant::variant | ( | const datetime & | value | ) |
Creates a datetime-type variant with the given value.
| xlnt::variant::variant | ( | const std::initializer_list< std::int32_t > & | value | ) |
Creates a vector_i4-type variant with the given value.
| xlnt::variant::variant | ( | const std::vector< std::int32_t > & | value | ) |
Creates a vector_i4-type variant with the given value.
| xlnt::variant::variant | ( | const std::initializer_list< const char *> & | value | ) |
Creates a vector_string-type variant with the given value.
| xlnt::variant::variant | ( | const std::vector< const char *> & | value | ) |
Creates a vector_string-type variant with the given value.
| xlnt::variant::variant | ( | const std::initializer_list< std::string > & | value | ) |
Creates a vector_string-type variant with the given value.
| xlnt::variant::variant | ( | const std::vector< std::string > & | value | ) |
Creates a vector_string-type variant with the given value.
| xlnt::variant::variant | ( | const std::initializer_list< bool > & | value | ) |
Creates a vector_bool-type variant with the given value.
| xlnt::variant::variant | ( | const std::vector< bool > & | value | ) |
Creates a vector_bool-type variant with the given value.
| xlnt::variant::variant | ( | const std::initializer_list< datetime > & | value | ) |
Creates a vector_datetime-type variant with the given value.
| xlnt::variant::variant | ( | const std::vector< datetime > & | value | ) |
Creates a vector_datetime-type variant with the given value.
| xlnt::variant::variant | ( | const std::initializer_list< variant > & | value | ) |
Creates a vector_variant-type variant with the given value.
| xlnt::variant::variant | ( | const std::vector< variant > & | value | ) |
Creates a vector_variant-type variant with the given value.
| T xlnt::variant::get | ( | ) | const |
Returns the value of this variant as type T. Assumes that the variant is of type T (please call is() or value_type() to check). For details on each type, please see the documentation for each get<T> function below. An xlnt::bad_variant_access exception will be thrown if the types are not convertible.
| bool xlnt::variant::get | ( | ) | const |
Returns the value of this variant as type bool. Assumes that the variant is of type::boolean (please call is() or value_type() to check). An xlnt::bad_variant_access exception will be thrown if the types are not compatible.
| std::int32_t xlnt::variant::get | ( | ) | const |
Returns the value of this variant as type std::int32_t. Assumes that the variant is of type::i4 (please call is() or value_type() to check). An xlnt::bad_variant_access exception will be thrown if the types are not compatible.
| std::string xlnt::variant::get | ( | ) | const |
Returns the value of this variant as type std::string. Please call is() or value_type() to check the type. The following types are compatible:
| datetime xlnt::variant::get | ( | ) | const |
Returns the value of this variant as type xlnt::datetime. Assumes that the variant is of type::date (please call is() or value_type() to check). An xlnt::bad_variant_access exception will be thrown if the types are not compatible.
| std::vector<variant> xlnt::variant::get | ( | ) | const |
Returns the value of this variant as type std::vector<xlnt::variant>. Please call is() or value_type() to check the type. The following types are compatible:
| std::vector<bool> xlnt::variant::get | ( | ) | const |
Returns the value of this variant as type std::vector<bool>. Assumes that the variant is of type::vector (please call is() or value_type() to check) containing elements of type::boolean. An xlnt::bad_variant_access exception will be thrown if the types are not compatible.
| std::vector<std::int32_t> xlnt::variant::get | ( | ) | const |
Returns the value of this variant as type std::vector<std::int32_t>. Assumes that the variant is of type::vector (please call is() or value_type() to check) containing elements of type::i4. An xlnt::bad_variant_access exception will be thrown if the types are not compatible.
| std::vector<std::string> xlnt::variant::get | ( | ) | const |
Returns the value of this variant as type std::vector<std::string>. Assumes that the variant is of type::vector (please call is() or value_type() to check) containing elements of type:
| std::vector<datetime> xlnt::variant::get | ( | ) | const |
Returns the value of this variant as type std::vector<xlnt::datetime>. Assumes that the variant is of type::vector (please call is() or value_type() to check) containing elements of type::date. An xlnt::bad_variant_access exception will be thrown if the types are not compatible.
|
static |
Returns a displayable string for the specified type.
| bool xlnt::variant::is | ( | type | t | ) | const |
Returns true if this variant is of type t.
| type xlnt::variant::value_type | ( | ) | const |
Returns the type of this variant.
1.8.13