1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include <common-api-dbus/dbus-message.h>
9 #include "TestDBusSerializableStruct.h"
12 #define COMMON_API_TEST_TEST_STRUCT_SIGNATURE "(ud)"
13 #define COMMON_API_TEST_TEST_STRUCT_ARRAY_SIGNATURE "a" COMMON_API_TEST_TEST_STRUCT_SIGNATURE
15 #define COMMON_API_TEST_TEST_STRUCT_EXTENDED_SIGNATURE "(uds)"
16 #define COMMON_API_TEST_TEST_STRUCT_EXTENDED_ARRAY_SIGNATURE "a" COMMON_API_TEST_TEST_STRUCT_EXTENDED_SIGNATURE
24 TestStruct::TestStruct(const uint32_t& fromIntValue, const double& fromDoubleValue):
25 intValue(fromIntValue),
26 doubleValue(fromDoubleValue) {
29 common::api::dbus::DBusInputMessageStream& TestStruct::readFromDBusInputMessageStream(
30 common::api::dbus::DBusInputMessageStream& inputMessageStream) {
31 return inputMessageStream >> intValue
35 common::api::dbus::DBusOutputMessageStream& TestStruct::writeToDBusOutputMessageStream(
36 common::api::dbus::DBusOutputMessageStream& outputMessageStream) const {
37 return outputMessageStream << intValue
42 TestStructExtended::TestStructExtended(const uint32_t& fromIntValue, const double& fromDoubleValue, const std::string& fromStringValue):
43 TestStruct(fromIntValue, fromDoubleValue),
44 stringValue(fromStringValue) {
47 common::api::dbus::DBusInputMessageStream& TestStructExtended::readFromDBusInputMessageStream(
48 common::api::dbus::DBusInputMessageStream& inputMessageStream) {
49 return TestStruct::readFromDBusInputMessageStream(inputMessageStream) >> stringValue;
52 common::api::dbus::DBusOutputMessageStream& TestStructExtended::writeToDBusOutputMessageStream(
53 common::api::dbus::DBusOutputMessageStream& outputMessageStream) const {
54 return TestStruct::writeToDBusOutputMessageStream(outputMessageStream) << stringValue;
63 using namespace common::api::test;
65 TestStructExtended testStructExtended(123, 456.789, "TestStructExtended");
67 common::api::dbus::DBusMessage message = common::api::dbus::DBusMessage::createMethodCall(
68 "com.bmw.test.TestStruct",
69 "/com/bmw/test/TestStruct",
70 "com.bmw.test.TestStruct",
72 COMMON_API_TEST_TEST_STRUCT_EXTENDED_SIGNATURE);
74 common::api::dbus::DBusOutputMessageStream outStream(message);
75 outStream << testStructExtended;