1 #ifndef DBUS_ELEMENT_HPP 2 #define DBUS_ELEMENT_HPP 3 4 #include <dbus/dbus.h> 5 #include <string> 6 7 namespace dbus { 8 9 /// Message elements 10 /** 11 * D-Bus Messages are composed of simple elements of one of these types 12 */ 13 typedef std::string string; 14 typedef dbus_int32_t int32; 15 typedef dbus_uint32_t uint32; 16 //TODO: add more types... 17 18 /// Traits template for message elements 19 /** 20 * D-Bus Message elements are identified by unique integer type codes. 21 */ 22 template<typename InvalidType=void> struct element 23 { 24 static const int code = DBUS_TYPE_INVALID; 25 }; 26 27 template<> struct element< int32 > 28 { 29 static const int code = DBUS_TYPE_INT32; 30 }; 31 32 template<> struct element< uint32 > 33 { 34 static const int code = DBUS_TYPE_UINT32; 35 }; 36 37 template<> struct element< string > 38 { 39 static const int code = DBUS_TYPE_STRING; 40 }; 41 42 /// Convenience overloads 43 template<> struct element< char * > 44 { 45 static const int code = DBUS_TYPE_STRING; 46 }; 47 template<> struct element< const char * > 48 { 49 static const int code = DBUS_TYPE_STRING; 50 }; 51 52 } // namespace dbus 53 54 55 #endif // DBUS_ELEMENT_HPP 56