edelib
2.1.0
|
Class for representing D-Bus data types. More...
#include <edelib/EdbusData.h>
Public Member Functions | |
EdbusData () | |
EdbusData (byte_t val) | |
EdbusData (bool val) | |
EdbusData (int16_t val) | |
EdbusData (uint16_t val) | |
EdbusData (int32_t val) | |
EdbusData (uint32_t val) | |
EdbusData (int64_t val) | |
EdbusData (uint64_t val) | |
EdbusData (double val) | |
EdbusData (const char *val) | |
EdbusData (const EdbusObjectPath &val) | |
EdbusData (const EdbusVariant &val) | |
EdbusData (const EdbusDict &val) | |
EdbusData (const EdbusList &val) | |
EdbusData (const EdbusData &other) | |
~EdbusData () | |
EdbusDataType | type (void) const |
byte_t | to_byte (void) const |
char | to_char (void) const |
bool | to_bool (void) const |
int16_t | to_int16 (void) const |
uint16_t | to_uint16 (void) const |
int32_t | to_int32 (void) const |
uint32_t | to_uint32 (void) const |
int64_t | to_int64 (void) const |
uint64_t | to_uint64 (void) const |
double | to_double (void) const |
const char * | to_string (void) const |
EdbusObjectPath | to_object_path (void) const |
EdbusVariant | to_variant (void) const |
EdbusDict | to_dict (void) const |
EdbusList | to_array (void) const |
EdbusList | to_struct (void) const |
EdbusData & | operator= (const EdbusData &other) |
bool | operator== (const EdbusData &other) const |
bool | operator!= (const EdbusData &other) const |
bool | is_valid (void) const |
bool | is_byte (void) const |
bool | is_char (void) const |
bool | is_bool (void) const |
bool | is_int16 (void) const |
bool | is_uint16 (void) const |
bool | is_int32 (void) const |
bool | is_uint32 (void) const |
bool | is_int64 (void) const |
bool | is_uint64 (void) const |
bool | is_double (void) const |
bool | is_string (void) const |
bool | is_object_path (void) const |
bool | is_array (void) const |
bool | is_struct (void) const |
bool | is_variant (void) const |
bool | is_dict (void) const |
Static Public Member Functions | |
static bool | basic_type (const EdbusData &val) |
static EdbusData | from_invalid (void) |
static EdbusData | from_byte (byte_t val) |
static EdbusData | from_char (char val) |
static EdbusData | from_bool (bool val) |
static EdbusData | from_int16 (int16_t val) |
static EdbusData | from_uint16 (uint16_t val) |
static EdbusData | from_int32 (int32_t val) |
static EdbusData | from_uint32 (uint32_t val) |
static EdbusData | from_int64 (int64_t val) |
static EdbusData | from_uint64 (uint64_t val) |
static EdbusData | from_double (double val) |
static EdbusData | from_string (const char *val) |
static EdbusData | from_object_path (const EdbusObjectPath &val) |
static EdbusData | from_variant (const EdbusVariant &val) |
static EdbusData | from_dict (const EdbusDict &val) |
static EdbusData | from_array (const EdbusList &val) |
static EdbusData | from_struct (const EdbusList &val) |
Class for representing D-Bus data types.
This class is variant-like class; this means it can hold any of already predefined types (see EdbusDataType for the list) that D-Bus protocol understainds.
Class use implicit sharing so copying EdbusData objects is cheap operation that does not require content copying.
Since EdbusData object can hold only one type at the time (I'm assuming arrays or structs are types too), when you decide to fetch a currently holding value, make sure you call correct function (e.g. for bool to_bool() or for double to_double()) or assertion will be triggered.
The best way to check what current type is, is to use one of is_XYZ members (e.g. for bool is_bool() or for double is_double()).
When data is assigned to EdbusData, it can implicitly resolve data type (e.g. strings, integers or EdbusObjectPath), but in case of similar types, things can a bit strange at first look. To better explain this, let say you assign 5 as value like:
What is d type? byte_t, int16_t, uint16_t, int32_t, uint32_t, int64_t and uint64_t can holds this value; by default, a compiler will use constructor with int32_t and d will be that type. This let-things-done-by-compiler stuff can introduce a strange bugs, so static from_ members are given to make life easier for compiler, like:
EdbusData | ( | ) |
Construct object with invalid type
EdbusData | ( | byte_t | val | ) |
Construct object with byte (char) type
EdbusData | ( | bool | val | ) |
Construct object with bool type
EdbusData | ( | int16_t | val | ) |
Construct object with int16 (short) type
EdbusData | ( | uint16_t | val | ) |
Construct object with uint16 (unsigned short) type
EdbusData | ( | int32_t | val | ) |
Construct object with int32 (int) type
EdbusData | ( | uint32_t | val | ) |
Construct object with uint32 (unsigned int) type
EdbusData | ( | int64_t | val | ) |
Construct object with int64 (long long) type
EdbusData | ( | uint64_t | val | ) |
Construct object with uint64 (unsigned long long) type
EdbusData | ( | double | val | ) |
Construct object with double type
EdbusData | ( | const char * | val | ) |
Construct object with string type
EdbusData | ( | const EdbusObjectPath & | val | ) |
Construct object with EdbusObjectPath type
EdbusData | ( | const EdbusVariant & | val | ) |
Construct object with EdbusVariant type
Construct object with EdbusList type. Correct type will be deduced from EdbusList::list_is_array() and EdbusList::list_is_struct() members
Construct object with already constructed object. Essential for containers
~EdbusData | ( | ) |
Destructs object cleaning allocated data
|
inlinestatic |
Returns true if given object is basic type. Basic types (to D-Bus) are all EdbusDataType types except array, structure, dict and variant
References edelib::EDBUS_TYPE_ARRAY, edelib::EDBUS_TYPE_DICT, edelib::EDBUS_TYPE_STRUCT, edelib::EDBUS_TYPE_VARIANT, and EdbusData::type().
|
inlinestatic |
Creates object with bool value
|
inlinestatic |
Creates object with byte value
|
inlinestatic |
Creates object with char value
Creates object with EdbusDict value
|
inlinestatic |
Creates object with double value
|
inlinestatic |
Creates object with int16 value
|
inlinestatic |
Creates object with int32 value
|
inlinestatic |
Creates object with int64 value
|
inlinestatic |
Creates object of invalid type
|
inlinestatic |
Creates object with EdbusObjectPath value
|
inlinestatic |
Creates object with string value
|
inlinestatic |
Creates object with uint16 value
|
inlinestatic |
Creates object with uint32 value
|
inlinestatic |
Creates object with uint64 value
|
inlinestatic |
Creates object with EdbusVariant value
|
inline |
Returns true if object currently holds a EdbusList as array value
References edelib::EDBUS_TYPE_ARRAY.
|
inline |
Returns true if object currently holds a bool value
References edelib::EDBUS_TYPE_BOOL.
|
inline |
Returns true if object currently holds a byte value
References edelib::EDBUS_TYPE_BYTE.
|
inline |
Returns true if object currently holds a char value
|
inline |
Returns true if object currently holds a EdbusDict value
References edelib::EDBUS_TYPE_DICT.
|
inline |
Returns true if object currently holds a double value
References edelib::EDBUS_TYPE_DOUBLE.
|
inline |
Returns true if object currently holds a int16 value
References edelib::EDBUS_TYPE_INT16.
|
inline |
Returns true if object currently holds a int32 value
References edelib::EDBUS_TYPE_INT32.
|
inline |
Returns true if object currently holds a int64 value
References edelib::EDBUS_TYPE_INT64.
|
inline |
Returns true if object currently holds a EdbusObjectPath value
References edelib::EDBUS_TYPE_OBJECT_PATH.
|
inline |
Returns true if object currently holds a string value
References edelib::EDBUS_TYPE_STRING.
|
inline |
Returns true if object currently holds a EdbusList as struct value
References edelib::EDBUS_TYPE_STRUCT.
|
inline |
Returns true if object currently holds a uint16 value
References edelib::EDBUS_TYPE_UINT16.
|
inline |
Returns true if object currently holds a uint32 value
References edelib::EDBUS_TYPE_UINT32.
|
inline |
Returns true if object currently holds a uint64 value
References edelib::EDBUS_TYPE_UINT64.
|
inline |
Returns true if object currently holds a value of valid type
References edelib::EDBUS_TYPE_INVALID.
|
inline |
Returns true if object currently holds a EdbusVariant value
References edelib::EDBUS_TYPE_VARIANT.
|
inline |
Check if two objects are not equal
bool operator== | ( | const EdbusData & | other | ) | const |
Check if two objects are the same checking their types and comparing their values if they are same type
bool to_bool | ( | void | ) | const |
Returns a bool value if it holds
byte_t to_byte | ( | void | ) | const |
Returns a byte value if it holds
|
inline |
Returns a char value if it holds
double to_double | ( | void | ) | const |
Returns a double value if it holds
int16_t to_int16 | ( | void | ) | const |
Returns a int16 value if it holds
int32_t to_int32 | ( | void | ) | const |
Returns a int32 value if it holds
int64_t to_int64 | ( | void | ) | const |
Returns a int64 value if it holds
EdbusObjectPath to_object_path | ( | void | ) | const |
Returns a EdbusObjectPath value if it holds
const char* to_string | ( | void | ) | const |
Returns a string value if it holds
uint16_t to_uint16 | ( | void | ) | const |
Returns a uint16 value if it holds
uint32_t to_uint32 | ( | void | ) | const |
Returns a uint32 value if it holds
uint64_t to_uint64 | ( | void | ) | const |
Returns a uint64 value if it holds
EdbusVariant to_variant | ( | void | ) | const |
Returns a EdbusVariant value if it holds
EdbusDataType type | ( | void | ) | const |
Returns a current holding type
Referenced by EdbusData::basic_type().