4a8459ed940943e80d91dde0dedad158454c5624
[iec.git] / src / type3_AndroidCloud / anbox-master / src / anbox / dbus / codecs.h
1 /*
2  * Copyright (C) 2017 Simon Fels <morphis@gravedo.de>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation; version 3.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
15  *
16  */
17
18 #ifndef ANBOX_DBUS_CODECS_H_
19 #define ANBOX_DBUS_CODECS_H_
20
21 #include "anbox/wm/stack.h"
22
23 #include <core/dbus/codec.h>
24
25 #include <sstream>
26
27 namespace core {
28 namespace dbus {
29 template<>
30 struct Codec<anbox::wm::Stack::Id> {
31   inline static void encode_argument(Message::Writer &out, const anbox::wm::Stack::Id &stack) {
32     std::stringstream ss;
33     ss << stack;
34     auto s = ss.str();
35     out.push_stringn(s.c_str(), s.length());
36   }
37
38   inline static void decode_argument(Message::Reader &in, anbox::wm::Stack::Id &stack) {
39     std::stringstream ss;
40     ss << in.pop_string();
41     ss >> stack;
42   }
43 };
44 } // namespace dbus
45 } // namespace core
46
47 #endif