EdbusData.h
/*
* $Id: EdbusData.h 3441 2012-11-01 20:40:30Z karijes $
*
* D-BUS stuff
* Copyright (c) 2008 edelib authors
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __EDELIB_EDBUSDATA_H__
#define __EDELIB_EDBUSDATA_H__
#include <inttypes.h>
#include "EdbusObjectPath.h"
typedef char byte_t;
/* Sun compiler does not have this type */
#ifdef __SUNPRO_CC
typedef long long int int64_t;
#endif
EDELIB_NS_BEGIN
enum EdbusDataType {
EDBUS_TYPE_INVALID,
EDBUS_TYPE_BYTE,
EDBUS_TYPE_BOOL,
EDBUS_TYPE_INT16,
EDBUS_TYPE_UINT16,
EDBUS_TYPE_INT32,
EDBUS_TYPE_UINT32,
EDBUS_TYPE_INT64,
EDBUS_TYPE_UINT64,
EDBUS_TYPE_DOUBLE,
EDBUS_TYPE_STRING,
EDBUS_TYPE_OBJECT_PATH,
EDBUS_TYPE_ARRAY,
EDBUS_TYPE_STRUCT,
EDBUS_TYPE_DICT,
EDBUS_TYPE_VARIANT
};
#ifndef SKIP_DOCS
struct EdbusDataPrivate;
#endif
struct EdbusDict;
class EdbusList;
struct EdbusVariant;
class EDELIB_API EdbusData {
private:
EdbusDataPrivate* impl;
void dispose(void);
public:
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 { return to_byte(); }
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 { return !operator==(other); }
bool is_valid(void) const { return type() != EDBUS_TYPE_INVALID; }
bool is_byte(void) const { return type() == EDBUS_TYPE_BYTE; }
bool is_char(void) const { return is_byte(); }
bool is_bool(void) const { return type() == EDBUS_TYPE_BOOL; }
bool is_int16(void) const { return type() == EDBUS_TYPE_INT16; }
bool is_uint16(void) const { return type() == EDBUS_TYPE_UINT16; }
bool is_int32(void) const { return type() == EDBUS_TYPE_INT32; }
bool is_uint32(void) const { return type() == EDBUS_TYPE_UINT32; }
bool is_int64(void) const { return type() == EDBUS_TYPE_INT64; }
bool is_uint64(void) const { return type() == EDBUS_TYPE_UINT64; }
bool is_double(void) const { return type() == EDBUS_TYPE_DOUBLE; }
bool is_string(void) const { return type() == EDBUS_TYPE_STRING; }
bool is_object_path(void) const { return type() == EDBUS_TYPE_OBJECT_PATH; }
bool is_array(void) const { return type() == EDBUS_TYPE_ARRAY; }
bool is_struct(void) const { return type() == EDBUS_TYPE_STRUCT; }
bool is_variant(void) const { return type() == EDBUS_TYPE_VARIANT; }
bool is_dict(void) const { return type() == EDBUS_TYPE_DICT; }
static bool basic_type(const EdbusData& val) {
return ((val.type() != EDBUS_TYPE_ARRAY) && (val.type() != EDBUS_TYPE_STRUCT) &&
(val.type() != EDBUS_TYPE_VARIANT) && (val.type() != EDBUS_TYPE_DICT));
}
static EdbusData from_invalid(void) { return EdbusData(); }
static EdbusData from_byte(byte_t val) { return EdbusData((byte_t)val); }
static EdbusData from_char(char val) { return from_byte(val); }
static EdbusData from_bool(bool val) { return EdbusData((bool)val); }
static EdbusData from_int16(int16_t val) { return EdbusData((int16_t)val); }
static EdbusData from_uint16(uint16_t val) { return EdbusData((uint16_t)val); }
static EdbusData from_int32(int32_t val) { return EdbusData((int32_t)val); }
static EdbusData from_uint32(uint32_t val) { return EdbusData((uint32_t)val); }
static EdbusData from_int64(int64_t val) { return EdbusData((int64_t)val); }
static EdbusData from_uint64(uint64_t val) { return EdbusData((uint64_t)val); }
static EdbusData from_double(double val) { return EdbusData((double)val); }
static EdbusData from_string(const char* val) { return EdbusData((const char*)val); }
static EdbusData from_object_path(const EdbusObjectPath& val) { return EdbusData(val); }
static EdbusData from_variant(const EdbusVariant& val) { return EdbusData(val); }
static EdbusData from_dict(const EdbusDict& val) { return EdbusData(val); }
static EdbusData from_array(const EdbusList& val) { return EdbusData(val); }
static EdbusData from_struct(const EdbusList& val) { return EdbusData(val); }
};
struct EdbusVariant {
EdbusData value;
};
EDELIB_NS_END
#endif
edelib::EdbusData::from_char
static EdbusData from_char(char val)
Definition: EdbusData.h:412
edelib::EdbusData::is_variant
bool is_variant(void) const
Definition: EdbusData.h:382
edelib::EdbusData::is_bool
bool is_bool(void) const
Definition: EdbusData.h:322
edelib::EdbusData::from_variant
static EdbusData from_variant(const EdbusVariant &val)
Definition: EdbusData.h:467
edelib::EdbusData
Class for representing D-Bus data types.
Definition: EdbusData.h:110
edelib::EdbusData::is_valid
bool is_valid(void) const
Definition: EdbusData.h:307
edelib::EdbusData::is_array
bool is_array(void) const
Definition: EdbusData.h:372
edelib::EdbusData::from_int32
static EdbusData from_int32(int32_t val)
Definition: EdbusData.h:432
edelib::EdbusData::from_bool
static EdbusData from_bool(bool val)
Definition: EdbusData.h:417
edelib::EdbusData::is_int16
bool is_int16(void) const
Definition: EdbusData.h:327
edelib::EdbusList
A class representing D-Bus struct and array.
Definition: EdbusList.h:114
edelib::EdbusData::from_invalid
static EdbusData from_invalid(void)
Definition: EdbusData.h:402
edelib::EdbusData::is_uint64
bool is_uint64(void) const
Definition: EdbusData.h:352
edelib::EDBUS_TYPE_STRING
string
Definition: EdbusData.h:52
edelib::EDBUS_TYPE_VARIANT
variant
Definition: EdbusData.h:57
edelib::EdbusData::from_string
static EdbusData from_string(const char *val)
Definition: EdbusData.h:457
edelib::EdbusObjectPath
Represents D-Bus object path.
Definition: EdbusObjectPath.h:58
edelib::EDBUS_TYPE_UINT16
unsigned short
Definition: EdbusData.h:46
edelib::EDBUS_TYPE_UINT32
unsigned integer
Definition: EdbusData.h:48
edelib::EdbusData::from_object_path
static EdbusData from_object_path(const EdbusObjectPath &val)
Definition: EdbusData.h:462
edelib::EdbusData::from_array
static EdbusData from_array(const EdbusList &val)
Definition: EdbusData.h:477
edelib::EDBUS_TYPE_UINT64
unsigned long long
Definition: EdbusData.h:50
edelib::EdbusData::from_struct
static EdbusData from_struct(const EdbusList &val)
Definition: EdbusData.h:482
edelib::EdbusData::is_dict
bool is_dict(void) const
Definition: EdbusData.h:387
edelib::EdbusData::type
EdbusDataType type(void) const
edelib::EdbusData::from_double
static EdbusData from_double(double val)
Definition: EdbusData.h:452
edelib::EdbusData::is_double
bool is_double(void) const
Definition: EdbusData.h:357
edelib::EdbusData::is_char
bool is_char(void) const
Definition: EdbusData.h:317
edelib::EdbusData::from_uint64
static EdbusData from_uint64(uint64_t val)
Definition: EdbusData.h:447
edelib::EdbusData::from_int64
static EdbusData from_int64(int64_t val)
Definition: EdbusData.h:442
edelib::EdbusData::is_object_path
bool is_object_path(void) const
Definition: EdbusData.h:367
edelib::EDBUS_TYPE_INT64
long long
Definition: EdbusData.h:49
edelib::EDBUS_TYPE_INT32
integer
Definition: EdbusData.h:47
edelib::EdbusData::from_uint16
static EdbusData from_uint16(uint16_t val)
Definition: EdbusData.h:427
edelib::EdbusData::is_byte
bool is_byte(void) const
Definition: EdbusData.h:312
edelib::EDBUS_TYPE_OBJECT_PATH
EdbusObjectPath type.
Definition: EdbusData.h:53
edelib::EdbusVariant::value
EdbusData value
Definition: EdbusData.h:492
edelib::EDBUS_TYPE_INT16
short
Definition: EdbusData.h:45
edelib::EdbusData::is_int64
bool is_int64(void) const
Definition: EdbusData.h:347
edelib::EdbusData::from_dict
static EdbusData from_dict(const EdbusDict &val)
Definition: EdbusData.h:472
edelib::EdbusData::to_char
char to_char(void) const
Definition: EdbusData.h:216
edelib::EdbusDict
Dictionary container for D-Bus types.
Definition: EdbusDict.h:121
edelib::EDBUS_TYPE_BOOL
bool
Definition: EdbusData.h:44
edelib::EDBUS_TYPE_DOUBLE
double
Definition: EdbusData.h:51
edelib::EdbusData::is_uint32
bool is_uint32(void) const
Definition: EdbusData.h:342
edelib::EdbusData::from_byte
static EdbusData from_byte(byte_t val)
Definition: EdbusData.h:407
edelib::EDBUS_TYPE_STRUCT
structure
Definition: EdbusData.h:55
edelib::EdbusData::is_uint16
bool is_uint16(void) const
Definition: EdbusData.h:332
edelib::EdbusData::is_struct
bool is_struct(void) const
Definition: EdbusData.h:377
edelib::EDBUS_TYPE_BYTE
byte
Definition: EdbusData.h:43
edelib::EDBUS_TYPE_INVALID
Invalid type (empty object)
Definition: EdbusData.h:42
edelib::EdbusData::from_uint32
static EdbusData from_uint32(uint32_t val)
Definition: EdbusData.h:437
edelib::EdbusData::basic_type
static bool basic_type(const EdbusData &val)
Definition: EdbusData.h:394
edelib::EDBUS_TYPE_DICT
dictionary
Definition: EdbusData.h:56
edelib::EdbusData::operator!=
bool operator!=(const EdbusData &other) const
Definition: EdbusData.h:302
edelib::EdbusData::is_int32
bool is_int32(void) const
Definition: EdbusData.h:337
edelib::EdbusVariant
Represents D-Bus variant.
Definition: EdbusData.h:490
edelib::EdbusData::is_string
bool is_string(void) const
Definition: EdbusData.h:362
edelib::EDBUS_TYPE_ARRAY
array
Definition: EdbusData.h:54
edelib::EdbusData::from_int16
static EdbusData from_int16(int16_t val)
Definition: EdbusData.h:422
edelib::EdbusDataType
EdbusDataType
Type of data current EdbusData object holds.
Definition: EdbusData.h:41