F´ Flight Software - C/C++ Documentation NASA-v1.6.0
A framework for building embedded system applications to NASA flight quality standards.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Serializable.cpp
Go to the documentation of this file.
2#include <cstring> // memcpy
3#include <Fw/Types/Assert.hpp>
5#include <cstdio>
6#include <FpConfig.hpp>
7#ifdef BUILD_UT
8#include <iomanip>
9#include <Fw/Types/String.hpp>
10#endif
11
12// Some macros/functions to optimize for architectures
13
14namespace Fw {
15
17 }
18
20 }
21
22#if FW_SERIALIZABLE_TO_STRING || FW_ENABLE_TEXT_LOGGING || BUILD_UT
23
24 void Serializable::toString(StringBase& text) const {
25 text = "NOSPEC"; // set to not specified.
26 }
27
28#endif
29
30#ifdef BUILD_UT
31 std::ostream& operator<<(std::ostream& os, const Serializable& val) {
32 Fw::String out;
33 val.toString(out);
34
35 os << out;
36
37 return os;
38 }
39#endif
40
42 m_serLoc(0), m_deserLoc(0) {
43 }
44
46 }
47
48 void SerializeBufferBase::copyFrom(const SerializeBufferBase& src) {
49 this->m_serLoc = src.m_serLoc;
50 this->m_deserLoc = src.m_deserLoc;
52 FW_ASSERT(this->getBuffAddr());
53 // destination has to be same or bigger
54 FW_ASSERT(src.getBuffLength() <= this->getBuffCapacity(),src.getBuffLength(),this->getBuffLength());
55 (void) memcpy(this->getBuffAddr(),src.getBuffAddr(),this->m_serLoc);
56 }
57
58 // Copy constructor doesn't make sense in this virtual class as there is nothing to copy. Derived classes should
59 // call the empty constructor and then call their own copy function
61 this->copyFrom(src);
62 return *this;
63 }
64
65 // serialization routines
66
68 if (this->m_serLoc + static_cast<NATIVE_UINT_TYPE>(sizeof(val)) - 1 >= this->getBuffCapacity()) {
70 }
71 FW_ASSERT(this->getBuffAddr());
72 this->getBuffAddr()[this->m_serLoc] = val;
73 this->m_serLoc += sizeof(val);
74 this->m_deserLoc = 0;
75
76 return FW_SERIALIZE_OK;
77 }
78
80 if (this->m_serLoc + static_cast<NATIVE_UINT_TYPE>(sizeof(val)) - 1 >= this->getBuffCapacity()) {
82 }
83 FW_ASSERT(this->getBuffAddr());
84 this->getBuffAddr()[this->m_serLoc + 0] = static_cast<U8>(val);
85 this->m_serLoc += sizeof(val);
86 this->m_deserLoc = 0;
87 return FW_SERIALIZE_OK;
88 }
89
90#if FW_HAS_16_BIT==1
92 if (this->m_serLoc + static_cast<NATIVE_UINT_TYPE>(sizeof(val)) - 1 >= this->getBuffCapacity()) {
94 }
95 FW_ASSERT(this->getBuffAddr());
96 // MSB first
97 this->getBuffAddr()[this->m_serLoc + 0] = static_cast<U8>(val >> 8);
98 this->getBuffAddr()[this->m_serLoc + 1] = static_cast<U8>(val);
99 this->m_serLoc += sizeof(val);
100 this->m_deserLoc = 0;
101 return FW_SERIALIZE_OK;
102 }
103
105 if (this->m_serLoc + static_cast<NATIVE_UINT_TYPE>(sizeof(val)) - 1 >= this->getBuffCapacity()) {
107 }
108 FW_ASSERT(this->getBuffAddr());
109 // MSB first
110 this->getBuffAddr()[this->m_serLoc + 0] = static_cast<U8>(val >> 8);
111 this->getBuffAddr()[this->m_serLoc + 1] = static_cast<U8>(val);
112 this->m_serLoc += sizeof(val);
113 this->m_deserLoc = 0;
114 return FW_SERIALIZE_OK;
115 }
116#endif
117#if FW_HAS_32_BIT==1
119 if (this->m_serLoc + static_cast<NATIVE_UINT_TYPE>(sizeof(val)) - 1 >= this->getBuffCapacity()) {
121 }
122 FW_ASSERT(this->getBuffAddr());
123 // MSB first
124 this->getBuffAddr()[this->m_serLoc + 0] = static_cast<U8>(val >> 24);
125 this->getBuffAddr()[this->m_serLoc + 1] = static_cast<U8>(val >> 16);
126 this->getBuffAddr()[this->m_serLoc + 2] = static_cast<U8>(val >> 8);
127 this->getBuffAddr()[this->m_serLoc + 3] = static_cast<U8>(val);
128 this->m_serLoc += sizeof(val);
129 this->m_deserLoc = 0;
130 return FW_SERIALIZE_OK;
131 }
132
134 if (this->m_serLoc + static_cast<NATIVE_UINT_TYPE>(sizeof(val)) - 1 >= this->getBuffCapacity()) {
136 }
137 FW_ASSERT(this->getBuffAddr());
138 // MSB first
139 this->getBuffAddr()[this->m_serLoc + 0] = static_cast<U8>(val >> 24);
140 this->getBuffAddr()[this->m_serLoc + 1] = static_cast<U8>(val >> 16);
141 this->getBuffAddr()[this->m_serLoc + 2] = static_cast<U8>(val >> 8);
142 this->getBuffAddr()[this->m_serLoc + 3] = static_cast<U8>(val);
143 this->m_serLoc += sizeof(val);
144 this->m_deserLoc = 0;
145 return FW_SERIALIZE_OK;
146 }
147#endif
148
149#if FW_HAS_64_BIT==1
151 if (this->m_serLoc + static_cast<NATIVE_UINT_TYPE>(sizeof(val)) - 1 >= this->getBuffCapacity()) {
153 }
154 FW_ASSERT(this->getBuffAddr());
155 // MSB first
156 this->getBuffAddr()[this->m_serLoc + 0] = static_cast<U8>(val >> 56);
157 this->getBuffAddr()[this->m_serLoc + 1] = static_cast<U8>(val >> 48);
158 this->getBuffAddr()[this->m_serLoc + 2] = static_cast<U8>(val >> 40);
159 this->getBuffAddr()[this->m_serLoc + 3] = static_cast<U8>(val >> 32);
160 this->getBuffAddr()[this->m_serLoc + 4] = static_cast<U8>(val >> 24);
161 this->getBuffAddr()[this->m_serLoc + 5] = static_cast<U8>(val >> 16);
162 this->getBuffAddr()[this->m_serLoc + 6] = static_cast<U8>(val >> 8);
163 this->getBuffAddr()[this->m_serLoc + 7] = static_cast<U8>(val);
164 this->m_serLoc += sizeof(val);
165 this->m_deserLoc = 0;
166 return FW_SERIALIZE_OK;
167 }
168
170 if (this->m_serLoc + static_cast<NATIVE_UINT_TYPE>(sizeof(val)) - 1 >= this->getBuffCapacity()) {
172 }
173 FW_ASSERT(this->getBuffAddr());
174 // MSB first
175 this->getBuffAddr()[this->m_serLoc + 0] = static_cast<U8>(val >> 56);
176 this->getBuffAddr()[this->m_serLoc + 1] = static_cast<U8>(val >> 48);
177 this->getBuffAddr()[this->m_serLoc + 2] = static_cast<U8>(val >> 40);
178 this->getBuffAddr()[this->m_serLoc + 3] = static_cast<U8>(val >> 32);
179 this->getBuffAddr()[this->m_serLoc + 4] = static_cast<U8>(val >> 24);
180 this->getBuffAddr()[this->m_serLoc + 5] = static_cast<U8>(val >> 16);
181 this->getBuffAddr()[this->m_serLoc + 6] = static_cast<U8>(val >> 8);
182 this->getBuffAddr()[this->m_serLoc + 7] = static_cast<U8>(val);
183 this->m_serLoc += sizeof(val);
184 this->m_deserLoc = 0;
185 return FW_SERIALIZE_OK;
186 }
187#endif
188
189#if FW_HAS_F64 && FW_HAS_64_BIT
190
192 // floating point values need to be byte-swapped as well, so copy to U64 and use that routine
193 U64 u64Val;
194 (void) memcpy(&u64Val, &val, sizeof(val));
195 return this->serialize(u64Val);
196
197 }
198
199#endif
200
202
203 // floating point values need to be byte-swapped as well, so copy to U32 and use that routine
204 U32 u32Val;
205 (void) memcpy(&u32Val, &val, sizeof(val));
206 return this->serialize(u32Val);
207
208 }
209
211 if (this->m_serLoc + static_cast<NATIVE_UINT_TYPE>(sizeof(U8)) - 1 >= this->getBuffCapacity()) {
213 }
214
215 FW_ASSERT(this->getBuffAddr());
216 if (val) {
217 this->getBuffAddr()[this->m_serLoc + 0] = FW_SERIALIZE_TRUE_VALUE;
218 } else {
219 this->getBuffAddr()[this->m_serLoc + 0] = FW_SERIALIZE_FALSE_VALUE;
220 }
221
222 this->m_serLoc += sizeof(U8);
223 this->m_deserLoc = 0;
224 return FW_SERIALIZE_OK;
225 }
226
228 if (this->m_serLoc + static_cast<NATIVE_UINT_TYPE>(sizeof(void*)) - 1
229 >= this->getBuffCapacity()) {
231 }
232
233 return this->serialize(reinterpret_cast<POINTER_CAST>(val));
234
235 }
236
238 // First serialize length
239 SerializeStatus stat;
240 if (not noLength) {
241 stat = this->serialize(static_cast<FwBuffSizeType>(length));
242 if (stat != FW_SERIALIZE_OK) {
243 return stat;
244 }
245 }
246
247 // make sure we have enough space
248 if (this->m_serLoc + length > this->getBuffCapacity()) {
250 }
251
252 // copy buffer to our buffer
253 (void) memcpy(&this->getBuffAddr()[this->m_serLoc], buff, length);
254 this->m_serLoc += length;
255 this->m_deserLoc = 0;
256
257 return FW_SERIALIZE_OK;
258 }
259
261 return val.serialize(*this);
262 }
263
265 const SerializeBufferBase& val) {
266 NATIVE_UINT_TYPE size = val.getBuffLength();
267 if (this->m_serLoc + size + static_cast<NATIVE_UINT_TYPE>(sizeof(FwBuffSizeType))
268 > this->getBuffCapacity()) {
270 }
271
272 // First, serialize size
273 SerializeStatus stat = this->serialize(static_cast<FwBuffSizeType>(size));
274 if (stat != FW_SERIALIZE_OK) {
275 return stat;
276 }
277
278 FW_ASSERT(this->getBuffAddr());
279 FW_ASSERT(val.getBuffAddr());
280 // serialize buffer
281 (void) memcpy(&this->getBuffAddr()[this->m_serLoc], val.getBuffAddr(), size);
282 this->m_serLoc += size;
283 this->m_deserLoc = 0;
284
285 return FW_SERIALIZE_OK;
286 }
287
288 // deserialization routines
289
291 // check for room
292 if (this->getBuffLength() == this->m_deserLoc) {
294 } else if (this->getBuffLength() - this->m_deserLoc < static_cast<NATIVE_UINT_TYPE>(sizeof(val))) {
296 }
297 // read from current location
298 FW_ASSERT(this->getBuffAddr());
299 val = this->getBuffAddr()[this->m_deserLoc + 0];
300 this->m_deserLoc += sizeof(val);
301 return FW_SERIALIZE_OK;
302 }
303
305 // check for room
306 if (this->getBuffLength() == this->m_deserLoc) {
308 } else if (this->getBuffLength() - this->m_deserLoc < static_cast<NATIVE_UINT_TYPE>(sizeof(val))) {
310 }
311 // read from current location
312 FW_ASSERT(this->getBuffAddr());
313 val = static_cast<I8>(this->getBuffAddr()[this->m_deserLoc + 0]);
314 this->m_deserLoc += sizeof(val);
315 return FW_SERIALIZE_OK;
316 }
317
318#if FW_HAS_16_BIT==1
320 // check for room
321 if (this->getBuffLength() == this->m_deserLoc) {
323 } else if (this->getBuffLength() - this->m_deserLoc < static_cast<NATIVE_UINT_TYPE>(sizeof(val))) {
325 }
326 // read from current location
327 FW_ASSERT(this->getBuffAddr());
328 // MSB first
329 val = static_cast<U16>(
330 ((this->getBuffAddr()[this->m_deserLoc + 1]) << 0) |
331 ((this->getBuffAddr()[this->m_deserLoc + 0]) << 8)
332 );
333 this->m_deserLoc += sizeof(val);
334 return FW_SERIALIZE_OK;
335 }
336
338 // check for room
339 if (this->getBuffLength() == this->m_deserLoc) {
341 } else if (this->getBuffLength() - this->m_deserLoc < static_cast<NATIVE_UINT_TYPE>(sizeof(val))) {
343 }
344 // read from current location
345 FW_ASSERT(this->getBuffAddr());
346 // MSB first
347 val = static_cast<I16>(
348 ((this->getBuffAddr()[this->m_deserLoc + 1]) << 0) |
349 ((this->getBuffAddr()[this->m_deserLoc + 0]) << 8)
350 );
351 this->m_deserLoc += sizeof(val);
352 return FW_SERIALIZE_OK;
353 }
354#endif
355#if FW_HAS_32_BIT==1
357 // check for room
358 if (this->getBuffLength() == this->m_deserLoc) {
360 } else if (this->getBuffLength() - this->m_deserLoc < static_cast<NATIVE_UINT_TYPE>(sizeof(val))) {
362 }
363 // read from current location
364 FW_ASSERT(this->getBuffAddr());
365 // MSB first
366 val = (static_cast<U32>(this->getBuffAddr()[this->m_deserLoc + 3]) << 0)
367 | (static_cast<U32>(this->getBuffAddr()[this->m_deserLoc + 2]) << 8)
368 | (static_cast<U32>(this->getBuffAddr()[this->m_deserLoc + 1]) << 16)
369 | (static_cast<U32>(this->getBuffAddr()[this->m_deserLoc + 0]) << 24);
370 this->m_deserLoc += sizeof(val);
371 return FW_SERIALIZE_OK;
372 }
373
375 // check for room
376 if (this->getBuffLength() == this->m_deserLoc) {
378 } else if (this->getBuffLength() - this->m_deserLoc < static_cast<NATIVE_UINT_TYPE>(sizeof(val))) {
380 }
381 // read from current location
382 FW_ASSERT(this->getBuffAddr());
383 // MSB first
384 val = (static_cast<I32>(this->getBuffAddr()[this->m_deserLoc + 3]) << 0)
385 | (static_cast<I32>(this->getBuffAddr()[this->m_deserLoc + 2]) << 8)
386 | (static_cast<I32>(this->getBuffAddr()[this->m_deserLoc + 1]) << 16)
387 | (static_cast<I32>(this->getBuffAddr()[this->m_deserLoc + 0]) << 24);
388 this->m_deserLoc += sizeof(val);
389 return FW_SERIALIZE_OK;
390 }
391#endif
392
393#if FW_HAS_64_BIT==1
394
396 // check for room
397 if (this->getBuffLength() == this->m_deserLoc) {
399 } else if (this->getBuffLength() - this->m_deserLoc < static_cast<NATIVE_UINT_TYPE>(sizeof(val))) {
401 }
402 // read from current location
403 FW_ASSERT(this->getBuffAddr());
404 // MSB first
405 val = (static_cast<U64>(this->getBuffAddr()[this->m_deserLoc + 7]) << 0)
406 | (static_cast<U64>(this->getBuffAddr()[this->m_deserLoc + 6]) << 8)
407 | (static_cast<U64>(this->getBuffAddr()[this->m_deserLoc + 5]) << 16)
408 | (static_cast<U64>(this->getBuffAddr()[this->m_deserLoc + 4]) << 24)
409 | (static_cast<U64>(this->getBuffAddr()[this->m_deserLoc + 3]) << 32)
410 | (static_cast<U64>(this->getBuffAddr()[this->m_deserLoc + 2]) << 40)
411 | (static_cast<U64>(this->getBuffAddr()[this->m_deserLoc + 1]) << 48)
412 | (static_cast<U64>(this->getBuffAddr()[this->m_deserLoc + 0]) << 56);
413
414 this->m_deserLoc += sizeof(val);
415 return FW_SERIALIZE_OK;
416 }
417
419 // check for room
420 if (this->getBuffLength() == this->m_deserLoc) {
422 } else if (this->getBuffLength() - this->m_deserLoc < static_cast<NATIVE_UINT_TYPE>(sizeof(val))) {
424 }
425 // read from current location
426 FW_ASSERT(this->getBuffAddr());
427 // MSB first
428 val = (static_cast<I64>(this->getBuffAddr()[this->m_deserLoc + 7]) << 0)
429 | (static_cast<I64>(this->getBuffAddr()[this->m_deserLoc + 6]) << 8)
430 | (static_cast<I64>(this->getBuffAddr()[this->m_deserLoc + 5]) << 16)
431 | (static_cast<I64>(this->getBuffAddr()[this->m_deserLoc + 4]) << 24)
432 | (static_cast<I64>(this->getBuffAddr()[this->m_deserLoc + 3]) << 32)
433 | (static_cast<I64>(this->getBuffAddr()[this->m_deserLoc + 2]) << 40)
434 | (static_cast<I64>(this->getBuffAddr()[this->m_deserLoc + 1]) << 48)
435 | (static_cast<I64>(this->getBuffAddr()[this->m_deserLoc + 0]) << 56);
436 this->m_deserLoc += sizeof(val);
437 return FW_SERIALIZE_OK;
438 }
439#endif
440
441#if FW_HAS_F64
442
444
445 // deserialize as 64-bit int to handle endianness
446 U64 tempVal;
447 SerializeStatus stat = this->deserialize(tempVal);
448 if (stat != FW_SERIALIZE_OK) {
449 return stat;
450 }
451 // copy to argument
452 (void) memcpy(&val, &tempVal, sizeof(val));
453
454 return FW_SERIALIZE_OK;
455 }
456
457#endif
458
460 // check for room
461 if (this->getBuffLength() == this->m_deserLoc) {
463 } else if (this->getBuffLength() - this->m_deserLoc < static_cast<NATIVE_UINT_TYPE>(sizeof(U8))) {
465 }
466 // read from current location
467 FW_ASSERT(this->getBuffAddr());
468 if (FW_SERIALIZE_TRUE_VALUE == this->getBuffAddr()[this->m_deserLoc + 0]) {
469 val = true;
470 } else if (FW_SERIALIZE_FALSE_VALUE == this->getBuffAddr()[this->m_deserLoc + 0]) {
471 val = false;
472 } else {
474 }
475
476 this->m_deserLoc += sizeof(U8);
477 return FW_SERIALIZE_OK;
478 }
479
481 return this->deserialize(reinterpret_cast<POINTER_CAST&>(val));
482 }
483
485 // deserialize as 64-bit int to handle endianness
486 U32 tempVal;
487 SerializeStatus stat = this->deserialize(tempVal);
488 if (stat != FW_SERIALIZE_OK) {
489 return stat;
490 }
491 (void) memcpy(&val, &tempVal, sizeof(val));
492
493 return FW_SERIALIZE_OK;
494 }
495
497
498 FW_ASSERT(this->getBuffAddr());
499
500 if (not noLength) {
501 FwBuffSizeType storedLength;
502
503 SerializeStatus stat = this->deserialize(storedLength);
504
505 if (stat != FW_SERIALIZE_OK) {
506 return stat;
507 }
508
509 // make sure it fits
510 if ((storedLength > this->getBuffLeft()) or (storedLength > length)) {
512 }
513
514 (void) memcpy(buff, &this->getBuffAddr()[this->m_deserLoc], storedLength);
515
516 length = static_cast<NATIVE_UINT_TYPE>(storedLength);
517
518 } else {
519 // make sure enough is left
520 if (length > this->getBuffLeft()) {
522 }
523
524 (void) memcpy(buff, &this->getBuffAddr()[this->m_deserLoc], length);
525 }
526
527 this->m_deserLoc += length;
528 return FW_SERIALIZE_OK;
529 }
530
532 return val.deserialize(*this);
533 }
534
536
537 FW_ASSERT(val.getBuffAddr());
539
540 FwBuffSizeType storedLength;
541
542 stat = this->deserialize(storedLength);
543
544 if (stat != FW_SERIALIZE_OK) {
545 return stat;
546 }
547
548 // make sure destination has enough room
549
550 if ((storedLength > val.getBuffCapacity()) or (storedLength > this->getBuffLeft()) ) {
552 }
553
554 FW_ASSERT(this->getBuffAddr());
555 (void) memcpy(val.getBuffAddr(), &this->getBuffAddr()[this->m_deserLoc],
556 storedLength);
557
558 stat = val.setBuffLen(storedLength);
559
560 if (stat != FW_SERIALIZE_OK) {
561 return stat;
562 }
563
564 this->m_deserLoc += storedLength;
565
566 return FW_SERIALIZE_OK;
567 }
568
570 this->m_deserLoc = 0;
571 this->m_serLoc = 0;
572 }
573
575 this->m_deserLoc = 0;
576 }
577
579 {
580 // check for room
581 if (this->getBuffLength() == this->m_deserLoc) {
583 } else if (this->getBuffLength() - this->m_deserLoc < numBytesToSkip) {
585 }
586 // update location in buffer to skip the value
587 this->m_deserLoc += numBytesToSkip;
588 return FW_SERIALIZE_OK;
589 }
590
592 return this->m_serLoc;
593 }
594
596 if (this->getBuffCapacity() < length) {
598 } else {
599 FW_ASSERT(src);
600 FW_ASSERT(this->getBuffAddr());
601 memcpy(this->getBuffAddr(), src, length);
602 this->m_serLoc = length;
603 this->m_deserLoc = 0;
604 return FW_SERIALIZE_OK;
605 }
606 }
607
609 if (this->getBuffCapacity() < length) {
611 } else {
612 this->m_serLoc = length;
613 this->m_deserLoc = 0;
614 return FW_SERIALIZE_OK;
615 }
616 }
617
619 return this->m_serLoc - this->m_deserLoc;
620 }
621
623 // make sure there is sufficient size in destination
624 if (dest.getBuffCapacity() < size) {
626 }
627 // otherwise, set destination buffer to data from deserialization pointer plus size
628 SerializeStatus stat = dest.setBuff(&this->getBuffAddr()[this->m_deserLoc],size);
629 if (stat == FW_SERIALIZE_OK) {
630 this->m_deserLoc += size;
631 }
632 return stat;
633
634 }
635
637 // make sure there is sufficient size in destination
638 if (dest.getBuffCapacity() < size + dest.getBuffLength()) {
640 }
641 // make sure there is sufficient buffer in source
642 if (this->getBuffLeft() < size) {
644 }
645
646 // otherwise, serialize bytes to destination without writing length
647 SerializeStatus stat = dest.serialize(&this->getBuffAddr()[this->m_deserLoc], size, true);
648 if (stat == FW_SERIALIZE_OK) {
649 this->m_deserLoc += size;
650 }
651 return stat;
652
653 }
654
655 // return address of buffer not yet deserialized. This is used
656 // to copy the remainder of a buffer.
658 return &this->getBuffAddr()[this->m_deserLoc];
659 }
660
663 return &this->getBuffAddr()[this->m_serLoc];
664 }
665
666#ifdef BUILD_UT
667 bool SerializeBufferBase::operator==(const SerializeBufferBase& other) const {
668 if (this->getBuffLength() != other.getBuffLength()) {
669 return false;
670 }
671
672 const U8* us = this->getBuffAddr();
673 const U8* them = other.getBuffAddr();
674
675 FW_ASSERT(us);
676 FW_ASSERT(them);
677
678 for (NATIVE_UINT_TYPE byte = 0; byte < this->getBuffLength(); byte++) {
679 if (us[byte] != them[byte]) {
680 return false;
681 }
682 }
683
684 return true;
685 }
686
687 std::ostream& operator<<(std::ostream& os, const SerializeBufferBase& buff) {
688
689 const U8* us = buff.getBuffAddr();
690
691 FW_ASSERT(us);
692
693 for (NATIVE_UINT_TYPE byte = 0; byte < buff.getBuffLength(); byte++) {
694 os << "[" << std::setw(2) << std::hex << std::setfill('0') << us[byte] << "]" << std::dec;
695 }
696
697 return os;
698 }
699#endif
700
702 this->setExtBuffer(buffPtr,size);
703 }
704
706 this->clear();
707 }
708
710 FW_ASSERT(buffPtr);
711 this->m_buff = buffPtr;
712 this->m_buffSize = size;
713 }
714
716 this->m_buff = nullptr;
717 this->m_buffSize = 0;
718 }
719
721 return this->m_buffSize;
722 }
723
725 return this->m_buff;
726 }
727
729 return this->m_buff;
730 }
731
732}
733
#define FW_ASSERT(...)
Definition Assert.hpp:7
PlatformPointerCastType POINTER_CAST
Definition BasicTypes.h:53
int8_t I8
8-bit signed integer
Definition BasicTypes.h:25
float F32
32-bit floating point
Definition BasicTypes.h:45
uint8_t U8
8-bit unsigned integer
Definition BasicTypes.h:26
PlatformUIntType NATIVE_UINT_TYPE
Definition BasicTypes.h:52
#define FW_SERIALIZE_TRUE_VALUE
Value encoded during serialization for boolean true.
Definition FpConfig.h:73
#define FW_SERIALIZE_FALSE_VALUE
Value encoded during serialization for boolean false.
Definition FpConfig.h:77
U16 FwBuffSizeType
Definition FpConfig.h:30
C++-compatible configuration header for fprime configuration.
Declares ISF string base class.
NATIVE_UINT_TYPE getBuffCapacity() const
returns capacity, not current size, of buffer
U8 * getBuffAddr()
gets buffer address for data filling
void setExtBuffer(U8 *buffPtr, NATIVE_UINT_TYPE size)
Set the external buffer.
void clear()
clear external buffer
ExternalSerializeBuffer()
default constructor
forward declaration
Serializable()
Default constructor.
virtual ~Serializable()
destructor
virtual SerializeStatus deserialize(SerializeBufferBase &buffer)=0
deserialize to contents
virtual SerializeStatus serialize(SerializeBufferBase &buffer) const =0
serialize contents
NATIVE_UINT_TYPE getBuffLeft() const
returns how much deserialization buffer is left
void resetDeser()
reset deserialization to beginning
SerializeStatus setBuffLen(NATIVE_UINT_TYPE length)
sets buffer length manually after filling with data
const U8 * getBuffAddrLeft() const
gets address of remaining non-deserialized data.
void resetSer()
reset to beginning of buffer to reuse for serialization
SerializeBufferBase()
default constructor
SerializeStatus setBuff(const U8 *src, NATIVE_UINT_TYPE length)
sets buffer contents and size
SerializeStatus deserializeSkip(NATIVE_UINT_TYPE numBytesToSkip)
Skips the number of specified bytes for deserialization.
SerializeBufferBase & operator=(const SerializeBufferBase &src)
equal operator
virtual NATIVE_UINT_TYPE getBuffCapacity() const =0
returns capacity, not current size, of buffer
SerializeStatus deserialize(U8 &val)
deserialize 8-bit unsigned int
virtual ~SerializeBufferBase()
destructor
U8 * getBuffAddrSer()
gets address of end of serialization. DANGEROUS! Need to know max buffer size and adjust when done
SerializeStatus serialize(U8 val)
serialize 8-bit unsigned int
SerializeStatus copyRawOffset(SerializeBufferBase &dest, NATIVE_UINT_TYPE size)
directly copies buffer without looking for a size in the stream.
SerializeStatus copyRaw(SerializeBufferBase &dest, NATIVE_UINT_TYPE size)
directly copies buffer without looking for a size in the stream.
virtual U8 * getBuffAddr()=0
gets buffer address for data filling
NATIVE_UINT_TYPE getBuffLength() const
returns current buffer size
Definition Buffer.cpp:21
SerializeStatus
forward declaration for string
@ FW_DESERIALIZE_FORMAT_ERROR
Deserialization data had incorrect values (unexpected data types)
@ FW_DESERIALIZE_BUFFER_EMPTY
Deserialization buffer was empty when trying to read more data.
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.
@ FW_DESERIALIZE_SIZE_MISMATCH
Data was left in the buffer, but not enough to deserialize.
@ FW_SERIALIZE_NO_ROOM_LEFT
No room left in the buffer to serialize data.
#define U64(C)
Definition sha.h:176