DBus::Variant Class Reference

A Variant is a type-safe union for DBus operations. More...

#include <variant.h>

Public Member Functions

 Variant ()
 
 Variant (uint8_t byte)
 
 Variant (bool b)
 
 Variant (int16_t i)
 
 Variant (uint16_t i)
 
 Variant (int32_t i)
 
 Variant (uint32_t i)
 
 Variant (int64_t i)
 
 Variant (uint64_t i)
 
 Variant (double i)
 
 Variant (const char *cstr)
 
 Variant (std::string str)
 
 Variant (Signature sig)
 
 Variant (Path path)
 
template<typename T >
 Variant (const std::vector< T > &vec)
 
template<typename Key , typename Value >
 Variant (const std::map< Key, Value > &map)
 
template<typename ... T>
 Variant (const std::tuple< T... > &tup)
 
 Variant (const Variant &other)
 
 Variant (Variant &&other)
 
 ~Variant ()
 
Signature signature () const
 
DataType type () const
 
const std::vector< uint8_t > * marshaled () const
 
int data_alignment () const
 
bool operator== (const Variant &other) const
 
Variantoperator= (const Variant &other)
 
template<typename T >
std::vector< T > to_vector ()
 
template<typename Key , typename Value >
std::map< Key, Value > to_map ()
 
template<typename ... T>
std::tuple< T... > to_tuple ()
 
bool to_bool () const
 
uint8_t to_uint8 () const
 
uint16_t to_uint16 () const
 
int16_t to_int16 () const
 
uint32_t to_uint32 () const
 
int32_t to_int32 () const
 
uint64_t to_uint64 () const
 
int64_t to_int64 () const
 
double to_double () const
 
std::string to_string () const
 
DBus::Path to_path () const
 
DBus::Signature to_signature () const
 
 operator bool ()
 
 operator uint8_t ()
 
 operator uint16_t ()
 
 operator int16_t ()
 
 operator uint32_t ()
 
 operator int32_t ()
 
 operator uint64_t ()
 
 operator int64_t ()
 
 operator double ()
 
 operator std::string ()
 
 operator DBus::Path ()
 
 operator DBus::Signature ()
 
template<typename T >
 operator std::vector< T > ()
 
template<typename Key , typename Data >
 operator std::map< Key, Data > ()
 
template<typename... T>
 operator std::tuple< T... > ()
 

Static Public Member Functions

static Variant createFromMessage (MessageIterator iter)
 Obsolete, do not call. More...
 
static Variant createFromDemarshal (Signature sig, std::shared_ptr< Demarshaling > demarshal, const std::vector< int > &filedescriptors, uint32_t depth)
 

Private Member Functions

void recurseArray (SignatureIterator iter, std::shared_ptr< Demarshaling > demarshal, Marshaling *marshal, const std::vector< int > &filedescriptors, uint32_t depth)
 
void recurseDictEntry (SignatureIterator iter, std::shared_ptr< Demarshaling > demarshal, Marshaling *marshal, uint32_t ending_offset, const std::vector< int > &filedescriptors, uint32_t depth)
 
void recurseStruct (SignatureIterator sigit, std::shared_ptr< Demarshaling > demarshal, Marshaling *marshal, const std::vector< int > &filedescriptors, uint32_t depth)
 
void remarshal (DataType dt, SignatureIterator sigit, std::shared_ptr< Demarshaling > demarshal, Marshaling *marshal, const std::vector< int > &filedescriptors, uint32_t depth)
 
void recurseArray (MessageIterator iter, Marshaling *marshal)
 Obsolete, do not call. More...
 
void recurseDictEntry (MessageIterator iter, Marshaling *marshal)
 Obsolete, do not call. More...
 
void recurseStruct (MessageIterator iter, Marshaling *marshal)
 Obsolete, do not call. More...
 

Private Attributes

DataType m_currentType
 
Signature m_signature
 
std::vector< uint8_t > m_marshaled
 
int m_dataAlignment
 

Friends

class priv::VariantAppendIterator
 
class priv::VariantIterator
 
std::ostream & operator<< (std::ostream &os, const Variant &var)
 

Detailed Description

A Variant is a type-safe union for DBus operations.

Variants are immutable - once you create them, you cannot change them.

To get the value out of the variant, use one of the to_XXX methods. If the type you requested is not possible to get out, an ErrorBadVariantCast will be thrown.

Constructor & Destructor Documentation

◆ Variant() [1/19]

Variant::Variant ( )

References DBus::INVALID.

◆ Variant() [2/19]

Variant::Variant ( uint8_t  byte)

◆ Variant() [3/19]

Variant::Variant ( bool  b)

◆ Variant() [4/19]

Variant::Variant ( int16_t  i)

◆ Variant() [5/19]

Variant::Variant ( uint16_t  i)

◆ Variant() [6/19]

Variant::Variant ( int32_t  i)

◆ Variant() [7/19]

Variant::Variant ( uint32_t  i)

◆ Variant() [8/19]

Variant::Variant ( int64_t  i)

◆ Variant() [9/19]

Variant::Variant ( uint64_t  i)

◆ Variant() [10/19]

Variant::Variant ( double  i)

◆ Variant() [11/19]

Variant::Variant ( const char *  cstr)

◆ Variant() [12/19]

