F´ Flight Software - C/C++ Documentation  NASA-v1.5.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 <string.h> // memcpy
3 #include <Fw/Types/Assert.hpp>
5 #include <stdio.h>
6 
7 #ifdef BUILD_UT
8 #include <iomanip>
10 #endif
11 
12 // Some macros/functions to optimize for architectures
13 
14 namespace Fw {
15 
17  }
18 
20  }
21 
22 #if FW_SERIALIZABLE_TO_STRING || 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) {
33  val.toString(out);
34 
35  os << out;
36 
37  return os;
38  }
39 #endif
40 
41  SerializeBufferBase::SerializeBufferBase() :
42  m_serLoc(0), m_deserLoc(0) {
43  }
44 
46  }
47 
49  this->m_serLoc = src.m_serLoc;
50  this->m_deserLoc = src.m_deserLoc;
51  FW_ASSERT(src.getBuffAddr());
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+1);
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
60  const SerializeBufferBase& SerializeBufferBase::operator=(const SerializeBufferBase &src) { // lgtm[cpp/rule-of-two]
61  this->copyFrom(src);
62  return *this;
63  }
64 
65  // serialization routines
66 
68  if (this->m_serLoc + (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 + (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 + (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 + (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 + (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 + (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 + (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 + (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
190 
192  // floating point values need to be byte-swapped as well, so copy to U64 and use that routine
193  U64 u64Val;
194 
195  *reinterpret_cast<F64*>(&u64Val) = val;
196  return this->serialize(u64Val);
197 
198  }
199 
200 #endif
201 
203 
204  // floating point values need to be byte-swapped as well, so copy to U32 and use that routine
205  U32 u32Val;
206 
207  *reinterpret_cast<F32*>(&u32Val) = val;
208  return this->serialize(u32Val);
209 
210  }
211 
213  if (this->m_serLoc + (NATIVE_UINT_TYPE) sizeof(U8) - 1 >= this->getBuffCapacity()) {
215  }
216 
217  FW_ASSERT(this->getBuffAddr());
218  if (val) {
219  this->getBuffAddr()[this->m_serLoc + 0] = FW_SERIALIZE_TRUE_VALUE;
220  } else {
221  this->getBuffAddr()[this->m_serLoc + 0] = FW_SERIALIZE_FALSE_VALUE;
222  }
223 
224  this->m_serLoc += sizeof(U8);
225  this->m_deserLoc = 0;
226  return FW_SERIALIZE_OK;
227  }
228 
230  if (this->m_serLoc + (NATIVE_UINT_TYPE) sizeof(void*) - 1
231  >= this->getBuffCapacity()) {
233  }
234 
235  return this->serialize((POINTER_CAST) val);
236 
237  }
238 
240  // First serialize length
241  SerializeStatus stat;
242  if (not noLength) {
243  stat = this->serialize(static_cast<FwBuffSizeType>(length));
244  if (stat != FW_SERIALIZE_OK) {
245  return stat;
246  }
247  }
248 
249  // make sure we have enough space
250  if (this->m_serLoc + length > this->getBuffCapacity()) {
252  }
253 
254  // copy buffer to our buffer
255  (void) memcpy(&this->getBuffAddr()[this->m_serLoc], buff, length);
256  this->m_serLoc += length;
257  this->m_deserLoc = 0;
258 
259  return FW_SERIALIZE_OK;
260  }
261 
263  return val.serialize(*this);
264  }
265 
267  const SerializeBufferBase& val) {
268  NATIVE_UINT_TYPE size = val.getBuffLength();
269  if (this->m_serLoc + size + (NATIVE_UINT_TYPE) sizeof(FwBuffSizeType)
270  > this->getBuffCapacity()) {
272  }
273 
274  // First, serialize size
275  SerializeStatus stat = this->serialize((FwBuffSizeType)size);
276  if (stat != FW_SERIALIZE_OK) {
277  return stat;
278  }
279 
280  FW_ASSERT(this->getBuffAddr());
281  FW_ASSERT(val.getBuffAddr());
282  // serialize buffer
283  (void) memcpy(&this->getBuffAddr()[this->m_serLoc], val.getBuffAddr(), size);
284  this->m_serLoc += size;
285  this->m_deserLoc = 0;
286 
287  return FW_SERIALIZE_OK;
288  }
289 
290  // deserialization routines
291 
293  // check for room
294  if (this->getBuffLength() == this->m_deserLoc) {
296  } else if (this->getBuffLength() - this->m_deserLoc < (NATIVE_UINT_TYPE)sizeof(val)) {
298  }
299  // read from current location
300  FW_ASSERT(this->getBuffAddr());
301  val = this->getBuffAddr()[this->m_deserLoc + 0];
302  this->m_deserLoc += sizeof(val);
303  return FW_SERIALIZE_OK;
304  }
305 
307  // check for room
308  if (this->getBuffLength() == this->m_deserLoc) {
310  } else if (this->getBuffLength() - this->m_deserLoc < (NATIVE_UINT_TYPE)sizeof(val)) {
312  }
313  // read from current location
314  FW_ASSERT(this->getBuffAddr());
315  val = (I8) this->getBuffAddr()[this->m_deserLoc + 0];
316  this->m_deserLoc += sizeof(val);
317  return FW_SERIALIZE_OK;
318  }
319 
320 #if FW_HAS_16_BIT==1
322  // check for room
323  if (this->getBuffLength() == this->m_deserLoc) {
325  } else if (this->getBuffLength() - this->m_deserLoc < (NATIVE_UINT_TYPE)sizeof(val)) {
327  }
328  // read from current location
329  FW_ASSERT(this->getBuffAddr());
330  // MSB first
331  val = (U16) (this->getBuffAddr()[this->m_deserLoc + 1] << 0)
332  | (U16) (this->getBuffAddr()[this->m_deserLoc + 0] << 8);
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 < (NATIVE_UINT_TYPE)sizeof(val)) {
343  }
344  // read from current location
345  FW_ASSERT(this->getBuffAddr());
346  // MSB first
347  val = (I16) (this->getBuffAddr()[this->m_deserLoc + 1] << 0)
348  | (I16) (this->getBuffAddr()[this->m_deserLoc + 0] << 8);
349  this->m_deserLoc += sizeof(val);
350  return FW_SERIALIZE_OK;
351  }
352 #endif
353 #if FW_HAS_32_BIT==1
355  // check for room
356  if (this->getBuffLength() == this->m_deserLoc) {
358  } else if (this->getBuffLength() - this->m_deserLoc < (NATIVE_UINT_TYPE)sizeof(val)) {
360  }
361  // read from current location
362  FW_ASSERT(this->getBuffAddr());
363  // MSB first
364  val = ((U32) this->getBuffAddr()[this->m_deserLoc + 3] << 0)
365  | ((U32) this->getBuffAddr()[this->m_deserLoc + 2] << 8)
366  | ((U32) this->getBuffAddr()[this->m_deserLoc + 1] << 16)
367  | ((U32) this->getBuffAddr()[this->m_deserLoc + 0] << 24);
368  this->m_deserLoc += sizeof(val);
369  return FW_SERIALIZE_OK;
370  }
371 
373  // check for room
374  if (this->getBuffLength() == this->m_deserLoc) {
376  } else if (this->getBuffLength() - this->m_deserLoc < (NATIVE_UINT_TYPE)sizeof(val)) {
378  }
379  // read from current location
380  FW_ASSERT(this->getBuffAddr());
381  // MSB first
382  val = ((U32) this->getBuffAddr()[this->m_deserLoc + 3] << 0)
383  | ((U32) this->getBuffAddr()[this->m_deserLoc + 2] << 8)
384  | ((U32) this->getBuffAddr()[this->m_deserLoc + 1] << 16)
385  | ((U32) this->getBuffAddr()[this->m_deserLoc + 0] << 24);
386  this->m_deserLoc += sizeof(val);
387  return FW_SERIALIZE_OK;
388  }
389 #endif
390 
391 #if FW_HAS_64_BIT==1
392 
394  // check for room
395  if (this->getBuffLength() == this->m_deserLoc) {
397  } else if (this->getBuffLength() - this->m_deserLoc < (NATIVE_UINT_TYPE)sizeof(val)) {
399  }
400  // read from current location
401  FW_ASSERT(this->getBuffAddr());
402  // MSB first
403  val = ((U64) this->getBuffAddr()[this->m_deserLoc + 7] << 0)
404  | ((U64) this->getBuffAddr()[this->m_deserLoc + 6] << 8)
405  | ((U64) this->getBuffAddr()[this->m_deserLoc + 5] << 16)
406  | ((U64) this->getBuffAddr()[this->m_deserLoc + 4] << 24)
407  | ((U64) this->getBuffAddr()[this->m_deserLoc + 3] << 32)
408  | ((U64) this->getBuffAddr()[this->m_deserLoc + 2] << 40)
409  | ((U64) this->getBuffAddr()[this->m_deserLoc + 1] << 48)
410  | ((U64) this->getBuffAddr()[this->m_deserLoc + 0] << 56);
411 
412  this->m_deserLoc += sizeof(val);
413  return FW_SERIALIZE_OK;
414  }
415 
417  // check for room
418  if (this->getBuffLength() == this->m_deserLoc) {
420  } else if (this->getBuffLength() - this->m_deserLoc < (NATIVE_UINT_TYPE)sizeof(val)) {
422  }
423  // read from current location
424  FW_ASSERT(this->getBuffAddr());
425  // MSB first
426  val = ((I64) this->getBuffAddr()[this->m_deserLoc + 7] << 0)
427  | ((I64) this->getBuffAddr()[this->m_deserLoc + 6] << 8)
428  | ((I64) this->getBuffAddr()[this->m_deserLoc + 5] << 16)
429  | ((I64) this->getBuffAddr()[this->m_deserLoc + 4] << 24)
430  | ((I64) this->getBuffAddr()[this->m_deserLoc + 3] << 32)
431  | ((I64) this->getBuffAddr()[this->m_deserLoc + 2] << 40)
432  | ((I64) this->getBuffAddr()[this->m_deserLoc + 1] << 48)
433  | ((I64) this->getBuffAddr()[this->m_deserLoc + 0] << 56);
434  this->m_deserLoc += sizeof(val);
435  return FW_SERIALIZE_OK;
436  }
437 #endif
438 
439 #if FW_HAS_F64
440 
442 
443  // deserialize as 64-bit int to handle endianness
444  U64 tempVal;
445  SerializeStatus stat = this->deserialize(tempVal);
446  if (stat != FW_SERIALIZE_OK) {
447  return stat;
448  }
449 
450  // copy to argument
451  val = *reinterpret_cast<F64*>(&tempVal);
452 
453  return FW_SERIALIZE_OK;
454  }
455 
456 #endif
457 
459  // check for room
460  if (this->getBuffLength() == this->m_deserLoc) {
462  } else if (this->getBuffLength() - this->m_deserLoc < (NATIVE_UINT_TYPE)sizeof(U8)) {
464  }
465  // read from current location
466  FW_ASSERT(this->getBuffAddr());
467  if (FW_SERIALIZE_TRUE_VALUE == this->getBuffAddr()[this->m_deserLoc + 0]) {
468  val = true;
469  } else if (FW_SERIALIZE_FALSE_VALUE == this->getBuffAddr()[this->m_deserLoc + 0]) {
470  val = false;
471  } else {
473  }
474 
475  this->m_deserLoc += sizeof(U8);
476  return FW_SERIALIZE_OK;
477  }
478 
480  return this->deserialize((POINTER_CAST&) val);
481  }
482 
484  // deserialize as 64-bit int to handle endianness
485  U32 tempVal;
486  SerializeStatus stat = this->deserialize(tempVal);
487  if (stat != FW_SERIALIZE_OK) {
488  return stat;
489  }
490 
491  // copy to argument
492  val = *reinterpret_cast<F32*>(&tempVal);
493 
494  return FW_SERIALIZE_OK;
495  }
496 
498 
499  FW_ASSERT(this->getBuffAddr());
500 
501  if (not noLength) {
502  FwBuffSizeType storedLength;
503 
504  SerializeStatus stat = this->deserialize(storedLength);
505 
506  if (stat != FW_SERIALIZE_OK) {
507  return stat;
508  }
509 
510  // make sure it fits
511  if ((storedLength > this->getBuffLeft()) or (storedLength > length)) {
513  }
514 
515  (void) memcpy(buff, &this->getBuffAddr()[this->m_deserLoc], storedLength);
516 
517  length = static_cast<NATIVE_UINT_TYPE>(storedLength);
518 
519  } else {
520  // make sure enough is left
521  if (length > this->getBuffLeft()) {
523  }
524 
525  (void) memcpy(buff, &this->getBuffAddr()[this->m_deserLoc], length);
526  }
527 
528  this->m_deserLoc += length;
529  return FW_SERIALIZE_OK;
530  }
531 
533  return val.deserialize(*this);
534  }
535 
537 
538  FW_ASSERT(val.getBuffAddr());
540 
541  FwBuffSizeType storedLength;
542 
543  stat = this->deserialize(storedLength);
544 
545  if (stat != FW_SERIALIZE_OK) {
546  return stat;
547  }
548 
549  // make sure destination has enough room
550 
551  if ((storedLength > val.getBuffCapacity()) or (storedLength > this->getBuffLeft()) ) {
553  }
554 
555  FW_ASSERT(this->getBuffAddr());
556  (void) memcpy(val.getBuffAddr(), &this->getBuffAddr()[this->m_deserLoc],
557  storedLength);
558 
559  stat = val.setBuffLen(storedLength);
560 
561  if (stat != FW_SERIALIZE_OK) {
562  return stat;
563  }
564 
565  this->m_deserLoc += storedLength;
566 
567  return FW_SERIALIZE_OK;
568  }
569 
571  this->m_deserLoc = 0;
572  this->m_serLoc = 0;
573  }
574 
576  this->m_deserLoc = 0;
577  }
578 
580  {
581  // check for room
582  if (this->getBuffLength() == this->m_deserLoc) {
584  } else if (this->getBuffLength() - this->m_deserLoc < numBytesToSkip) {
586  }
587  // update location in buffer to skip the value
588  this->m_deserLoc += numBytesToSkip;
589  return FW_SERIALIZE_OK;
590  }
591 
593  return this->m_serLoc;
594  }
595 
597  if (this->getBuffCapacity() < length) {
599  } else {
600  FW_ASSERT(src);
601  FW_ASSERT(this->getBuffAddr());
602  memcpy(this->getBuffAddr(), src, length);
603  this->m_serLoc = length;
604  this->m_deserLoc = 0;
605  return FW_SERIALIZE_OK;
606  }
607  }
608 
610  if (this->getBuffCapacity() < length) {
612  } else {
613  this->m_serLoc = length;
614  this->m_deserLoc = 0;
615  return FW_SERIALIZE_OK;
616  }
617  }
618 
620  return this->m_serLoc - this->m_deserLoc;
621  }
622 
624  // make sure there is sufficient size in destination
625  if (dest.getBuffCapacity() < size) {
627  }
628  // otherwise, set destination buffer to data from deserialization pointer plus size
629  SerializeStatus stat = dest.setBuff(&this->getBuffAddr()[this->m_deserLoc],size);
630  if (FW_SERIALIZE_OK) {
631  this->m_deserLoc += size;
632  }
633  return stat;
634 
635  }
636 
638  // make sure there is sufficient size in destination
639  if (dest.getBuffCapacity() < size + dest.getBuffLength()) {
641  }
642  // make sure there is sufficient buffer in source
643  if (this->getBuffLeft() < size) {
645  }
646 
647  // otherwise, serialize bytes to destination without writing length
648  SerializeStatus stat = dest.serialize(&this->getBuffAddr()[this->m_deserLoc], size, true);
649  if (stat == FW_SERIALIZE_OK) {
650  this->m_deserLoc += size;
651  }
652  return stat;
653 
654  }
655 
656  // return address of buffer not yet deserialized. This is used
657  // to copy the remainder of a buffer.
659  return &this->getBuffAddr()[this->m_deserLoc];
660  }
661 
664  return &this->getBuffAddr()[this->m_serLoc];
665  }
666 
667 #ifdef BUILD_UT
668  bool SerializeBufferBase::operator==(const SerializeBufferBase& other) const {
669  if (this->getBuffLength() != other.getBuffLength()) {
670  return false;
671  }
672 
673  const U8* us = this->getBuffAddr();
674  const U8* them = other.getBuffAddr();
675 
676  FW_ASSERT(us);
677  FW_ASSERT(them);
678 
679  for (NATIVE_UINT_TYPE byte = 0; byte < this->getBuffLength(); byte++) {
680  if (us[byte] != them[byte]) {
681  return false;
682  }
683  }
684 
685  return true;
686  }
687 
688  std::ostream& operator<<(std::ostream& os, const SerializeBufferBase& buff) {
689 
690  const U8* us = buff.getBuffAddr();
691 
692  FW_ASSERT(us);
693 
694  for (NATIVE_UINT_TYPE byte = 0; byte < buff.getBuffLength(); byte++) {
695  os << "[" << std::setw(2) << std::hex << std::setfill('0') << (NATIVE_UINT_TYPE)us[byte] << "]" << std::dec;
696  }
697 
698  return os;
699  }
700 #endif
701 
703  this->setExtBuffer(buffPtr,size);
704  }
705 
707  this->clear();
708  }
709 
711  FW_ASSERT(buffPtr);
712  this->m_buff = buffPtr;
713  this->m_buffSize = size;
714  }
715 
717  this->m_buff = 0;
718  this->m_buffSize = 0;
719  }
720 
722  return this->m_buffSize;
723  }
724 
726  return this->m_buff;
727  }
728 
730  return this->m_buff;
731  }
732 
733 }
734 
StringType.hpp
Declares ISF string base class.
FW_SERIALIZE_TRUE_VALUE
#define FW_SERIALIZE_TRUE_VALUE
Value encoded during serialization for boolean true.
Definition: FpConfig.hpp:43
Fw::FW_DESERIALIZE_BUFFER_EMPTY
@ FW_DESERIALIZE_BUFFER_EMPTY
Deserialization buffer was empty when trying to read more data.
Definition: Serializable.hpp:18
Fw::SerializeBufferBase::getBuffAddrLeft
const U8 * getBuffAddrLeft(void) const
gets address of remaining non-deserialized data.
Definition: Serializable.cpp:658
FW_SERIALIZE_FALSE_VALUE
#define FW_SERIALIZE_FALSE_VALUE
Value encoded during serialization for boolean false.
Definition: FpConfig.hpp:47
Fw::SerializeBufferBase
Definition: Serializable.hpp:43
Fw::SerializeStatus
SerializeStatus
forward declaration for string
Definition: Serializable.hpp:14
Fw::FW_DESERIALIZE_SIZE_MISMATCH
@ FW_DESERIALIZE_SIZE_MISMATCH
Data was left in in the buffer, but not enough to deserialize.
Definition: Serializable.hpp:20
Fw::SerializeBufferBase::resetDeser
void resetDeser(void)
reset deserialization to beginning
Definition: Serializable.cpp:575
Serializable.hpp
Fw::SerializeBufferBase::serialize
SerializeStatus serialize(U8 val)
serialize 8-bit unsigned int
Definition: Serializable.cpp:67
Fw::StringBase
Definition: StringType.hpp:23
Fw::SerializeBufferBase::copyRaw
SerializeStatus copyRaw(SerializeBufferBase &dest, NATIVE_UINT_TYPE size)
directly copies buffer without looking for a size in the stream.
Definition: Serializable.cpp:623
U8
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.hpp:76
Fw::EightyCharString
Definition: EightyCharString.hpp:10
Fw::SerializeBufferBase::~SerializeBufferBase
virtual ~SerializeBufferBase()
destructor
Definition: Serializable.cpp:45
Fw::SerializeBufferBase::resetSer
void resetSer(void)
reset to beginning of buffer to reuse for serialization
Definition: Serializable.cpp:570
Fw::Serializable
forward declaration
Definition: Serializable.hpp:26
Assert.hpp
Fw::FW_SERIALIZE_OK
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.
Definition: Serializable.hpp:15
Fw::ExternalSerializeBuffer::m_buffSize
NATIVE_UINT_TYPE m_buffSize
size of external buffer
Definition: Serializable.hpp:176
Fw::ExternalSerializeBuffer::clear
void clear(void)
clear external buffer
Definition: Serializable.cpp:716
Fw::SerializeBufferBase::getBuffLeft
NATIVE_UINT_TYPE getBuffLeft() const
returns how much deserialization buffer is left
Definition: Serializable.cpp:619
Fw::SerializeBufferBase::getBuffAddr
virtual U8 * getBuffAddr(void)=0
gets buffer address for data filling
U64
#define U64(C)
Definition: sha.h:176
EightyCharString.hpp
Fw::SerializeBufferBase::getBuffCapacity
virtual NATIVE_UINT_TYPE getBuffCapacity(void) const =0
returns capacity, not current size, of buffer
Fw::SerializeBufferBase::deserializeSkip
SerializeStatus deserializeSkip(NATIVE_UINT_TYPE numBytesToSkip)
Skips the number of specified bytes for deserialization.
Definition: Serializable.cpp:579
I8
int8_t I8
8-bit signed integer
Definition: BasicTypes.hpp:75
Fw::FW_DESERIALIZE_FORMAT_ERROR
@ FW_DESERIALIZE_FORMAT_ERROR
Deserialization data had incorrect values (unexpected data types)
Definition: Serializable.hpp:19
F32
float F32
32-bit floating point
Definition: BasicTypes.hpp:94
Fw::Serializable::~Serializable
virtual ~Serializable()
destructor
Definition: Serializable.cpp:19
Fw::Serializable::deserialize
virtual SerializeStatus deserialize(SerializeBufferBase &buffer)=0
deserialize to contents
Fw::SerializeBufferBase::setBuffLen
SerializeStatus setBuffLen(NATIVE_UINT_TYPE length)
sets buffer length manually after filling with data
Definition: Serializable.cpp:609
Fw::FW_SERIALIZE_NO_ROOM_LEFT
@ FW_SERIALIZE_NO_ROOM_LEFT
No room left in the buffer to serialize data.
Definition: Serializable.hpp:17
NATIVE_UINT_TYPE
unsigned int NATIVE_UINT_TYPE
native unsigned integer type declaration
Definition: BasicTypes.hpp:30
Fw::ExternalSerializeBuffer::setExtBuffer
void setExtBuffer(U8 *buffPtr, NATIVE_UINT_TYPE size)
Set the external buffer.
Definition: Serializable.cpp:710
FW_ASSERT
#define FW_ASSERT(...)
Definition: Assert.hpp:9
Fw::SerializeBufferBase::m_serLoc
NATIVE_UINT_TYPE m_serLoc
current offset in buffer of serialized data
Definition: Serializable.hpp:150
Fw::SerializeBufferBase::getBuffLength
NATIVE_UINT_TYPE getBuffLength() const
returns current buffer size
Definition: Serializable.cpp:592
Fw::SerializeBufferBase::getBuffAddrSer
U8 * getBuffAddrSer(void)
gets address of end of serialization. DANGEROUS! Need to know max buffer size and adjust when done
Definition: Serializable.cpp:663
Fw::ExternalSerializeBuffer::getBuffCapacity
NATIVE_UINT_TYPE getBuffCapacity(void) const
returns capacity, not current size, of buffer
Definition: Serializable.cpp:721
Fw::Serializable::Serializable
Serializable()
Default constructor.
Definition: Serializable.cpp:16
Fw::SerializeBufferBase::deserialize
SerializeStatus deserialize(U8 &val)
deserialize 8-bit unsigned int
Definition: Serializable.cpp:292
Fw::SerializeBufferBase::setBuff
SerializeStatus setBuff(const U8 *src, NATIVE_UINT_TYPE length)
sets buffer contents and size
Definition: Serializable.cpp:596
Fw::SerializeBufferBase::operator=
const SerializeBufferBase & operator=(const SerializeBufferBase &src)
equal operator
Definition: Serializable.cpp:60
Fw::SerializeBufferBase::copyRawOffset
SerializeStatus copyRawOffset(SerializeBufferBase &dest, NATIVE_UINT_TYPE size)
directly copies buffer without looking for a size in the stream.
Definition: Serializable.cpp:637
Fw::Serializable::serialize
virtual SerializeStatus serialize(SerializeBufferBase &buffer) const =0
serialize contents
Fw::ExternalSerializeBuffer::ExternalSerializeBuffer
ExternalSerializeBuffer()
default constructor
Definition: Serializable.cpp:706
Fw::SerializeBufferBase::m_deserLoc
NATIVE_UINT_TYPE m_deserLoc
current offset for deserialization
Definition: Serializable.hpp:151
FwBuffSizeType
#define FwBuffSizeType
Type representation for storing a buffer or string size.
Definition: FpConfig.hpp:79
Fw::ExternalSerializeBuffer::m_buff
U8 * m_buff
pointer to external buffer
Definition: Serializable.hpp:175
Fw::ExternalSerializeBuffer::getBuffAddr
U8 * getBuffAddr(void)
gets buffer address for data filling
Definition: Serializable.cpp:725
Fw
Definition: BufferGetPortAc.cpp:6
Fw::SerializeBufferBase::copyFrom
void copyFrom(const SerializeBufferBase &src)
copy data from source buffer
Definition: Serializable.cpp:48