![]() |
dbus-cxx
|
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 |
| Variant & | operator= (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 |
| Variant | to_variant () 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) |
| static Variant | createFromVariant (Variant &other) |
| Wrap variant 'other' inside of a new variant. More... | |
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) |
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.
| Variant::Variant | ( | ) |
References DBus::INVALID.
| Variant::Variant | ( | uint8_t | byte | ) |
References DBus::BYTE, DBus::default_endianess(), m_marshaled, and DBus::Marshaling::marshal().
| Variant::Variant | ( | bool | b | ) |
References DBus::BOOLEAN, DBus::default_endianess(), m_marshaled, and DBus::Marshaling::marshal().
| Variant::Variant | ( | int16_t | i | ) |
References DBus::default_endianess(), DBus::INT16, m_marshaled, and DBus::Marshaling::marshal().
| Variant::Variant | ( | uint16_t | i | ) |
References DBus::default_endianess(), m_marshaled, DBus::Marshaling::marshal(), and DBus::UINT16.
| Variant::Variant | ( | int32_t | i | ) |
References DBus::default_endianess(), DBus::INT32, m_marshaled, and DBus::Marshaling::marshal().
| Variant::Variant | ( | uint32_t | i | ) |
References DBus::default_endianess(), m_marshaled, DBus::Marshaling::marshal(), and DBus::UINT32.
| Variant::Variant | ( | int64_t | i | ) |
References DBus::default_endianess(), DBus::INT64, m_marshaled, and DBus::Marshaling::marshal().
| Variant::Variant | ( | uint64_t | i | ) |
References DBus::default_endianess(), m_marshaled, DBus::Marshaling::marshal(), and DBus::UINT64.
| Variant::Variant | ( | double | i | ) |
References DBus::default_endianess(), DBus::DOUBLE, m_marshaled, and DBus::Marshaling::marshal().
| Variant::Variant | ( | const char * | cstr | ) |
| Variant::Variant | ( | std::string | str | ) |
References DBus::default_endianess(), m_marshaled, DBus::Marshaling::marshal(), and DBus::STRING.
|
explicit |
References DBus::default_endianess(), m_marshaled, DBus::Marshaling::marshal(), and DBus::SIGNATURE.
|
explicit |
References DBus::default_endianess(), m_marshaled, DBus::Marshaling::marshal(), and DBus::OBJECT_PATH.
|
inline |
References DBus::ARRAY.
|
inline |
References DBus::ARRAY.
|
inline |
References DBus::STRUCT.
| Variant::Variant | ( | const Variant & | other | ) |
| Variant::Variant | ( | Variant && | other | ) |
References DBus::INVALID.
| Variant::~Variant | ( | ) |
|
static |
References DBus::TypeInfo::alignment(), DBus::ARRAY, DBus::Signature::begin(), DBus::BOOLEAN, DBus::BYTE, createFromDemarshal(), createFromVariant(), DBus::default_endianess(), DBus::DOUBLE, DBus::INT16, DBus::INT32, DBus::INT64, DBus::INVALID, LOGGER_NAME, m_currentType, m_dataAlignment, m_marshaled, m_signature, DBus::Marshaling::marshal(), DBus::Validator::maximum_message_depth(), DBus::OBJECT_PATH, DBus::SignatureIterator::recurse(), recurseArray(), recurseStruct(), DBus::SIGNATURE, SIMPLELOGGER_TRACE, DBus::STRING, DBus::STRUCT, DBus::SignatureIterator::type(), DBus::UINT16, DBus::UINT32, DBus::UINT64, and DBus::VARIANT.
Referenced by createFromDemarshal(), DBus::MessageIterator::get_variant(), DBus::priv::VariantIterator::get_variant(), and remarshal().
|
static |
Obsolete, do not call.
Wrap variant 'other' inside of a new variant.
| other |
References DBus::TypeInfo::alignment(), DBus::default_endianess(), m_currentType, m_dataAlignment, m_marshaled, m_signature, DBus::Marshaling::marshal(), DBus::signature(), and DBus::VARIANT.
Referenced by createFromDemarshal().
| int Variant::data_alignment | ( | ) | const |
References m_dataAlignment.
Referenced by DBus::Marshaling::marshal(), DBus::MessageAppendIterator::operator<<(), and DBus::priv::VariantAppendIterator::operator<<().
| const std::vector< uint8_t > * Variant::marshaled | ( | ) | const |
References m_marshaled.
Referenced by DBus::Marshaling::marshal(), DBus::MessageAppendIterator::operator<<(), DBus::priv::VariantAppendIterator::operator<<(), and remarshal().
| Variant::operator bool | ( | ) |
| Variant::operator DBus::Path | ( | ) |
| Variant::operator DBus::Signature | ( | ) |
| Variant::operator double | ( | ) |
| Variant::operator int16_t | ( | ) |
| Variant::operator int32_t | ( | ) |
| Variant::operator int64_t | ( | ) |
|
inline |
| Variant::operator std::string | ( | ) |
|
inline |
References to_tuple().
|
inline |
| Variant::operator uint16_t | ( | ) |
| Variant::operator uint32_t | ( | ) |
| Variant::operator uint64_t | ( | ) |
| Variant::operator uint8_t | ( | ) |
References m_currentType, m_dataAlignment, m_marshaled, and m_signature.
| bool Variant::operator== | ( | const Variant & | other | ) | const |
References m_marshaled, and type().
|
private |
Obsolete, do not call.
|
private |
References DBus::Marshaling::align(), DBus::TypeInfo::alignment(), DBus::default_endianess(), DBus::DICT_ENTRY, LOGGER_NAME, DBus::Marshaling::marshal(), DBus::Validator::maximum_message_depth(), DBus::SignatureIterator::recurse(), recurseDictEntry(), remarshal(), SIMPLELOGGER_TRACE, and DBus::SignatureIterator::type().
Referenced by createFromDemarshal(), and remarshal().
|
private |
Obsolete, do not call.
|
private |
References DBus::Marshaling::align(), LOGGER_NAME, DBus::Validator::maximum_message_depth(), remarshal(), SIMPLELOGGER_TRACE, and DBus::SignatureIterator::type().
Referenced by recurseArray().
|
private |
Obsolete, do not call.
|
private |
References DBus::Marshaling::align(), DBus::SignatureIterator::is_valid(), DBus::Validator::maximum_message_depth(), remarshal(), and DBus::SignatureIterator::type().
Referenced by createFromDemarshal(), and remarshal().
|
private |
References DBus::Marshaling::align(), DBus::TypeInfo::alignment(), DBus::ARRAY, DBus::Signature::begin(), DBus::BOOLEAN, DBus::BYTE, createFromDemarshal(), DBus::DICT_ENTRY, DBus::DOUBLE, DBus::Signature::end(), DBus::INT16, DBus::INT32, DBus::INT64, DBus::Marshaling::marshal(), marshaled(), DBus::OBJECT_PATH, DBus::SignatureIterator::recurse(), recurseArray(), recurseStruct(), DBus::SIGNATURE, DBus::STRING, DBus::STRUCT, type(), DBus::UINT16, DBus::UINT32, DBus::UINT64, and DBus::VARIANT.
Referenced by recurseArray(), recurseDictEntry(), and recurseStruct().
| DBus::Signature Variant::signature | ( | ) | const |
References m_signature.
Referenced by DBus::Marshaling::marshal(), DBus::MessageAppendIterator::operator<<(), and DBus::priv::VariantIterator::VariantIterator().
| bool Variant::to_bool | ( | ) | const |
References DBus::BOOLEAN, DBus::priv::VariantIterator::get_bool(), and m_currentType.
| double Variant::to_double | ( | ) | const |
References DBus::DOUBLE, DBus::priv::VariantIterator::get_double(), and m_currentType.
| int16_t Variant::to_int16 | ( | ) | const |
References DBus::priv::VariantIterator::get_int16(), DBus::INT16, and m_currentType.
| int32_t Variant::to_int32 | ( | ) | const |
References DBus::priv::VariantIterator::get_int32(), DBus::INT32, and m_currentType.
| int64_t Variant::to_int64 | ( | ) | const |
References DBus::priv::VariantIterator::get_int64(), DBus::INT64, and m_currentType.
|
inline |
References DBus::ARRAY, m_currentType, and retval.
| DBus::Path Variant::to_path | ( | ) | const |
References DBus::priv::VariantIterator::get_string(), m_currentType, and DBus::OBJECT_PATH.
Referenced by DBus::CallMessage::path(), and DBus::SignalMessage::path().
| DBus::Signature Variant::to_signature | ( | ) | const |
References DBus::priv::VariantIterator::get_signature(), m_currentType, and DBus::SIGNATURE.
Referenced by DBus::Message::append_signature(), and DBus::Message::signature().
| std::string Variant::to_string | ( | ) | const |
|
inline |
References m_currentType, and DBus::STRUCT.
Referenced by operator std::tuple< T... >().
| uint16_t Variant::to_uint16 | ( | ) | const |
References DBus::priv::VariantIterator::get_uint16(), m_currentType, and DBus::UINT16.
| uint32_t Variant::to_uint32 | ( | ) | const |
References DBus::priv::VariantIterator::get_uint32(), m_currentType, and DBus::UINT32.
Referenced by DBus::ErrorMessage::reply_serial(), DBus::ReturnMessage::reply_serial(), and DBus::Message::serialize_to_vector().
| uint64_t Variant::to_uint64 | ( | ) | const |
References DBus::priv::VariantIterator::get_uint64(), m_currentType, and DBus::UINT64.
| uint8_t Variant::to_uint8 | ( | ) | const |
References DBus::BYTE, DBus::priv::VariantIterator::get_uint8(), and m_currentType.
| Variant Variant::to_variant | ( | ) | const |
References DBus::priv::VariantIterator::get_variant(), m_currentType, and DBus::VARIANT.
|
inline |
References DBus::ARRAY, m_currentType, and retval.
| DBus::DataType Variant::type | ( | ) | const |
References m_currentType.
Referenced by DBus::Message::append_signature(), DBus::CallMessage::interface_name(), DBus::SignalMessage::interface_name(), DBus::SignalMessage::member(), DBus::ErrorMessage::name(), DBus::MessageAppendIterator::operator<<(), DBus::priv::VariantAppendIterator::operator<<(), operator==(), DBus::CallMessage::path(), DBus::SignalMessage::path(), remarshal(), DBus::ErrorMessage::reply_serial(), DBus::ReturnMessage::reply_serial(), DBus::Message::serialize_to_vector(), and DBus::Message::signature().
|
friend |
|
friend |
|
friend |
|
private |
Referenced by createFromDemarshal(), createFromVariant(), DBus::priv::VariantAppendIterator::operator<<(), operator=(), to_bool(), to_double(), to_int16(), to_int32(), to_int64(), to_map(), to_path(), to_signature(), to_string(), to_tuple(), to_uint16(), to_uint32(), to_uint64(), to_uint8(), to_variant(), to_vector(), and type().
|
private |
Referenced by createFromDemarshal(), createFromVariant(), data_alignment(), and operator=().
|
private |
|
private |