xref: /openbmc/boost-dbus/include/dbus/element.hpp (revision a83e5951)
1 // Copyright (c) Benjamin Kietzman (github.com/bkietz)
2 //
3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5 
6 #ifndef DBUS_ELEMENT_HPP
7 #define DBUS_ELEMENT_HPP
8 
9 #include <dbus/dbus.h>
10 #include <string>
11 
12 namespace dbus {
13 
14 /// Message elements
15 /**
16  * D-Bus Messages are composed of simple elements of one of these types
17  */
18 typedef std::string   string;
19 typedef dbus_int32_t  int32;
20 typedef dbus_uint32_t uint32;
21 //TODO: add more types...
22 
23 /// Traits template for message elements
24 /**
25  * D-Bus Message elements are identified by unique integer type codes.
26  */
27 template<typename InvalidType=void> struct element
28 {
29   static const int code = DBUS_TYPE_INVALID;
30 };
31 
32 template<> struct element< int32 >
33 {
34   static const int code = DBUS_TYPE_INT32;
35 };
36 
37 template<> struct element< uint32 >
38 {
39   static const int code = DBUS_TYPE_UINT32;
40 };
41 
42 template<> struct element< string >
43 {
44   static const int code = DBUS_TYPE_STRING;
45 };
46 
47 /// Convenience overloads
48 template<> struct element< char * >
49 {
50   static const int code = DBUS_TYPE_STRING;
51 };
52 template<> struct element< const char * >
53 {
54   static const int code = DBUS_TYPE_STRING;
55 };
56 
57 } // namespace dbus
58 
59 
60 #endif // DBUS_ELEMENT_HPP
61