summaryrefslogtreecommitdiff
path: root/src/test/commonapi/tests/DerivedTypeCollection.cpp
blob: 1ad1cceff13d6c62453c33856378df3a14d3fda3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "DerivedTypeCollection.h"

namespace commonapi {
namespace tests {
namespace DerivedTypeCollection {

TestStructExtended::TestStructExtended(const PredefinedTypeCollection::TestString& testStringValue, const uint16_t& uintValueValue, const TestEnumExtended2& testEnumExtended2Value, const PredefinedTypeCollection::WeirdStrangeAlienEnum& alienEnumValue):
        TestStruct(testStringValue, uintValueValue),
        testEnumExtended2(testEnumExtended2Value),
        alienEnum(alienEnumValue)
{
}

bool operator==(const TestStructExtended& lhs, const TestStructExtended& rhs) {
    if (&lhs == &rhs)
        return true;

    return
        static_cast<TestStructExtended::TestStruct>(lhs) == static_cast<TestStructExtended::TestStruct>(rhs) &&
        lhs.testEnumExtended2 == rhs.testEnumExtended2 &&
        lhs.alienEnum == rhs.alienEnum
    ;
}

void TestStructExtended::readFromInputStream(CommonAPI::InputStream& inputStream) {
    TestStruct::readFromInputStream(inputStream);
    inputStream >> testEnumExtended2;
    inputStream >> alienEnum;
}

void TestStructExtended::writeToOutputStream(CommonAPI::OutputStream& outputStream) const {
    TestStruct::writeToOutputStream(outputStream);
    outputStream << testEnumExtended2;
    outputStream << alienEnum;
}
TestStruct::TestStruct(const PredefinedTypeCollection::TestString& testStringValue, const uint16_t& uintValueValue):
        testString(testStringValue),
        uintValue(uintValueValue)
{
}

bool operator==(const TestStruct& lhs, const TestStruct& rhs) {
    if (&lhs == &rhs)
        return true;

    return
        lhs.testString == rhs.testString &&
        lhs.uintValue == rhs.uintValue
    ;
}

void TestStruct::readFromInputStream(CommonAPI::InputStream& inputStream) {
    inputStream >> testString;
    inputStream >> uintValue;
}

void TestStruct::writeToOutputStream(CommonAPI::OutputStream& outputStream) const {
    outputStream << testString;
    outputStream << uintValue;
}

} // namespace DerivedTypeCollection
} // namespace tests
} // namespace commonapi