GCC Code Coverage Report


Directory: Fw/Types/
File: Serializable.cpp
Date: 2026-09-03 21:15:04
Exec Total Coverage
Lines: 332 589 56.4%
Functions: 44 101 43.6%
Branches: 87 211 41.2%

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 139 Serializable::Serializable() {}
15
16 278 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 20 SerialBufferBase::~SerialBufferBase() {}
39
40 10 LinearBufferBase::LinearBufferBase(U8* buffAddr, Serializable::SizeType capacity)
41 10 : m_buffAddr(buffAddr), m_capacity(capacity), m_serLoc(0), m_deserLoc(0) {
42 // Ensure buffAddr & capacity are consistent
43 10 FW_ASSERT((buffAddr == nullptr) == (capacity == 0), static_cast<FwAssertArgType>(capacity));
44 10 }
45
46 20 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 2000070 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::serializeFrom(U8 val, Endianness mode) {
71
2/2
✓ Branch 8 taken 1999993 times.
✓ Branch 9 taken 77 times.
2000070 if (this->m_serLoc + static_cast<Serializable::SizeType>(sizeof(val)) - 1 >= this->m_capacity) {
72 1999993 return FW_SERIALIZE_NO_ROOM_LEFT;
73 }
74 77 U8* buffAddr = this->m_buffAddr;
75 77 FW_ASSERT(buffAddr != nullptr);
76 77 buffAddr[this->m_serLoc] = val;
77 77 this->m_serLoc += static_cast<Serializable::SizeType>(sizeof(val));
78 77 this->m_deserLoc = 0;
79
80 77 return FW_SERIALIZE_OK;
81 }
82
83 4 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::serializeFrom(I8 val, Endianness mode) {
84 4 return serializeFrom(static_cast<U8>(val), mode);
85 }
86
87 #if FW_HAS_16_BIT == 1
88 4000014 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::serializeFrom(U16 val, Endianness mode) {
89
2/2
✓ Branch 8 taken 3999984 times.
✓ Branch 9 taken 30 times.
4000014 if (this->m_serLoc + static_cast<Serializable::SizeType>(sizeof(val)) - 1 >= this->m_capacity) {
90 3999984 return FW_SERIALIZE_NO_ROOM_LEFT;
91 }
92 30 U8* buffAddr = this->m_buffAddr;
93 30 FW_ASSERT(buffAddr != nullptr);
94
2/3
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
30 switch (mode) {
95 26 case Endianness::BIG:
96 // MSB first
97 26 buffAddr[this->m_serLoc + 0] = static_cast<U8>(val >> 8);
98 26 buffAddr[this->m_serLoc + 1] = static_cast<U8>(val);
99 26 break;
100 4 case Endianness::LITTLE:
101 // LSB first
102 4 buffAddr[this->m_serLoc + 0] = static_cast<U8>(val);
103 4 buffAddr[this->m_serLoc + 1] = static_cast<U8>(val >> 8);
104 4 break;
105 default:
106 FW_ASSERT(false);
107 break;
108 }
109 30 this->m_serLoc += static_cast<Serializable::SizeType>(sizeof(val));
110 30 this->m_deserLoc = 0;
111 30 return FW_SERIALIZE_OK;
112 }
113
114 6 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::serializeFrom(I16 val, Endianness mode) {
115 6 return serializeFrom(static_cast<U16>(val), mode);
116 }
117 #endif
118 #if FW_HAS_32_BIT == 1
119 4000016 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::serializeFrom(U32 val, Endianness mode) {
120
2/2
✓ Branch 8 taken 3999984 times.
✓ Branch 9 taken 32 times.
4000016 if (this->m_serLoc + static_cast<Serializable::SizeType>(sizeof(val)) - 1 >= this->m_capacity) {
121 3999984 return FW_SERIALIZE_NO_ROOM_LEFT;
122 }
123 32 U8* buffAddr = this->m_buffAddr;
124 32 FW_ASSERT(buffAddr != nullptr);
125
2/3
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
32 switch (mode) {
126 28 case Endianness::BIG:
127 // MSB first
128 28 buffAddr[this->m_serLoc + 0] = static_cast<U8>(val >> 24);
129 28 buffAddr[this->m_serLoc + 1] = static_cast<U8>(val >> 16);
130 28 buffAddr[this->m_serLoc + 2] = static_cast<U8>(val >> 8);
131 28 buffAddr[this->m_serLoc + 3] = static_cast<U8>(val);
132 28 break;
133 4 case Endianness::LITTLE:
134 // LSB first
135 4 buffAddr[this->m_serLoc + 0] = static_cast<U8>(val);
136 4 buffAddr[this->m_serLoc + 1] = static_cast<U8>(val >> 8);
137 4 buffAddr[this->m_serLoc + 2] = static_cast<U8>(val >> 16);
138 4 buffAddr[this->m_serLoc + 3] = static_cast<U8>(val >> 24);
139 4 break;
140 default:
141 FW_ASSERT(false);
142 break;
143 }
144 32 this->m_serLoc += static_cast<Serializable::SizeType>(sizeof(val));
145 32 this->m_deserLoc = 0;
146 32 return FW_SERIALIZE_OK;
147 }
148
149 6 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::serializeFrom(I32 val, Endianness mode) {
150 6 return serializeFrom(static_cast<U32>(val), mode);
151 }
152 #endif
153
154 #if FW_HAS_64_BIT == 1
155 1000018 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::serializeFrom(U64 val, Endianness mode) {
156
1/2
✗ Branch 8 not taken.
✓ Branch 9 taken 1000018 times.
1000018 if (this->m_serLoc + static_cast<Serializable::SizeType>(sizeof(val)) - 1 >= this->m_capacity) {
157 return FW_SERIALIZE_NO_ROOM_LEFT;
158 }
159 1000018 U8* buffAddr = this->m_buffAddr;
160 1000018 FW_ASSERT(buffAddr != nullptr);
161
2/3
✓ Branch 0 taken 1000013 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
1000018 switch (mode) {
162 1000013 case Endianness::BIG:
163 // MSB first
164 1000013 buffAddr[this->m_serLoc + 0] = static_cast<U8>(val >> 56);
165 1000013 buffAddr[this->m_serLoc + 1] = static_cast<U8>(val >> 48);
166 1000013 buffAddr[this->m_serLoc + 2] = static_cast<U8>(val >> 40);
167 1000013 buffAddr[this->m_serLoc + 3] = static_cast<U8>(val >> 32);
168 1000013 buffAddr[this->m_serLoc + 4] = static_cast<U8>(val >> 24);
169 1000013 buffAddr[this->m_serLoc + 5] = static_cast<U8>(val >> 16);
170 1000013 buffAddr[this->m_serLoc + 6] = static_cast<U8>(val >> 8);
171 1000013 buffAddr[this->m_serLoc + 7] = static_cast<U8>(val);
172 1000013 break;
173 5 case Endianness::LITTLE:
174 // LSB first
175 5 buffAddr[this->m_serLoc + 0] = static_cast<U8>(val);
176 5 buffAddr[this->m_serLoc + 1] = static_cast<U8>(val >> 8);
177 5 buffAddr[this->m_serLoc + 2] = static_cast<U8>(val >> 16);
178 5 buffAddr[this->m_serLoc + 3] = static_cast<U8>(val >> 24);
179 5 buffAddr[this->m_serLoc + 4] = static_cast<U8>(val >> 32);
180 5 buffAddr[this->m_serLoc + 5] = static_cast<U8>(val >> 40);
181 5 buffAddr[this->m_serLoc + 6] = static_cast<U8>(val >> 48);
182 5 buffAddr[this->m_serLoc + 7] = static_cast<U8>(val >> 56);
183 5 break;
184 default:
185 FW_ASSERT(false);
186 break;
187 }
188 1000018 this->m_serLoc += static_cast<Serializable::SizeType>(sizeof(val));
189 1000018 this->m_deserLoc = 0;
190 1000018 return FW_SERIALIZE_OK;
191 }
192
193 6 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::serializeFrom(I64 val, Endianness mode) {
194 6 return serializeFrom(static_cast<U64>(val), mode);
195 }
196 #endif
197
198 1000004 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 1000004 U64 u64Val;
201 1000004 (void)memcpy(&u64Val, &val, sizeof(val));
202
1/1
✓ Branch 7 taken 1000004 times.
2000008 return this->serializeFrom(u64Val, mode);
203 }
204
205 2000004 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 2000004 U32 u32Val;
208 2000004 (void)memcpy(&u32Val, &val, sizeof(val));
209
1/1
✓ Branch 7 taken 2000004 times.
4000008 return this->serializeFrom(u32Val, mode);
210 }
211
212 3 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::serializeFrom(bool val, Endianness mode) {
213
1/2
✗ Branch 8 not taken.
✓ Branch 9 taken 3 times.
3 if (this->m_serLoc + static_cast<Serializable::SizeType>(sizeof(U8)) - 1 >= this->m_capacity) {
214 return FW_SERIALIZE_NO_ROOM_LEFT;
215 }
216
217 3 U8* buffAddr = this->m_buffAddr;
218 3 FW_ASSERT(buffAddr != nullptr);
219
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (val) {
220 3 buffAddr[this->m_serLoc + 0] = FW_SERIALIZE_TRUE_VALUE;
221 } else {
222 buffAddr[this->m_serLoc + 0] = FW_SERIALIZE_FALSE_VALUE;
223 }
224
225 3 this->m_serLoc += static_cast<Serializable::SizeType>(sizeof(U8));
226 3 this->m_deserLoc = 0;
227 3 return FW_SERIALIZE_OK;
228 }
229
230 4 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::serializeFrom(const void* val, Endianness mode) {
231
1/2
✗ Branch 8 not taken.
✓ Branch 9 taken 4 times.
4 if (this->m_serLoc + static_cast<Serializable::SizeType>(sizeof(void*)) - 1 >= this->m_capacity) {
232 return FW_SERIALIZE_NO_ROOM_LEFT;
233 }
234
235 4 return this->serializeFrom(reinterpret_cast<PlatformPointerCastType>(val), mode);
236 }
237
238 2000002 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::serializeFrom(const U8* buff,
239 Serializable::SizeType length,
240 Endianness endianMode) {
241 2000002 return this->serializeFrom(buff, static_cast<FwSizeType>(length), Serialization::INCLUDE_LENGTH, endianMode);
242 }
243
244 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus
245 2000002 LinearBufferBase::serializeFrom(const U8* buff,
246 FwSizeType length,
247 Serialization::t lengthMode,
248 Endianness endianMode) { // First serialize length
249 SerializeStatus stat;
250
1/2
✓ Branch 0 taken 2000002 times.
✗ Branch 1 not taken.
2000002 if (lengthMode == Serialization::INCLUDE_LENGTH) {
251 2000002 stat = this->serializeFrom(static_cast<FwSizeStoreType>(length), endianMode);
252
2/2
✓ Branch 0 taken 1999992 times.
✓ Branch 1 taken 10 times.
2000002 if (stat != FW_SERIALIZE_OK) {
253 1999992 return stat;
254 }
255 }
256
257 // make sure we have enough space
258
2/2
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 8 times.
10 if (this->m_serLoc + length > this->m_capacity) {
259 2 return FW_SERIALIZE_NO_ROOM_LEFT;
260 }
261
262
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if (length > 0) {
263 8 FW_ASSERT(buff != nullptr);
264 }
265 8 U8* buffAddr = this->m_buffAddr;
266 8 FW_ASSERT(buffAddr != nullptr);
267 // copy buffer to our buffer; memmove is used because the source may overlap this buffer
268
2/4
✗ Branch 5 not taken.
✓ Branch 6 taken 8 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 8 times.
8 (void)memmove(&buffAddr[this->m_serLoc], buff, static_cast<size_t>(length));
269 8 this->m_serLoc += static_cast<Serializable::SizeType>(length);
270 8 this->m_deserLoc = 0;
271
272 8 return FW_SERIALIZE_OK;
273 }
274
275 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::serializeFrom(const Serializable& val,
276 Endianness mode) {
277 return val.serializeTo(*this, mode);
278 }
279
280 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::serializeFrom(const LinearBufferBase& val,
281 Endianness mode) {
282 Serializable::SizeType size = val.getSize();
283 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 SerializeStatus stat = this->serializeFrom(static_cast<FwSizeStoreType>(size), mode);
289 if (stat != FW_SERIALIZE_OK) {
290 return stat;
291 }
292
293 U8* thisBuffAddr = this->m_buffAddr;
294 const U8* valBuffAddr = val.getBuffAddr();
295 FW_ASSERT(thisBuffAddr != nullptr);
296 FW_ASSERT(valBuffAddr != nullptr);
297 // serialize buffer
298 (void)memcpy(&thisBuffAddr[this->m_serLoc], valBuffAddr, static_cast<size_t>(size));
299 this->m_serLoc += size;
300 this->m_deserLoc = 0;
301
302 return FW_SERIALIZE_OK;
303 }
304
305 2 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::serializeSize(const FwSizeType size, Endianness mode) {
306 2 SerializeStatus status = FW_SERIALIZE_OK;
307
3/6
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
2 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 2 times.
✗ Branch 1 not taken.
2 if (status == FW_SERIALIZE_OK) {
311 2 status = this->serializeFrom(static_cast<FwSizeStoreType>(size), mode);
312 }
313 2 return status;
314 }
315
316 // deserialization routines
317
318 26 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::deserializeTo(U8& val, Endianness mode) {
319 // check for room
320 26 const Serializable::SizeType size = this->m_serLoc;
321
2/2
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 23 times.
26 if (size == this->m_deserLoc) {
322 3 return FW_DESERIALIZE_BUFFER_EMPTY;
323
1/2
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
23 } 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 23 U8* buffAddr = this->m_buffAddr;
328 23 FW_ASSERT(buffAddr != nullptr);
329 23 val = buffAddr[this->m_deserLoc + 0];
330 23 this->m_deserLoc += static_cast<Serializable::SizeType>(sizeof(val));
331 23 return FW_SERIALIZE_OK;
332 }
333
334 4 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::deserializeTo(I8& val, Endianness mode) {
335 // check for room
336 4 const Serializable::SizeType size = this->m_serLoc;
337
1/2
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
4 if (size == this->m_deserLoc) {
338 return FW_DESERIALIZE_BUFFER_EMPTY;
339
1/2
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
4 } 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 4 U8* buffAddr = this->m_buffAddr;
344 4 FW_ASSERT(buffAddr != nullptr);
345 4 val = static_cast<I8>(buffAddr[this->m_deserLoc + 0]);
346 4 this->m_deserLoc += static_cast<Serializable::SizeType>(sizeof(val));
347 4 return FW_SERIALIZE_OK;
348 }
349
350 #if FW_HAS_16_BIT == 1
351 14 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::deserializeTo(U16& val, Endianness mode) {
352 // check for room
353 14 const Serializable::SizeType size = this->m_serLoc;
354
1/2
✗ Branch 4 not taken.
✓ Branch 5 taken 14 times.
14 if (size == this->m_deserLoc) {
355 return FW_DESERIALIZE_BUFFER_EMPTY;
356
1/2
✗ Branch 4 not taken.
✓ Branch 5 taken 14 times.
14 } 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 14 U8* buffAddr = this->m_buffAddr;
361 14 FW_ASSERT(buffAddr != nullptr);
362
2/3
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
14 switch (mode) {
363 10 case Endianness::BIG:
364 // MSB first
365
2/4
✗ Branch 6 not taken.
✓ Branch 7 taken 10 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 10 times.
10 val = static_cast<U16>(((buffAddr[this->m_deserLoc + 1]) << 0) | ((buffAddr[this->m_deserLoc + 0]) << 8));
366 10 break;
367 4 case Endianness::LITTLE:
368 // LSB first
369
2/4
✗ Branch 6 not taken.
✓ Branch 7 taken 4 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 4 times.
4 val = static_cast<U16>(((buffAddr[this->m_deserLoc + 0]) << 0) | ((buffAddr[this->m_deserLoc + 1]) << 8));
370 4 break;
371 default:
372 FW_ASSERT(false);
373 break;
374 }
375 14 this->m_deserLoc += static_cast<Serializable::SizeType>(sizeof(val));
376 14 return FW_SERIALIZE_OK;
377 }
378
379 6 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::deserializeTo(I16& val, Endianness mode) {
380 6 U16 unsignVal = 0;
381
1/1
✓ Branch 7 taken 6 times.
6 SerializeStatus res = deserializeTo(unsignVal, mode);
382
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if (res == SerializeStatus::FW_SERIALIZE_OK) {
383 6 val = static_cast<I16>(unsignVal);
384 }
385 6 return res;
386 }
387 #endif
388 #if FW_HAS_32_BIT == 1
389 15 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::deserializeTo(U32& val, Endianness mode) {
390 // check for room
391 15 const Serializable::SizeType size = this->m_serLoc;
392
1/2
✗ Branch 4 not taken.
✓ Branch 5 taken 15 times.
15 if (size == this->m_deserLoc) {
393 return FW_DESERIALIZE_BUFFER_EMPTY;
394
1/2
✗ Branch 4 not taken.
✓ Branch 5 taken 15 times.
15 } 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 15 U8* buffAddr = this->m_buffAddr;
399 15 FW_ASSERT(buffAddr != nullptr);
400
2/3
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
15 switch (mode) {
401 11 case Endianness::BIG:
402 // MSB first
403 11 val = (static_cast<U32>(buffAddr[this->m_deserLoc + 3]) << 0) |
404 11 (static_cast<U32>(buffAddr[this->m_deserLoc + 2]) << 8) |
405 11 (static_cast<U32>(buffAddr[this->m_deserLoc + 1]) << 16) |
406 11 (static_cast<U32>(buffAddr[this->m_deserLoc + 0]) << 24);
407 11 break;
408 4 case Endianness::LITTLE:
409 // LSB first
410 4 val = (static_cast<U32>(buffAddr[this->m_deserLoc + 0]) << 0) |
411 4 (static_cast<U32>(buffAddr[this->m_deserLoc + 1]) << 8) |
412 4 (static_cast<U32>(buffAddr[this->m_deserLoc + 2]) << 16) |
413 4 (static_cast<U32>(buffAddr[this->m_deserLoc + 3]) << 24);
414 4 break;
415 default:
416 FW_ASSERT(false);
417 break;
418 }
419 15 this->m_deserLoc += static_cast<Serializable::SizeType>(sizeof(val));
420 15 return FW_SERIALIZE_OK;
421 }
422
423 6 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::deserializeTo(I32& val, Endianness mode) {
424 6 U32 unsignVal = 0;
425
1/1
✓ Branch 7 taken 6 times.
6 SerializeStatus res = deserializeTo(unsignVal, mode);
426
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if (res == SerializeStatus::FW_SERIALIZE_OK) {
427 6 val = static_cast<I32>(unsignVal);
428 }
429 6 return res;
430 }
431 #endif
432
433 #if FW_HAS_64_BIT == 1
434
435 1000018 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::deserializeTo(U64& val, Endianness mode) {
436 // check for room
437
1/2
✗ Branch 8 not taken.
✓ Branch 9 taken 1000018 times.
1000018 if (this->m_serLoc == this->m_deserLoc) {
438 return FW_DESERIALIZE_BUFFER_EMPTY;
439
1/2
✗ Branch 8 not taken.
✓ Branch 9 taken 1000018 times.
1000018 } 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 1000018 U8* buffAddr = this->m_buffAddr;
444 1000018 FW_ASSERT(buffAddr != nullptr);
445
2/3
✓ Branch 0 taken 1000013 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
1000018 switch (mode) {
446 1000013 case Endianness::BIG:
447 // MSB first
448 1000013 val = (static_cast<U64>(buffAddr[this->m_deserLoc + 7]) << 0) |
449 1000013 (static_cast<U64>(buffAddr[this->m_deserLoc + 6]) << 8) |
450 1000013 (static_cast<U64>(buffAddr[this->m_deserLoc + 5]) << 16) |
451 1000013 (static_cast<U64>(buffAddr[this->m_deserLoc + 4]) << 24) |
452 1000013 (static_cast<U64>(buffAddr[this->m_deserLoc + 3]) << 32) |
453 1000013 (static_cast<U64>(buffAddr[this->m_deserLoc + 2]) << 40) |
454 1000013 (static_cast<U64>(buffAddr[this->m_deserLoc + 1]) << 48) |
455 1000013 (static_cast<U64>(buffAddr[this->m_deserLoc + 0]) << 56);
456 1000013 break;
457 5 case Endianness::LITTLE:
458 // LSB first
459 5 val = (static_cast<U64>(buffAddr[this->m_deserLoc + 0]) << 0) |
460 5 (static_cast<U64>(buffAddr[this->m_deserLoc + 1]) << 8) |
461 5 (static_cast<U64>(buffAddr[this->m_deserLoc + 2]) << 16) |
462 5 (static_cast<U64>(buffAddr[this->m_deserLoc + 3]) << 24) |
463 5 (static_cast<U64>(buffAddr[this->m_deserLoc + 4]) << 32) |
464 5 (static_cast<U64>(buffAddr[this->m_deserLoc + 5]) << 40) |
465 5 (static_cast<U64>(buffAddr[this->m_deserLoc + 6]) << 48) |
466 5 (static_cast<U64>(buffAddr[this->m_deserLoc + 7]) << 56);
467 5 break;
468 default:
469 FW_ASSERT(false);
470 break;
471 }
472 1000018 this->m_deserLoc += static_cast<Serializable::SizeType>(sizeof(val));
473 1000018 return FW_SERIALIZE_OK;
474 }
475
476 6 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::deserializeTo(I64& val, Endianness mode) {
477 6 U64 unsignVal;
478
1/1
✓ Branch 7 taken 6 times.
6 SerializeStatus res = deserializeTo(unsignVal, mode);
479
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if (res == SerializeStatus::FW_SERIALIZE_OK) {
480 6 val = static_cast<I64>(unsignVal);
481 }
482 6 return res;
483 }
484 #endif
485
486 1000004 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::deserializeTo(F64& val, Endianness mode) {
487 // deserialize as 64-bit int to handle endianness
488 1000004 U64 tempVal;
489
1/1
✓ Branch 7 taken 1000004 times.
1000004 SerializeStatus stat = this->deserializeTo(tempVal, mode);
490
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1000004 times.
1000004 if (stat != FW_SERIALIZE_OK) {
491 return stat;
492 }
493 // copy to argument
494 1000004 (void)memcpy(&val, &tempVal, sizeof(val));
495
496 1000004 return FW_SERIALIZE_OK;
497 }
498
499 3 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::deserializeTo(bool& val, Endianness mode) {
500 // check for room
501 3 const Serializable::SizeType size = this->m_serLoc;
502
1/2
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
3 if (size == this->m_deserLoc) {
503 return FW_DESERIALIZE_BUFFER_EMPTY;
504
1/2
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
3 } 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 3 U8* buffAddr = this->m_buffAddr;
509 3 FW_ASSERT(buffAddr != nullptr);
510 3 const U8 byteVal = buffAddr[this->m_deserLoc + 0];
511
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (FW_SERIALIZE_TRUE_VALUE == byteVal) {
512 3 val = true;
513 } else if (FW_SERIALIZE_FALSE_VALUE == byteVal) {
514 val = false;
515 } else {
516 return FW_DESERIALIZE_FORMAT_ERROR;
517 }
518
519 3 this->m_deserLoc += static_cast<Serializable::SizeType>(sizeof(U8));
520 3 return FW_SERIALIZE_OK;
521 }
522
523 4 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::deserializeTo(void*& val, Endianness mode) {
524 // Deserialize as pointer cast, then convert to void*
525 4 PlatformPointerCastType pointerCastVal = 0;
526
1/1
✓ Branch 7 taken 4 times.
4 const SerializeStatus stat = this->deserializeTo(pointerCastVal, mode);
527
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if (stat == FW_SERIALIZE_OK) {
528 4 val = reinterpret_cast<void*>(pointerCastVal);
529 }
530 4 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 7 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 2 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::deserializeTo(U8* buff,
555 Serializable::SizeType& length,
556 Serialization::t lengthMode,
557 Endianness endianMode) {
558 2 U8* buffAddr = this->m_buffAddr;
559 2 FW_ASSERT(buffAddr != nullptr);
560
561
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (lengthMode == Serialization::INCLUDE_LENGTH) {
562 2 FwSizeStoreType storedLength = 0;
563
564
1/1
✓ Branch 7 taken 2 times.
2 SerializeStatus stat = this->deserializeTo(storedLength, endianMode);
565
566
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (stat != FW_SERIALIZE_OK) {
567 return stat;
568 }
569
570 // make sure it fits
571
4/7
✓ Branch 7 taken 2 times.
✓ Branch 9 taken 2 times.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 2 times.
2 if ((storedLength > this->getDeserializeSizeLeft()) || (storedLength > length)) {
572 return FW_DESERIALIZE_SIZE_MISMATCH;
573 }
574
575
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (storedLength > 0) {
576 2 FW_ASSERT(buff != nullptr);
577 }
578
2/4
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
2 (void)memcpy(buff, &buffAddr[this->m_deserLoc], static_cast<size_t>(storedLength));
579
580 2 length = static_cast<FwSizeType>(storedLength);
581
582 } else {
583 // make sure enough is left
584 if (length > this->getDeserializeSizeLeft()) {
585 return FW_DESERIALIZE_SIZE_MISMATCH;
586 }
587
588 if (length > 0) {
589 FW_ASSERT(buff != nullptr);
590 }
591 (void)memcpy(buff, &buffAddr[this->m_deserLoc], static_cast<size_t>(length));
592 }
593
594 2 this->m_deserLoc += static_cast<Serializable::SizeType>(length);
595 2 return FW_SERIALIZE_OK;
596 }
597
598 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::deserializeTo(Serializable& val, Endianness mode) {
599 return val.deserializeFrom(*this, mode);
600 }
601
602 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::deserializeTo(LinearBufferBase& val, Endianness mode) {
603 U8* valBuffAddr = val.getBuffAddr();
604 FW_ASSERT(valBuffAddr != nullptr);
605 SerializeStatus stat = FW_SERIALIZE_OK;
606
607 FwSizeStoreType storedLength = 0;
608
609 stat = this->deserializeTo(storedLength, mode);
610
611 if (stat != FW_SERIALIZE_OK) {
612 return stat;
613 }
614
615 // make sure destination has enough room
616
617 if ((storedLength > val.getCapacity()) || (storedLength > this->getDeserializeSizeLeft())) {
618 return FW_DESERIALIZE_SIZE_MISMATCH;
619 }
620
621 U8* thisBuffAddr = this->m_buffAddr;
622 FW_ASSERT(thisBuffAddr != nullptr);
623 (void)memcpy(valBuffAddr, &thisBuffAddr[this->m_deserLoc], static_cast<size_t>(storedLength));
624
625 stat = val.setBuffLen(storedLength);
626
627 if (stat != FW_SERIALIZE_OK) {
628 return stat;
629 }
630
631 this->m_deserLoc += storedLength;
632
633 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 7 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 1000043 void LinearBufferBase::resetSer() {
646 1000043 this->m_deserLoc = 0;
647 1000043 this->m_serLoc = 0;
648 1000043 }
649
650 10 void LinearBufferBase::resetDeser() {
651 10 this->m_deserLoc = 0;
652 10 }
653
654 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::serializeSkip(FwSizeType numBytesToSkip) {
655 Fw::SerializeStatus status = FW_SERIALIZE_OK;
656 // compute new ser loc
657 const FwSizeType newSerLoc = this->m_serLoc + numBytesToSkip;
658 // check for room
659 if (newSerLoc <= this->m_capacity) {
660 // update ser loc
661 this->m_serLoc = static_cast<Serializable::SizeType>(newSerLoc);
662 } else {
663 status = FW_SERIALIZE_NO_ROOM_LEFT;
664 }
665 return status;
666 }
667
668 5 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::deserializeSkip(FwSizeType numBytesToSkip) {
669 // check for room
670 5 const Serializable::SizeType size = this->m_serLoc;
671
2/2
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 4 times.
5 if (size == this->m_deserLoc) {
672 1 return FW_DESERIALIZE_BUFFER_EMPTY;
673
2/2
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 3 times.
4 } else if (size - this->m_deserLoc < numBytesToSkip) {
674 1 return FW_DESERIALIZE_SIZE_MISMATCH;
675 }
676 // update location in buffer to skip the value
677 3 this->m_deserLoc += static_cast<Serializable::SizeType>(numBytesToSkip);
678 3 return FW_SERIALIZE_OK;
679 }
680
681 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::moveSerToOffset(FwSizeType offset) {
682 // Reset serialization
683 this->resetSer();
684 // Advance to offset
685 return this->serializeSkip(offset);
686 }
687 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::moveDeserToOffset(FwSizeType offset) {
688 // Reset deserialization
689 this->resetDeser();
690 // Advance to offset
691 return this->deserializeSkip(offset);
692 }
693
694 15 Serializable::SizeType LinearBufferBase::getSize() const {
695 15 return this->m_serLoc;
696 }
697
698 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::setBuff(const U8* src, Serializable::SizeType length) {
699 if (this->m_capacity < length) {
700 return FW_SERIALIZE_NO_ROOM_LEFT;
701 } else {
702 FW_ASSERT(src);
703 U8* buffAddr = this->m_buffAddr;
704 FW_ASSERT(buffAddr != nullptr);
705 (void)memcpy(buffAddr, src, static_cast<size_t>(length));
706 this->m_serLoc = length;
707 this->m_deserLoc = 0;
708 return FW_SERIALIZE_OK;
709 }
710 }
711
712 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::setBuffLen(Serializable::SizeType length) {
713 if (this->m_capacity < length) {
714 return FW_SERIALIZE_NO_ROOM_LEFT;
715 } else {
716 this->m_serLoc = length;
717 this->m_deserLoc = 0;
718 return FW_SERIALIZE_OK;
719 }
720 }
721
722 9 Serializable::SizeType LinearBufferBase::getDeserializeSizeLeft() const {
723 9 FW_ASSERT(this->m_serLoc >= this->m_deserLoc, static_cast<FwAssertArgType>(this->m_serLoc),
724 static_cast<FwAssertArgType>(this->m_deserLoc));
725 9 return this->m_serLoc - this->m_deserLoc;
726 }
727
728 2 Serializable::SizeType LinearBufferBase::getSerializeSizeLeft() const {
729 2 FW_ASSERT(this->m_capacity >= this->m_serLoc, static_cast<FwAssertArgType>(this->m_capacity),
730 static_cast<FwAssertArgType>(this->m_serLoc));
731 2 return this->m_capacity - this->m_serLoc;
732 }
733
734 FW_SERIALIZE_FORCE_INLINE_LBB SerializeStatus LinearBufferBase::copyRaw(SerialBufferBase& dest,
735 Serializable::SizeType size) {
736 // make sure there is sufficient size in destination
737 if (dest.getCapacity() < size) {
738 return FW_SERIALIZE_NO_ROOM_LEFT;
739 }
740 // make sure there is sufficient buffer in source
741 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 U8* buffAddr = this->m_buffAddr;
747
748 FW_ASSERT(buffAddr);
749 SerializeStatus stat = dest.setBuff(&buffAddr[this->m_deserLoc], size);
750 if (stat == FW_SERIALIZE_OK) {
751 this->m_deserLoc += size;
752 }
753 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 const U8* LinearBufferBase::getBuffAddrLeft() const {
781 const U8* buffAddr = this->m_buffAddr;
782 FW_ASSERT(buffAddr != nullptr);
783 return &buffAddr[this->m_deserLoc];
784 }
785
786 //!< gets address of end of serialization. Used to manually place data at the end
787 U8* LinearBufferBase::getBuffAddrSer() {
788 U8* buffAddr = this->m_buffAddr;
789 FW_ASSERT(buffAddr != nullptr);
790 return &buffAddr[this->m_serLoc];
791 }
792
793 #ifdef BUILD_UT
794 1 bool LinearBufferBase::operator==(const LinearBufferBase& other) const {
795
1/2
✗ Branch 11 not taken.
✓ Branch 12 taken 1 times.
1 if (this->m_serLoc != other.getSize()) {
796 return false;
797 }
798
799 1 const U8* us = this->m_buffAddr;
800 1 const U8* them = other.getBuffAddr();
801
802 1 FW_ASSERT(us);
803 1 FW_ASSERT(them);
804
805
2/2
✓ Branch 4 taken 51 times.
✓ Branch 5 taken 1 times.
52 for (Serializable::SizeType byte = 0; byte < this->m_serLoc; byte++) {
806
1/2
✗ Branch 4 not taken.
✓ Branch 5 taken 51 times.
51 if (us[byte] != them[byte]) {
807 return false;
808 }
809 }
810
811 1 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 5 ExternalSerializeBuffer::ExternalSerializeBuffer(U8* buffPtr, Serializable::SizeType size)
828 5 : LinearBufferBase(nullptr, 0) {
829
1/1
✓ Branch 4 taken 5 times.
5 this->setExtBuffer(buffPtr, size);
830 5 }
831
832 ExternalSerializeBuffer::ExternalSerializeBuffer() : LinearBufferBase(nullptr, 0) {
833 this->clear();
834 }
835
836 7 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 7 FW_ASSERT((buffPtr != nullptr) || (size == 0), static_cast<FwAssertArgType>(size));
840 7 this->clear();
841 7 this->setBuffAddrInternal(buffPtr);
842 7 this->setCapacityInternal(size);
843 7 }
844
845 8 void ExternalSerializeBuffer::clear() {
846 8 this->resetSer();
847 8 this->resetDeser();
848 8 this->setBuffAddrInternal(nullptr);
849 8 this->setCapacityInternal(0);
850 8 }
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