summaryrefslogtreecommitdiff
path: root/src/bindings/cxx/eldbus_cxx/eldbus_message_arguments.hh
diff options
context:
space:
mode:
authorFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2016-05-23 12:01:30 -0300
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2016-05-23 15:05:50 -0300
commite3c8b280c639058c54f5576f189d0dc288105fc7 (patch)
treee313fa05bd9d2b2cb88623f6adea2c3b396b66e8 /src/bindings/cxx/eldbus_cxx/eldbus_message_arguments.hh
parent930f39b91b12b311f40cd96b4cf2e85085b01832 (diff)
c++: Reorganized C++ binding generation
Moved all generation to a single Makefile_Cxx.am file instead of throughout the whole project. And fixed C++ generation on Elementary after elm merge.
Diffstat (limited to 'src/bindings/cxx/eldbus_cxx/eldbus_message_arguments.hh')
-rw-r--r--src/bindings/cxx/eldbus_cxx/eldbus_message_arguments.hh56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/bindings/cxx/eldbus_cxx/eldbus_message_arguments.hh b/src/bindings/cxx/eldbus_cxx/eldbus_message_arguments.hh
new file mode 100644
index 0000000000..6c57b0216b
--- /dev/null
+++ b/src/bindings/cxx/eldbus_cxx/eldbus_message_arguments.hh
@@ -0,0 +1,56 @@
1#ifndef ELDBUS_CXX_ELDBUS_MESSAGE_ARGUMENTS_HH
2#define ELDBUS_CXX_ELDBUS_MESSAGE_ARGUMENTS_HH
3
4#include <Eldbus.h>
5
6#include <tuple>
7#include <iostream>
8
9namespace efl { namespace eldbus { namespace _detail {
10
11template <std::size_t I, typename Seq, typename Tuple>
12bool _init_raw_tuple(Eldbus_Message_Iter*, Tuple const&, std::true_type)
13{
14 return true;
15}
16
17template <std::size_t I, typename Seq, typename Tuple>
18bool _init_raw_tuple(Eldbus_Message_Iter* iterator, Tuple const& tuple, std::false_type)
19{
20 typedef signature_traits<typename std::tuple_element<I, Seq>::type> traits;
21 typedef typename traits::value_type element_type;
22
23 char* c = eldbus_message_iter_signature_get(iterator);
24 if(c[0] != signature_traits<element_type>::sig)
25 {
26 return false;
27 }
28
29 eldbus_message_iter_get_and_next(iterator, *c, &std::get<I>(tuple));
30
31 return _init_raw_tuple<I+1, Seq>
32 (iterator, tuple, std::integral_constant<bool, (I+1 == std::tuple_size<Tuple>::value)>());
33}
34
35template <std::size_t I, typename Tuple>
36bool _append_tuple(Eldbus_Message*, Tuple const&, std::true_type)
37{
38 return true;
39}
40
41template <std::size_t I, typename Tuple>
42bool _append_tuple(Eldbus_Message* message, Tuple const& tuple, std::false_type)
43{
44 typedef signature_traits<typename std::tuple_element<I, Tuple>::type> traits;
45
46 char signature[2] = {traits::sig, 0};
47 if(!eldbus_message_arguments_append(message, signature, traits::to_raw(std::get<I>(tuple))))
48 return false;
49
50 return _append_tuple<I+1>
51 (message, tuple, std::integral_constant<bool, (I+1 == std::tuple_size<Tuple>::value)>());
52}
53
54} } }
55
56#endif