-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJSONMessageCdrAux.ipp
More file actions
144 lines (112 loc) · 4.91 KB
/
JSONMessageCdrAux.ipp
File metadata and controls
144 lines (112 loc) · 4.91 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*!
* @file JSONMessageCdrAux.ipp
* This source file contains some declarations of CDR related functions.
*
* This file was generated by the tool fastddsgen.
*/
#ifndef _FAST_DDS_GENERATED_JSONMESSAGECDRAUX_IPP_
#define _FAST_DDS_GENERATED_JSONMESSAGECDRAUX_IPP_
#include "JSONMessageCdrAux.hpp"
#include <fastcdr/Cdr.h>
#include <fastcdr/CdrSizeCalculator.hpp>
#include <fastcdr/exceptions/BadParamException.h>
using namespace eprosima::fastcdr::exception;
namespace eprosima {
namespace fastcdr {
template<>
eProsima_user_DllExport size_t calculate_serialized_size(
eprosima::fastcdr::CdrSizeCalculator& calculator,
const JSONMessage& data,
size_t& current_alignment)
{
static_cast<void>(data);
eprosima::fastcdr::EncodingAlgorithmFlag previous_encoding = calculator.get_encoding();
size_t calculated_size {calculator.begin_calculate_type_serialized_size(
eprosima::fastcdr::CdrVersion::XCDRv2 == calculator.get_cdr_version() ?
eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 :
eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR,
current_alignment)};
calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0),
data.uuid(), current_alignment);
calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1),
data.datetime(), current_alignment);
calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(2),
data.topic(), current_alignment);
calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(3),
data.message(), current_alignment);
calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment);
return calculated_size;
}
template<>
eProsima_user_DllExport void serialize(
eprosima::fastcdr::Cdr& scdr,
const JSONMessage& data)
{
eprosima::fastcdr::Cdr::state current_state(scdr);
scdr.begin_serialize_type(current_state,
eprosima::fastcdr::CdrVersion::XCDRv2 == scdr.get_cdr_version() ?
eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 :
eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR);
scdr
<< eprosima::fastcdr::MemberId(0) << data.uuid()
<< eprosima::fastcdr::MemberId(1) << data.datetime()
<< eprosima::fastcdr::MemberId(2) << data.topic()
<< eprosima::fastcdr::MemberId(3) << data.message()
;
scdr.end_serialize_type(current_state);
}
template<>
eProsima_user_DllExport void deserialize(
eprosima::fastcdr::Cdr& cdr,
JSONMessage& data)
{
cdr.deserialize_type(eprosima::fastcdr::CdrVersion::XCDRv2 == cdr.get_cdr_version() ?
eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 :
eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR,
[&data](eprosima::fastcdr::Cdr& dcdr, const eprosima::fastcdr::MemberId& mid) -> bool
{
bool ret_value = true;
switch (mid.id)
{
case 0:
dcdr >> data.uuid();
break;
case 1:
dcdr >> data.datetime();
break;
case 2:
dcdr >> data.topic();
break;
case 3:
dcdr >> data.message();
break;
default:
ret_value = false;
break;
}
return ret_value;
});
}
void serialize_key(
eprosima::fastcdr::Cdr& scdr,
const JSONMessage& data)
{
static_cast<void>(scdr);
static_cast<void>(data);
}
} // namespace fastcdr
} // namespace eprosima
#endif // _FAST_DDS_GENERATED_JSONMESSAGECDRAUX_IPP_