GCC Code Coverage Report


Directory: ./
File: Serializable.cpp
Date: 2026-09-03 22:13:07
Exec Total Coverage
Lines: 321 562 57.1%
Functions: 48 98 49.0%
Branches: 77 164 47.0%

Line Branch Exec Source
1 #include <Fw/FPrimeBasicTypes.hpp>
2 #include <Fw/Types/Assert.hpp>
3 #include <Fw/Types/Serializable.hpp>
4 #include <Fw/Types/StringType.hpp>
5 #include <cstdio>
6 #include <cstring> // memcpy
7 #ifdef BUILD_UT
8 #include <Fw/Types/String.hpp>
9 #include <iomanip>
10 #endif
11
12 namespace Fw {
13
14 92918 Serializable::Serializable() {}
15
16 185920 Serializable::~Serializable() {}
17
18 // ----------------------------------------------------------------------
19 #if FW_SERIALIZABLE_TO_STRING || FW_ENABLE_TEXT_LOGGING || BUILD_UT
20
21 void Serializable::toString(StringBase& text) const {
22 text = "NOSPEC"; // set to not specified.
23 }
24
25 #endif
26
27 #ifdef BUILD_UT
28 std::ostream& operator<<(std::ostream& os, const Serializable& val) {
29 Fw::String out;
30 val.toString(out);
31
32 os << out;
33
34 return os;
35 }
36 #endif
37
38 80042 SerialBufferBase::~SerialBufferBase() {}
39
40 40018 LinearBufferBase::LinearBufferBase(U8* buffAddr, Serializable::SizeType capacity)
41 40018 : m_buffAddr(buffAddr), m_capacity(capacity), m_serLoc(0), m_deserLoc(0) {
42 // Ensure buffAddr & capacity are consistent
43 40000 FW_ASSERT((buffAddr == nullptr) == (capacity == 0), static_cast<FwAssertArgType>(capacity));
44 40000 }
45
46 80036 LinearBufferBase::~LinearBufferBase() {}
47
48 void LinearBufferBase::copyFrom(const LinearBufferBase& src) {
49 this->m_serLoc = src.m_serLoc;
50 this->m_deserLoc = src.m_deserLoc;
51 const U8* srcBuffAddr = src.m_buffAddr;
52 U8* thisBuffAddr = this->m_buffAddr;
53 FW_ASSERT(srcBuffAddr != nullptr);
54 FW_ASSERT(thisBuffAddr != nullptr);
55 // destination has to be same or bigger
56 FW_ASSERT(src.m_serLoc <= this->m_capacity, static_cast<FwAssertArgType>(src.m_serLoc),
57 static_cast<FwAssertArgType>(this->m_capacity));
58 (void)memcpy(thisBuffAddr, srcBuffAddr, static_cast<size_t>(this->m_serLoc));
59 }
60
61 // Copy constructor doesn't make sense in this virtual class as there is nothing to copy. Derived classes should
62 // call the empty constructor and then call their own copy function
63 LinearBufferBase& LinearBufferBase::operator=(const LinearBufferBase& src) { // lgtm[cpp/rule-of-two]
64 this->copyFrom(src);
65 return *this;
66 }
67
68 // serialization routines
69
70 165267 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::serializeFrom(U8 val, Endianness mode) {
71
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 165267 times.
165267 if (this->m_serLoc + static_cast<Serializable::SizeType>(sizeof(val)) - 1 >= this->m_capacity) {
72 return FW_SERIALIZE_NO_ROOM_LEFT;
73 }
74 165267 U8* buffAddr = this->m_buffAddr;
75 165267 FW_ASSERT(buffAddr != nullptr);
76 165270 buffAddr[this->m_serLoc] = val;
77 165270 this->m_serLoc += static_cast<Serializable::SizeType>(sizeof(val));
78 165270 this->m_deserLoc = 0;
79
80 165270 return FW_SERIALIZE_OK;
81 }
82
83 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::serializeFrom(I8 val, Endianness mode) {
84 return serializeFrom(static_cast<U8>(val), mode);
85 }
86
87 #if FW_HAS_16_BIT == 1
88 19555 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::serializeFrom(U16 val, Endianness mode) {
89
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19555 times.
19555 if (this->m_serLoc + static_cast<Serializable::SizeType>(sizeof(val)) - 1 >= this->m_capacity) {
90 return FW_SERIALIZE_NO_ROOM_LEFT;
91 }
92 19555 U8* buffAddr = this->m_buffAddr;
93 19555 FW_ASSERT(buffAddr != nullptr);
94
1/3
✓ Branch 0 taken 19558 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
19558 switch (mode) {
95 19558 case Endianness::BIG:
96 // MSB first
97 19558 buffAddr[this->m_serLoc + 0] = static_cast<U8>(val >> 8);
98 19558 buffAddr[this->m_serLoc + 1] = static_cast<U8>(val);
99 19558 break;
100 case Endianness::LITTLE:
101 // LSB first
102 buffAddr[this->m_serLoc + 0] = static_cast<U8>(val);
103 buffAddr[this->m_serLoc + 1] = static_cast<U8>(val >> 8);
104 break;
105 default:
106 FW_ASSERT(false);
107 break;
108 }
109 19558 this->m_serLoc += static_cast<Serializable::SizeType>(sizeof(val));
110 19558 this->m_deserLoc = 0;
111 19558 return FW_SERIALIZE_OK;
112 }
113
114 7593 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::serializeFrom(I16 val, Endianness mode) {
115 7593 return serializeFrom(static_cast<U16>(val), mode);
116 }
117 #endif
118 #if FW_HAS_32_BIT == 1
119 29616 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::serializeFrom(U32 val, Endianness mode) {
120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29616 times.
29616 if (this->m_serLoc + static_cast<Serializable::SizeType>(sizeof(val)) - 1 >= this->m_capacity) {
121 return FW_SERIALIZE_NO_ROOM_LEFT;
122 }
123 29616 U8* buffAddr = this->m_buffAddr;
124 29616 FW_ASSERT(buffAddr != nullptr);
125
1/3
✓ Branch 0 taken 29613 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
29613 switch (mode) {
126 29613 case Endianness::BIG:
127 // MSB first
128 29613 buffAddr[this->m_serLoc + 0] = static_cast<U8>(val >> 24);
129 29613 buffAddr[this->m_serLoc + 1] = static_cast<U8>(val >> 16);
130 29613 buffAddr[this->m_serLoc + 2] = static_cast<U8>(val >> 8);
131 29613 buffAddr[this->m_serLoc + 3] = static_cast<U8>(val);
132 29613 break;
133 case Endianness::LITTLE:
134 // LSB first
135 buffAddr[this->m_serLoc + 0] = static_cast<U8>(val);
136 buffAddr[this->m_serLoc + 1] = static_cast<U8>(val >> 8);
137 buffAddr[this->m_serLoc + 2] = static_cast<U8>(val >> 16);
138 buffAddr[this->m_serLoc + 3] = static_cast<U8>(val >> 24);
139 break;
140 default:
141 FW_ASSERT(false);
142 break;
143 }
144 29613 this->m_serLoc += static_cast<Serializable::SizeType>(sizeof(val));
145 29613 this->m_deserLoc = 0;
146 29613 return FW_SERIALIZE_OK;
147 }
148
149 9717 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::serializeFrom(I32 val, Endianness mode) {
150 9717 return serializeFrom(static_cast<U32>(val), mode);
151 }
152 #endif
153
154 #if FW_HAS_64_BIT == 1
155 3682 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::serializeFrom(U64 val, Endianness mode) {
156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3682 times.
3682 if (this->m_serLoc + static_cast<Serializable::SizeType>(sizeof(val)) - 1 >= this->m_capacity) {
157 return FW_SERIALIZE_NO_ROOM_LEFT;
158 }
159 3682 U8* buffAddr = this->m_buffAddr;
160 3682 FW_ASSERT(buffAddr != nullptr);
161
1/3
✓ Branch 0 taken 3682 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
3682 switch (mode) {
162 3682 case Endianness::BIG:
163 // MSB first
164 3682 buffAddr[this->m_serLoc + 0] = static_cast<U8>(val >> 56);
165 3682 buffAddr[this->m_serLoc + 1] = static_cast<U8>(val >> 48);
166 3682 buffAddr[this->m_serLoc + 2] = static_cast<U8>(val >> 40);
167 3682 buffAddr[this->m_serLoc + 3] = static_cast<U8>(val >> 32);
168 3682 buffAddr[this->m_serLoc + 4] = static_cast<U8>(val >> 24);
169 3682 buffAddr[this->m_serLoc + 5] = static_cast<U8>(val >> 16);
170 3682 buffAddr[this->m_serLoc + 6] = static_cast<U8>(val >> 8);
171 3682 buffAddr[this->m_serLoc + 7] = static_cast<U8>(val);
172 3682 break;
173 case Endianness::LITTLE:
174 // LSB first
175 buffAddr[this->m_serLoc + 0] = static_cast<U8>(val);
176 buffAddr[this->m_serLoc + 1] = static_cast<U8>(val >> 8);
177 buffAddr[this->m_serLoc + 2] = static_cast<U8>(val >> 16);
178 buffAddr[this->m_serLoc + 3] = static_cast<U8>(val >> 24);
179 buffAddr[this->m_serLoc + 4] = static_cast<U8>(val >> 32);
180 buffAddr[this->m_serLoc + 5] = static_cast<U8>(val >> 40);
181 buffAddr[this->m_serLoc + 6] = static_cast<U8>(val >> 48);
182 buffAddr[this->m_serLoc + 7] = static_cast<U8>(val >> 56);
183 break;
184 default:
185 FW_ASSERT(false);
186 break;
187 }
188 3682 this->m_serLoc += static_cast<Serializable::SizeType>(sizeof(val));
189 3682 this->m_deserLoc = 0;
190 3682 return FW_SERIALIZE_OK;
191 }
192
193 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::serializeFrom(I64 val, Endianness mode) {
194 return serializeFrom(static_cast<U64>(val), mode);
195 }
196 #endif
197
198 2 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::serializeFrom(F64 val, Endianness mode) {
199 // floating point values need to be byte-swapped as well, so copy to U64 and use that routine
200 U64 u64Val;
201 2 (void)memcpy(&u64Val, &val, sizeof(val));
202
1/1
✓ Branch 1 taken 2 times.
4 return this->serializeFrom(u64Val, mode);
203 }
204
205 1221 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::serializeFrom(F32 val, Endianness mode) {
206 // floating point values need to be byte-swapped as well, so copy to U32 and use that routine
207 U32 u32Val;
208 1221 (void)memcpy(&u32Val, &val, sizeof(val));
209
1/1
✓ Branch 1 taken 1221 times.
2442 return this->serializeFrom(u32Val, mode);
210 }
211
212 1348 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::serializeFrom(bool val, Endianness mode) {
213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1348 times.
1348 if (this->m_serLoc + static_cast<Serializable::SizeType>(sizeof(U8)) - 1 >= this->m_capacity) {
214 return FW_SERIALIZE_NO_ROOM_LEFT;
215 }
216
217 1348 U8* buffAddr = this->m_buffAddr;
218 1348 FW_ASSERT(buffAddr != nullptr);
219
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1342 times.
1348 if (val) {
220 6 buffAddr[this->m_serLoc + 0] = FW_SERIALIZE_TRUE_VALUE;
221 } else {
222 1342 buffAddr[this->m_serLoc + 0] = FW_SERIALIZE_FALSE_VALUE;
223 }
224
225 1348 this->m_serLoc += static_cast<Serializable::SizeType>(sizeof(U8));
226 1348 this->m_deserLoc = 0;
227 1348 return FW_SERIALIZE_OK;
228 }
229
230 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::serializeFrom(const void* val, Endianness mode) {
231 if (this->m_serLoc + static_cast<Serializable::SizeType>(sizeof(void*)) - 1 >= this->m_capacity) {
232 return FW_SERIALIZE_NO_ROOM_LEFT;
233 }
234
235 return this->serializeFrom(reinterpret_cast<PlatformPointerCastType>(val), mode);
236 }
237
238 70 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::serializeFrom(const U8* buff,
239 Serializable::SizeType length,
240 Endianness endianMode) {
241 70 return this->serializeFrom(buff, static_cast<FwSizeType>(length), Serialization::INCLUDE_LENGTH, endianMode);
242 }
243
244 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus
245 4990 LinearBufferBase::serializeFrom(const U8* buff,
246 FwSizeType length,
247 Serialization::t lengthMode,
248 Endianness endianMode) { // First serialize length
249 SerializeStatus stat;
250
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 4884 times.
4990 if (lengthMode == Serialization::INCLUDE_LENGTH) {
251 106 stat = this->serializeFrom(static_cast<FwSizeStoreType>(length), endianMode);
252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106 times.
106 if (stat != FW_SERIALIZE_OK) {
253 return stat;
254 }
255 }
256
257 // make sure we have enough space
258
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4990 times.
4990 if (this->m_serLoc + length > this->m_capacity) {
259 return FW_SERIALIZE_NO_ROOM_LEFT;
260 }
261
262
2/2
✓ Branch 0 taken 4883 times.
✓ Branch 1 taken 107 times.
4990 if (length > 0) {
263 4883 FW_ASSERT(buff != nullptr);
264 }
265 4990 U8* buffAddr = this->m_buffAddr;
266 4990 FW_ASSERT(buffAddr != nullptr);
267 // copy buffer to our buffer; memmove is used because the source may overlap this buffer
268 4990 (void)memmove(&buffAddr[this->m_serLoc], buff, static_cast<size_t>(length));
269 4990 this->m_serLoc += static_cast<Serializable::SizeType>(length);
270 4990 this->m_deserLoc = 0;
271
272 4990 return FW_SERIALIZE_OK;
273 }
274
275 14920 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::serializeFrom(const Serializable& val,
276 Endianness mode) {
277 14920 return val.serializeTo(*this, mode);
278 }
279
280 2042 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::serializeFrom(const LinearBufferBase& val,
281 Endianness mode) {
282 2042 Serializable::SizeType size = val.getSize();
283
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2042 times.
2042 if (this->m_serLoc + size + static_cast<Serializable::SizeType>(sizeof(FwSizeStoreType)) > this->m_capacity) {
284 return FW_SERIALIZE_NO_ROOM_LEFT;
285 }
286
287 // First, serialize size
288 2042 SerializeStatus stat = this->serializeFrom(static_cast<FwSizeStoreType>(size), mode);
289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2041 times.
2041 if (stat != FW_SERIALIZE_OK) {
290 return stat;
291 }
292
293 2041 U8* thisBuffAddr = this->m_buffAddr;
294 2041 const U8* valBuffAddr = val.getBuffAddr();
295 2041 FW_ASSERT(thisBuffAddr != nullptr);
296 2041 FW_ASSERT(valBuffAddr != nullptr);
297 // serialize buffer
298 2040 (void)memcpy(&thisBuffAddr[this->m_serLoc], valBuffAddr, static_cast<size_t>(size));
299 2040 this->m_serLoc += size;
300 2040 this->m_deserLoc = 0;
301
302 2040 return FW_SERIALIZE_OK;
303 }
304
305 8 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::serializeSize(const FwSizeType size, Endianness mode) {
306 8 SerializeStatus status = FW_SERIALIZE_OK;
307
3/6
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 8 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 8 times.
8 if ((size < std::numeric_limits<FwSizeStoreType>::min()) || (size > std::numeric_limits<FwSizeStoreType>::max())) {
308 status = FW_SERIALIZE_FORMAT_ERROR;
309 }
310
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if (status == FW_SERIALIZE_OK) {
311 8 status = this->serializeFrom(static_cast<FwSizeStoreType>(size), mode);
312 }
313 8 return status;
314 }
315
316 // deserialization routines
317
318 9922 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::deserializeTo(U8& val, Endianness mode) {
319 // check for room
320 9922 const Serializable::SizeType size = this->m_serLoc;
321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9922 times.
9922 if (size == this->m_deserLoc) {
322 return FW_DESERIALIZE_BUFFER_EMPTY;
323
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9922 times.
9922 } else if (size - this->m_deserLoc < static_cast<Serializable::SizeType>(sizeof(val))) {
324 return FW_DESERIALIZE_SIZE_MISMATCH;
325 }
326 // read from current location
327 9922 U8* buffAddr = this->m_buffAddr;
328 9922 FW_ASSERT(buffAddr != nullptr);
329 9922 val = buffAddr[this->m_deserLoc + 0];
330 9922 this->m_deserLoc += static_cast<Serializable::SizeType>(sizeof(val));
331 9922 return FW_SERIALIZE_OK;
332 }
333
334 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::deserializeTo(I8& val, Endianness mode) {
335 // check for room
336 const Serializable::SizeType size = this->m_serLoc;
337 if (size == this->m_deserLoc) {
338 return FW_DESERIALIZE_BUFFER_EMPTY;
339 } else if (size - this->m_deserLoc < static_cast<Serializable::SizeType>(sizeof(val))) {
340 return FW_DESERIALIZE_SIZE_MISMATCH;
341 }
342 // read from current location
343 U8* buffAddr = this->m_buffAddr;
344 FW_ASSERT(buffAddr != nullptr);
345 val = static_cast<I8>(buffAddr[this->m_deserLoc + 0]);
346 this->m_deserLoc += static_cast<Serializable::SizeType>(sizeof(val));
347 return FW_SERIALIZE_OK;
348 }
349
350 #if FW_HAS_16_BIT == 1
351 25392 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::deserializeTo(U16& val, Endianness mode) {
352 // check for room
353 25392 const Serializable::SizeType size = this->m_serLoc;
354
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25392 times.
25392 if (size == this->m_deserLoc) {
355 return FW_DESERIALIZE_BUFFER_EMPTY;
356
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25392 times.
25392 } else if (size - this->m_deserLoc < static_cast<Serializable::SizeType>(sizeof(val))) {
357 return FW_DESERIALIZE_SIZE_MISMATCH;
358 }
359 // read from current location
360 25392 U8* buffAddr = this->m_buffAddr;
361 25392 FW_ASSERT(buffAddr != nullptr);
362
1/3
✓ Branch 0 taken 25454 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
25454 switch (mode) {
363 25454 case Endianness::BIG:
364 // MSB first
365 25454 val = static_cast<U16>(((buffAddr[this->m_deserLoc + 1]) << 0) | ((buffAddr[this->m_deserLoc + 0]) << 8));
366 25454 break;
367 case Endianness::LITTLE:
368 // LSB first
369 val = static_cast<U16>(((buffAddr[this->m_deserLoc + 0]) << 0) | ((buffAddr[this->m_deserLoc + 1]) << 8));
370 break;
371 default:
372 FW_ASSERT(false);
373 break;
374 }
375 25454 this->m_deserLoc += static_cast<Serializable::SizeType>(sizeof(val));
376 25454 return FW_SERIALIZE_OK;
377 }
378
379 7482 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::deserializeTo(I16& val, Endianness mode) {
380 7482 U16 unsignVal = 0;
381
1/1
✓ Branch 1 taken 7569 times.
7482 SerializeStatus res = deserializeTo(unsignVal, mode);
382
1/2
✓ Branch 0 taken 7570 times.
✗ Branch 1 not taken.
7569 if (res == SerializeStatus::FW_SERIALIZE_OK) {
383 7570 val = static_cast<I16>(unsignVal);
384 }
385 7569 return res;
386 }
387 #endif
388 #if FW_HAS_32_BIT == 1
389 16582 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::deserializeTo(U32& val, Endianness mode) {
390 // check for room
391 16582 const Serializable::SizeType size = this->m_serLoc;
392
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16582 times.
16582 if (size == this->m_deserLoc) {
393 return FW_DESERIALIZE_BUFFER_EMPTY;
394
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16582 times.
16582 } else if (size - this->m_deserLoc < static_cast<Serializable::SizeType>(sizeof(val))) {
395 return FW_DESERIALIZE_SIZE_MISMATCH;
396 }
397 // read from current location
398 16582 U8* buffAddr = this->m_buffAddr;
399 16582 FW_ASSERT(buffAddr != nullptr);
400
1/3
✓ Branch 0 taken 16590 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
16590 switch (mode) {
401 16590 case Endianness::BIG:
402 // MSB first
403 16590 val = (static_cast<U32>(buffAddr[this->m_deserLoc + 3]) << 0) |
404 16590 (static_cast<U32>(buffAddr[this->m_deserLoc + 2]) << 8) |
405 16590 (static_cast<U32>(buffAddr[this->m_deserLoc + 1]) << 16) |
406 16590 (static_cast<U32>(buffAddr[this->m_deserLoc + 0]) << 24);
407 16590 break;
408 case Endianness::LITTLE:
409 // LSB first
410 val = (static_cast<U32>(buffAddr[this->m_deserLoc + 0]) << 0) |
411 (static_cast<U32>(buffAddr[this->m_deserLoc + 1]) << 8) |
412 (static_cast<U32>(buffAddr[this->m_deserLoc + 2]) << 16) |
413 (static_cast<U32>(buffAddr[this->m_deserLoc + 3]) << 24);
414 break;
415 default:
416 FW_ASSERT(false);
417 break;
418 }
419 16590 this->m_deserLoc += static_cast<Serializable::SizeType>(sizeof(val));
420 16590 return FW_SERIALIZE_OK;
421 }
422
423 9169 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::deserializeTo(I32& val, Endianness mode) {
424 9169 U32 unsignVal = 0;
425
1/1
✓ Branch 1 taken 9174 times.
9169 SerializeStatus res = deserializeTo(unsignVal, mode);
426
1/2
✓ Branch 0 taken 9188 times.
✗ Branch 1 not taken.
9174 if (res == SerializeStatus::FW_SERIALIZE_OK) {
427 9188 val = static_cast<I32>(unsignVal);
428 }
429 9174 return res;
430 }
431 #endif
432
433 #if FW_HAS_64_BIT == 1
434
435 2730 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::deserializeTo(U64& val, Endianness mode) {
436 // check for room
437
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2730 times.
2730 if (this->m_serLoc == this->m_deserLoc) {
438 return FW_DESERIALIZE_BUFFER_EMPTY;
439
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2730 times.
2730 } else if (this->m_serLoc - this->m_deserLoc < static_cast<Serializable::SizeType>(sizeof(val))) {
440 return FW_DESERIALIZE_SIZE_MISMATCH;
441 }
442 // read from current location
443 2730 U8* buffAddr = this->m_buffAddr;
444 2730 FW_ASSERT(buffAddr != nullptr);
445
1/3
✓ Branch 0 taken 2730 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
2730 switch (mode) {
446 2730 case Endianness::BIG:
447 // MSB first
448 2730 val = (static_cast<U64>(buffAddr[this->m_deserLoc + 7]) << 0) |
449 2730 (static_cast<U64>(buffAddr[this->m_deserLoc + 6]) << 8) |
450 2730 (static_cast<U64>(buffAddr[this->m_deserLoc + 5]) << 16) |
451 2730 (static_cast<U64>(buffAddr[this->m_deserLoc + 4]) << 24) |
452 2730 (static_cast<U64>(buffAddr[this->m_deserLoc + 3]) << 32) |
453 2730 (static_cast<U64>(buffAddr[this->m_deserLoc + 2]) << 40) |
454 2730 (static_cast<U64>(buffAddr[this->m_deserLoc + 1]) << 48) |
455 2730 (static_cast<U64>(buffAddr[this->m_deserLoc + 0]) << 56);
456 2730 break;
457 case Endianness::LITTLE:
458 // LSB first
459 val = (static_cast<U64>(buffAddr[this->m_deserLoc + 0]) << 0) |
460 (static_cast<U64>(buffAddr[this->m_deserLoc + 1]) << 8) |
461 (static_cast<U64>(buffAddr[this->m_deserLoc + 2]) << 16) |
462 (static_cast<U64>(buffAddr[this->m_deserLoc + 3]) << 24) |
463 (static_cast<U64>(buffAddr[this->m_deserLoc + 4]) << 32) |
464 (static_cast<U64>(buffAddr[this->m_deserLoc + 5]) << 40) |
465 (static_cast<U64>(buffAddr[this->m_deserLoc + 6]) << 48) |
466 (static_cast<U64>(buffAddr[this->m_deserLoc + 7]) << 56);
467 break;
468 default:
469 FW_ASSERT(false);
470 break;
471 }
472 2730 this->m_deserLoc += static_cast<Serializable::SizeType>(sizeof(val));
473 2730 return FW_SERIALIZE_OK;
474 }
475
476 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::deserializeTo(I64& val, Endianness mode) {
477 U64 unsignVal;
478 SerializeStatus res = deserializeTo(unsignVal, mode);
479 if (res == SerializeStatus::FW_SERIALIZE_OK) {
480 val = static_cast<I64>(unsignVal);
481 }
482 return res;
483 }
484 #endif
485
486 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::deserializeTo(F64& val, Endianness mode) {
487 // deserialize as 64-bit int to handle endianness
488 U64 tempVal;
489 SerializeStatus stat = this->deserializeTo(tempVal, mode);
490 if (stat != FW_SERIALIZE_OK) {
491 return stat;
492 }
493 // copy to argument
494 (void)memcpy(&val, &tempVal, sizeof(val));
495
496 return FW_SERIALIZE_OK;
497 }
498
499 1336 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::deserializeTo(bool& val, Endianness mode) {
500 // check for room
501 1336 const Serializable::SizeType size = this->m_serLoc;
502
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1336 times.
1336 if (size == this->m_deserLoc) {
503 return FW_DESERIALIZE_BUFFER_EMPTY;
504
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1336 times.
1336 } else if (size - this->m_deserLoc < static_cast<Serializable::SizeType>(sizeof(U8))) {
505 return FW_DESERIALIZE_SIZE_MISMATCH;
506 }
507 // read from current location
508 1336 U8* buffAddr = this->m_buffAddr;
509 1336 FW_ASSERT(buffAddr != nullptr);
510 1336 const U8 byteVal = buffAddr[this->m_deserLoc + 0];
511
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1336 times.
1336 if (FW_SERIALIZE_TRUE_VALUE == byteVal) {
512 val = true;
513
1/2
✓ Branch 0 taken 1336 times.
✗ Branch 1 not taken.
1336 } else if (FW_SERIALIZE_FALSE_VALUE == byteVal) {
514 1336 val = false;
515 } else {
516 return FW_DESERIALIZE_FORMAT_ERROR;
517 }
518
519 1336 this->m_deserLoc += static_cast<Serializable::SizeType>(sizeof(U8));
520 1336 return FW_SERIALIZE_OK;
521 }
522
523 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::deserializeTo(void*& val, Endianness mode) {
524 // Deserialize as pointer cast, then convert to void*
525 PlatformPointerCastType pointerCastVal = 0;
526 const SerializeStatus stat = this->deserializeTo(pointerCastVal, mode);
527 if (stat == FW_SERIALIZE_OK) {
528 val = reinterpret_cast<void*>(pointerCastVal);
529 }
530 return stat;
531 }
532
533 4 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::deserializeTo(F32& val, Endianness mode) {
534 // deserialize as 32-bit int to handle endianness
535 4 U32 tempVal = 0;
536
1/1
✓ Branch 1 taken 4 times.
4 SerializeStatus stat = this->deserializeTo(tempVal, mode);
537
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (stat != FW_SERIALIZE_OK) {
538 return stat;
539 }
540 4 (void)memcpy(&val, &tempVal, sizeof(val));
541
542 4 return FW_SERIALIZE_OK;
543 }
544
545 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::deserializeTo(U8* buff,
546 Serializable::SizeType& length,
547 Endianness endianMode) {
548 FwSizeType length_in_out = static_cast<FwSizeType>(length);
549 SerializeStatus status = this->deserializeTo(buff, length_in_out, Serialization::INCLUDE_LENGTH, endianMode);
550 length = static_cast<Serializable::SizeType>(length_in_out);
551 return status;
552 }
553
554 23 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::deserializeTo(U8* buff,
555 Serializable::SizeType& length,
556 Serialization::t lengthMode,
557 Endianness endianMode) {
558 23 U8* buffAddr = this->m_buffAddr;
559 23 FW_ASSERT(buffAddr != nullptr);
560
561
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 16 times.
23 if (lengthMode == Serialization::INCLUDE_LENGTH) {
562 7 FwSizeStoreType storedLength = 0;
563
564
1/1
✓ Branch 1 taken 7 times.
7 SerializeStatus stat = this->deserializeTo(storedLength, endianMode);
565
566
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if (stat != FW_SERIALIZE_OK) {
567 return stat;
568 }
569
570 // make sure it fits
571
4/7
✓ Branch 1 taken 7 times.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 7 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 7 times.
7 if ((storedLength > this->getDeserializeSizeLeft()) || (storedLength > length)) {
572 return FW_DESERIALIZE_SIZE_MISMATCH;
573 }
574
575
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if (storedLength > 0) {
576 7 FW_ASSERT(buff != nullptr);
577 }
578 7 (void)memcpy(buff, &buffAddr[this->m_deserLoc], static_cast<size_t>(storedLength));
579
580 7 length = static_cast<FwSizeType>(storedLength);
581
582 } else {
583 // make sure enough is left
584
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
16 if (length > this->getDeserializeSizeLeft()) {
585 return FW_DESERIALIZE_SIZE_MISMATCH;
586 }
587
588
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if (length > 0) {
589 16 FW_ASSERT(buff != nullptr);
590 }
591 16 (void)memcpy(buff, &buffAddr[this->m_deserLoc], static_cast<size_t>(length));
592 }
593
594 23 this->m_deserLoc += static_cast<Serializable::SizeType>(length);
595 23 return FW_SERIALIZE_OK;
596 }
597
598 6610 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::deserializeTo(Serializable& val, Endianness mode) {
599 6610 return val.deserializeFrom(*this, mode);
600 }
601
602 2041 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::deserializeTo(LinearBufferBase& val, Endianness mode) {
603 2041 U8* valBuffAddr = val.getBuffAddr();
604 2042 FW_ASSERT(valBuffAddr != nullptr);
605 2042 SerializeStatus stat = FW_SERIALIZE_OK;
606
607 2042 FwSizeStoreType storedLength = 0;
608
609
1/1
✓ Branch 1 taken 2042 times.
2042 stat = this->deserializeTo(storedLength, mode);
610
611
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2042 times.
2042 if (stat != FW_SERIALIZE_OK) {
612 return stat;
613 }
614
615 // make sure destination has enough room
616
617
5/8
✓ Branch 1 taken 2041 times.
✓ Branch 3 taken 2041 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 2041 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2041 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2041 times.
2042 if ((storedLength > val.getCapacity()) || (storedLength > this->getDeserializeSizeLeft())) {
618 return FW_DESERIALIZE_SIZE_MISMATCH;
619 }
620
621 2041 U8* thisBuffAddr = this->m_buffAddr;
622 2041 FW_ASSERT(thisBuffAddr != nullptr);
623 2041 (void)memcpy(valBuffAddr, &thisBuffAddr[this->m_deserLoc], static_cast<size_t>(storedLength));
624
625
1/1
✓ Branch 1 taken 2042 times.
2041 stat = val.setBuffLen(storedLength);
626
627
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2042 times.
2042 if (stat != FW_SERIALIZE_OK) {
628 return stat;
629 }
630
631 2042 this->m_deserLoc += storedLength;
632
633 2042 return FW_SERIALIZE_OK;
634 }
635
636 2 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::deserializeSize(FwSizeType& size, Endianness mode) {
637 2 FwSizeStoreType storedSize = 0;
638
1/1
✓ Branch 1 taken 2 times.
2 Fw::SerializeStatus status = this->deserializeTo(storedSize, mode);
639
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (status == FW_SERIALIZE_OK) {
640 2 size = static_cast<FwSizeType>(storedSize);
641 }
642 2 return status;
643 }
644
645 41508 void LinearBufferBase::resetSer() {
646 41508 this->m_deserLoc = 0;
647 41508 this->m_serLoc = 0;
648 41508 }
649
650 39591 void LinearBufferBase::resetDeser() {
651 39591 this->m_deserLoc = 0;
652 39591 }
653
654 229 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::serializeSkip(FwSizeType numBytesToSkip) {
655 229 Fw::SerializeStatus status = FW_SERIALIZE_OK;
656 // compute new ser loc
657 229 const FwSizeType newSerLoc = this->m_serLoc + numBytesToSkip;
658 // check for room
659
1/2
✓ Branch 0 taken 229 times.
✗ Branch 1 not taken.
229 if (newSerLoc <= this->m_capacity) {
660 // update ser loc
661 229 this->m_serLoc = static_cast<Serializable::SizeType>(newSerLoc);
662 } else {
663 status = FW_SERIALIZE_NO_ROOM_LEFT;
664 }
665 229 return status;
666 }
667
668 1279 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::deserializeSkip(FwSizeType numBytesToSkip) {
669 // check for room
670 1279 const Serializable::SizeType size = this->m_serLoc;
671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1279 times.
1279 if (size == this->m_deserLoc) {
672 return FW_DESERIALIZE_BUFFER_EMPTY;
673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1279 times.
1279 } else if (size - this->m_deserLoc < numBytesToSkip) {
674 return FW_DESERIALIZE_SIZE_MISMATCH;
675 }
676 // update location in buffer to skip the value
677 1279 this->m_deserLoc += static_cast<Serializable::SizeType>(numBytesToSkip);
678 1279 return FW_SERIALIZE_OK;
679 }
680
681 229 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::moveSerToOffset(FwSizeType offset) {
682 // Reset serialization
683 229 this->resetSer();
684 // Advance to offset
685 229 return this->serializeSkip(offset);
686 }
687 1279 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::moveDeserToOffset(FwSizeType offset) {
688 // Reset deserialization
689 1279 this->resetDeser();
690 // Advance to offset
691 1279 return this->deserializeSkip(offset);
692 }
693
694 24490 Serializable::SizeType LinearBufferBase::getSize() const {
695 24490 return this->m_serLoc;
696 }
697
698 3704 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::setBuff(const U8* src, Serializable::SizeType length) {
699
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3704 times.
3704 if (this->m_capacity < length) {
700 return FW_SERIALIZE_NO_ROOM_LEFT;
701 } else {
702 3704 FW_ASSERT(src);
703 3704 U8* buffAddr = this->m_buffAddr;
704 3704 FW_ASSERT(buffAddr != nullptr);
705 3704 (void)memcpy(buffAddr, src, static_cast<size_t>(length));
706 3704 this->m_serLoc = length;
707 3704 this->m_deserLoc = 0;
708 3704 return FW_SERIALIZE_OK;
709 }
710 }
711
712 16015 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::setBuffLen(Serializable::SizeType length) {
713
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16015 times.
16015 if (this->m_capacity < length) {
714 return FW_SERIALIZE_NO_ROOM_LEFT;
715 } else {
716 16015 this->m_serLoc = length;
717 16015 this->m_deserLoc = 0;
718 16015 return FW_SERIALIZE_OK;
719 }
720 }
721
722 4121 Serializable::SizeType LinearBufferBase::getDeserializeSizeLeft() const {
723 4121 FW_ASSERT(this->m_serLoc >= this->m_deserLoc, static_cast<FwAssertArgType>(this->m_serLoc),
724 static_cast<FwAssertArgType>(this->m_deserLoc));
725 4121 return this->m_serLoc - this->m_deserLoc;
726 }
727
728 Serializable::SizeType LinearBufferBase::getSerializeSizeLeft() const {
729 FW_ASSERT(this->m_capacity >= this->m_serLoc, static_cast<FwAssertArgType>(this->m_capacity),
730 static_cast<FwAssertArgType>(this->m_serLoc));
731 return this->m_capacity - this->m_serLoc;
732 }
733
734 34 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::copyRaw(SerialBufferBase& dest,
735 Serializable::SizeType size) {
736 // make sure there is sufficient size in destination
737
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
34 if (dest.getCapacity() < size) {
738 return FW_SERIALIZE_NO_ROOM_LEFT;
739 }
740 // make sure there is sufficient buffer in source
741
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
34 if (this->getDeserializeSizeLeft() < size) {
742 return FW_DESERIALIZE_SIZE_MISMATCH;
743 }
744
745 // otherwise, set destination buffer to data from deserialization pointer plus size
746 34 U8* buffAddr = this->m_buffAddr;
747
748 34 FW_ASSERT(buffAddr);
749 34 SerializeStatus stat = dest.setBuff(&buffAddr[this->m_deserLoc], size);
750
1/2
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
34 if (stat == FW_SERIALIZE_OK) {
751 34 this->m_deserLoc += size;
752 }
753 34 return stat;
754 }
755
756 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::copyRawOffset(SerialBufferBase& dest,
757 Serializable::SizeType size) {
758 // make sure there is sufficient size in destination
759 const Serializable::SizeType destCapacity = dest.getCapacity();
760 const Serializable::SizeType destSize = dest.getSize();
761 if (destCapacity < size + destSize) {
762 return FW_SERIALIZE_NO_ROOM_LEFT;
763 }
764 // make sure there is sufficient buffer in source
765 if (this->getDeserializeSizeLeft() < size) {
766 return FW_DESERIALIZE_SIZE_MISMATCH;
767 }
768
769 // otherwise, serialize bytes to destination without writing length
770 U8* buffAddr = this->m_buffAddr;
771 SerializeStatus stat = dest.serializeFrom(&buffAddr[this->m_deserLoc], size, Serialization::OMIT_LENGTH);
772 if (stat == FW_SERIALIZE_OK) {
773 this->m_deserLoc += size;
774 }
775 return stat;
776 }
777
778 // return address of buffer not yet deserialized. This is used
779 // to copy the remainder of a buffer.
780 4 const U8* LinearBufferBase::getBuffAddrLeft() const {
781 4 const U8* buffAddr = this->m_buffAddr;
782 4 FW_ASSERT(buffAddr != nullptr);
783 4 return &buffAddr[this->m_deserLoc];
784 }
785
786 //!< gets address of end of serialization. Used to manually place data at the end
787 7848 U8* LinearBufferBase::getBuffAddrSer() {
788 7848 U8* buffAddr = this->m_buffAddr;
789 7848 FW_ASSERT(buffAddr != nullptr);
790 7851 return &buffAddr[this->m_serLoc];
791 }
792
793 #ifdef BUILD_UT
794 bool LinearBufferBase::operator==(const LinearBufferBase& other) const {
795 if (this->m_serLoc != other.getSize()) {
796 return false;
797 }
798
799 const U8* us = this->m_buffAddr;
800 const U8* them = other.getBuffAddr();
801
802 FW_ASSERT(us);
803 FW_ASSERT(them);
804
805 for (Serializable::SizeType byte = 0; byte < this->m_serLoc; byte++) {
806 if (us[byte] != them[byte]) {
807 return false;
808 }
809 }
810
811 return true;
812 }
813
814 std::ostream& operator<<(std::ostream& os, const LinearBufferBase& buff) {
815 const U8* us = buff.getBuffAddr();
816
817 FW_ASSERT(us);
818
819 for (Serializable::SizeType byte = 0; byte < buff.getSize(); byte++) {
820 os << "[" << std::setw(2) << std::hex << std::setfill('0') << us[byte] << "]" << std::dec;
821 }
822
823 return os;
824 }
825 #endif
826
827 9959 ExternalSerializeBuffer::ExternalSerializeBuffer(U8* buffPtr, Serializable::SizeType size)
828 9959 : LinearBufferBase(nullptr, 0) {
829
1/1
✓ Branch 1 taken 9959 times.
9959 this->setExtBuffer(buffPtr, size);
830 9959 }
831
832 8720 ExternalSerializeBuffer::ExternalSerializeBuffer() : LinearBufferBase(nullptr, 0) {
833
1/1
✓ Branch 1 taken 8720 times.
8720 this->clear();
834 8720 }
835
836 22566 void ExternalSerializeBuffer::setExtBuffer(U8* buffPtr, Serializable::SizeType size) {
837 // Allow setting buffer with null pointer and zero size (for initialization/reset)
838 // but reject null pointer with non-zero size
839 22566 FW_ASSERT((buffPtr != nullptr) || (size == 0), static_cast<FwAssertArgType>(size));
840 22566 this->clear();
841 22566 this->setBuffAddrInternal(buffPtr);
842 22566 this->setCapacityInternal(size);
843 22566 }
844
845 31288 void ExternalSerializeBuffer::clear() {
846 31288 this->resetSer();
847 31289 this->resetDeser();
848 31288 this->setBuffAddrInternal(nullptr);
849 31289 this->setCapacityInternal(0);
850 31289 }
851
852 // ----------------------------------------------------------------------
853 // Deprecated method implementations for backward compatibility
854 // ----------------------------------------------------------------------
855
856 Serializable::SizeType LinearBufferBase::getBuffLength() const {
857 return this->m_serLoc;
858 }
859
860 Serializable::SizeType LinearBufferBase::getBuffLeft() {
861 return this->getDeserializeSizeLeft();
862 }
863
864 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::serialize(U8 val) {
865 return this->serializeFrom(val);
866 }
867 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::serialize(I8 val) {
868 return this->serializeFrom(val);
869 }
870 #if FW_HAS_16_BIT == 1
871 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::serialize(U16 val) {
872 return this->serializeFrom(val);
873 }
874 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::serialize(I16 val) {
875 return this->serializeFrom(val);
876 }
877 #endif
878 #if FW_HAS_32_BIT == 1
879 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::serialize(U32 val) {
880 return this->serializeFrom(val);
881 }
882 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::serialize(I32 val) {
883 return this->serializeFrom(val);
884 }
885 #endif
886 #if FW_HAS_64_BIT == 1
887 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::serialize(U64 val) {
888 return this->serializeFrom(val);
889 }
890 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::serialize(I64 val) {
891 return this->serializeFrom(val);
892 }
893 #endif
894 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::serialize(F32 val) {
895 return this->serializeFrom(val);
896 }
897 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::serialize(F64 val) {
898 return this->serializeFrom(val);
899 }
900 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::serialize(bool val) {
901 return this->serializeFrom(val);
902 }
903 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::serialize(const void* val) {
904 return this->serializeFrom(val);
905 }
906
907 // Deprecated method for backward compatibility
908 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::serialize(const U8* buff,
909 FwSizeType length,
910 bool noLength) {
911 const Serialization::t mode = noLength ? Serialization::OMIT_LENGTH : Serialization::INCLUDE_LENGTH;
912 return this->serializeFrom(buff, length, mode);
913 }
914
915 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::serialize(const U8* buff, FwSizeType length) {
916 return this->serializeFrom(buff, length);
917 }
918 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::serialize(const U8* buff,
919 FwSizeType length,
920 Serialization::t mode) {
921 return this->serializeFrom(buff, length, mode);
922 }
923 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::serialize(const Serializable& val) {
924 return this->serializeFrom(val);
925 }
926 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::serialize(const LinearBufferBase& val) {
927 return this->serializeFrom(val);
928 }
929
930 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::deserialize(U8& val) {
931 return this->deserializeTo(val);
932 }
933 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::deserialize(I8& val) {
934 return this->deserializeTo(val);
935 }
936 #if FW_HAS_16_BIT == 1
937 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::deserialize(U16& val) {
938 return this->deserializeTo(val);
939 }
940 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::deserialize(I16& val) {
941 return this->deserializeTo(val);
942 }
943 #endif
944 #if FW_HAS_32_BIT == 1
945 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::deserialize(U32& val) {
946 return this->deserializeTo(val);
947 }
948 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::deserialize(I32& val) {
949 return this->deserializeTo(val);
950 }
951 #endif
952 #if FW_HAS_64_BIT == 1
953 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::deserialize(U64& val) {
954 return this->deserializeTo(val);
955 }
956 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::deserialize(I64& val) {
957 return this->deserializeTo(val);
958 }
959 #endif
960 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::deserialize(F32& val) {
961 return this->deserializeTo(val);
962 }
963 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::deserialize(F64& val) {
964 return this->deserializeTo(val);
965 }
966 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::deserialize(bool& val) {
967 return this->deserializeTo(val);
968 }
969 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::deserialize(void*& val) {
970 return this->deserializeTo(val);
971 }
972
973 // Deprecated method for backward compatibility
974 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::deserialize(U8* buff,
975 FwSizeType& length,
976 bool noLength) {
977 const Serialization::t mode = noLength ? Serialization::OMIT_LENGTH : Serialization::INCLUDE_LENGTH;
978 return this->deserializeTo(buff, length, mode);
979 }
980
981 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::deserialize(U8* buff, FwSizeType& length) {
982 return this->deserializeTo(buff, length, Serialization::INCLUDE_LENGTH);
983 }
984
985 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::deserialize(U8* buff,
986 FwSizeType& length,
987 Serialization::t mode) {
988 return this->deserializeTo(buff, length, mode);
989 }
990
991 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::deserialize(Serializable& val) {
992 return this->deserializeTo(val);
993 }
994 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::deserialize(LinearBufferBase& val) {
995 return this->deserializeTo(val);
996 }
997
998 Serializable::SizeType ExternalSerializeBuffer::getBuffCapacity() const {
999 return this->getCapacity();
1000 }
1001
1002 } // namespace Fw
1003