Variant::Variant ( std::string  str)

◆ Variant() [13/19]

◆ Variant() [14/19]

Variant::Variant ( DBus::Path  path)
explicit

◆ Variant() [15/19]

template<typename T >
DBus::Variant::Variant ( const std::vector< T > &  vec)
inline

References DBus::ARRAY.

◆ Variant() [16/19]

template<typename Key , typename Value >
DBus::Variant::Variant ( const std::map< Key, Value > &  map)
inline

References DBus::ARRAY.

◆ Variant() [17/19]

template<typename ... T>
DBus::Variant::Variant ( const std::tuple< T... > &  tup)
inline

References DBus::STRUCT.

◆ Variant() [18/19]

Variant::Variant ( const Variant other)

◆ Variant() [19/19]

Variant::Variant ( Variant &&  other)

References DBus::INVALID.

◆ ~Variant()

Variant::~Variant ( )

Member Function Documentation

◆ createFromDemarshal()

◆ createFromMessage()

DBus::Variant Variant::createFromMessage ( MessageIterator  iter)
static

Obsolete, do not call.

◆ data_alignment()

◆ marshaled()

const std::vector< uint8_t > * Variant::marshaled ( ) const

◆ operator bool()

Variant::operator bool ( )

◆ operator DBus::Path()

Variant::operator DBus::Path ( )

◆ operator DBus::Signature()

Variant::operator DBus::Signature ( )

◆ operator double()

Variant::operator double ( )

◆ operator int16_t()

Variant::operator int16_t ( )

◆ operator int32_t()

Variant::operator int32_t ( )

◆ operator int64_t()

Variant::operator int64_t ( )

◆ operator std::map< Key, Data >()

template<typename Key , typename Data >
DBus::Variant::operator std::map< Key, Data > ( )
inline

◆ operator std::string()

Variant::operator std::string ( )

◆ operator std::tuple< T... >()

template<typename... T>
DBus::Variant::operator std::tuple< T... > ( )
inline

References to_tuple().

◆ operator std::vector< T >()

template<typename T >
DBus::Variant::operator std::vector< T > ( )
inline

◆ operator uint16_t()

Variant::operator uint16_t ( )

◆ operator uint32_t()

Variant::operator uint32_t ( )

◆ operator uint64_t()

Variant::operator uint64_t ( )

◆ operator uint8_t()

Variant::operator uint8_t ( )

◆ operator=()

Variant & Variant::operator= ( const Variant other)

◆ operator==()

bool Variant::operator== ( const Variant other) const

References m_marshaled, and type().

◆ recurseArray() [1/2]

void Variant::recurseArray ( MessageIterator  iter,
Marshaling marshal 
)
private

Obsolete, do not call.

◆ recurseArray() [2/2]

◆ recurseDictEntry() [1/2]

void Variant::recurseDictEntry ( MessageIterator  iter,
Marshaling marshal 
)
private

Obsolete, do not call.

◆ recurseDictEntry() [2/2]

void Variant::recurseDictEntry ( SignatureIterator  iter,
std::shared_ptr< Demarshaling demarshal,
Marshaling marshal,
uint32_t  ending_offset,
const std::vector< int > &  filedescriptors,
uint32_t  depth 
)
private

◆ recurseStruct() [1/2]

void Variant::recurseStruct ( MessageIterator  iter,
Marshaling marshal 
)
private

Obsolete, do not call.

◆ recurseStruct() [2/2]

void Variant::recurseStruct ( SignatureIterator  sigit,
std::shared_ptr< Demarshaling demarshal,
Marshaling marshal,
const std::vector< int > &  filedescriptors,
uint32_t  depth 
)
private

◆ remarshal()

◆ signature()

◆ to_bool()

bool Variant::to_bool ( ) const

◆ to_double()

double Variant::to_double ( ) const

◆ to_int16()

int16_t Variant::to_int16 ( ) const

◆ to_int32()

int32_t Variant::to_int32 ( ) const

◆ to_int64()

int64_t Variant::to_int64 ( ) const

◆ to_map()

template<typename Key , typename Value >
std::map<Key, Value> DBus::Variant::to_map ( )
inline

References DBus::ARRAY, and m_currentType.

◆ to_path()

◆ to_signature()

◆ to_string()

◆ to_tuple()

template<typename ... T>
std::tuple<T...> DBus::Variant::to_tuple ( )
inline

References m_currentType, and DBus::STRUCT.

Referenced by operator std::tuple< T... >().

◆ to_uint16()

uint16_t Variant::to_uint16 ( ) const

◆ to_uint32()

◆ to_uint64()

uint64_t Variant::to_uint64 ( ) const

◆ to_uint8()

uint8_t Variant::to_uint8 ( ) const

◆ to_vector()

template<typename T >
std::vector<T> DBus::Variant::to_vector ( )
inline

References DBus::ARRAY, and m_currentType.

◆ type()

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const Variant var 
)
friend

◆ priv::VariantAppendIterator

friend class priv::VariantAppendIterator
friend

◆ priv::VariantIterator

friend class priv::VariantIterator
friend

Member Data Documentation

◆ m_currentType

◆ m_dataAlignment

int DBus::Variant::m_dataAlignment
private

◆ m_marshaled

◆ m_signature


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