xlnt
Public Types | Public Member Functions | List of all members
xlnt::variant Class Reference

Represents an object that can have variable type. More...

#include <variant.hpp>

Public Types

enum  type {
  vector, null, i4, lpstr,
  date, boolean
}
 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 date-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::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 >
get () const
 Returns the value of this variant as type T. An 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
 
template<>
bool get () const
 
template<>
std::int32_t get () const
 
template<>
std::string get () const
 
template<>
datetime get () const
 
template<>
std::vector< std::int32_t > get () const
 
template<>
std::vector< std::string > get () const
 
template<>
std::vector< variantget () const
 

Detailed Description

Represents an object that can have variable type.

Member Enumeration Documentation

◆ type

enum xlnt::variant::type
strong

The possible types a variant can hold.

Constructor & Destructor Documentation

◆ variant() [1/13]

xlnt::variant::variant ( )

Default constructor. Creates a null-type variant.

◆ variant() [2/13]

xlnt::variant::variant ( const std::string &  value)

Creates a string-type variant with the given value.

◆ variant() [3/13]

xlnt::variant::variant ( const char *  value)

Creates a string-type variant with the given value.

◆ variant() [4/13]

xlnt::variant::variant ( std::int32_t  value)

Creates a i4-type variant with the given value.

◆ variant() [5/13]

xlnt::variant::variant ( bool  value)

Creates a bool-type variant with the given value.

◆ variant() [6/13]

xlnt::variant::variant ( const datetime value)

Creates a date-type variant with the given value.

◆ variant() [7/13]

xlnt::variant::variant ( const std::initializer_list< std::int32_t > &  value)

Creates a vector_i4-type variant with the given value.

◆ variant() [8/13]

xlnt::variant::variant ( const std::vector< std::int32_t > &  value)

Creates a vector_i4-type variant with the given value.

◆ variant() [9/13]

xlnt::variant::variant ( const std::initializer_list< const char *> &  value)

Creates a vector_string-type variant with the given value.

◆ variant() [10/13]

xlnt::variant::variant ( const std::vector< const char *> &  value)

Creates a vector_string-type variant with the given value.

◆ variant() [11/13]

xlnt::variant::variant ( const std::initializer_list< std::string > &  value)

Creates a vector_string-type variant with the given value.

◆ variant() [12/13]

xlnt::variant::variant ( const std::vector< std::string > &  value)

Creates a vector_string-type variant with the given value.

◆ variant() [13/13]

xlnt::variant::variant ( const std::vector< variant > &  value)

Creates a vector_variant-type variant with the given value.

Member Function Documentation

◆ get()

template<typename T >
T xlnt::variant::get ( ) const

Returns the value of this variant as type T. An exception will be thrown if the types are not convertible.

◆ is()

bool xlnt::variant::is ( type  t) const

Returns true if this variant is of type t.

◆ value_type()

type xlnt::variant::value_type ( ) const

Returns the type of this variant.


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