F´ Flight Software - C/C++ Documentation  NASA-v2.0.1
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 
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;
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);
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  (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 + (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 + (NATIVE_UINT_TYPE) sizeof(void*) - 1
229  >= this->getBuffCapacity()) {
231  }
232 
233  return this->serialize((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 + (NATIVE_UINT_TYPE) sizeof(FwBuffSizeType)
268  > this->getBuffCapacity()) {
270  }
271 
272  // First, serialize size
273  SerializeStatus stat = this->serialize((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 < (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 < (NATIVE_UINT_TYPE)sizeof(val)) {
310  }
311  // read from current location
312  FW_ASSERT(this->getBuffAddr());
313  val = (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 < (NATIVE_UINT_TYPE)sizeof(val)) {
325  }
326  // read from current location
327  FW_ASSERT(this->getBuffAddr());
328  // MSB first
329  val = (U16) (this->getBuffAddr()[this->m_deserLoc + 1] << 0)
330  | (U16) (this->getBuffAddr()[this->m_deserLoc + 0] << 8);
331  this->m_deserLoc += sizeof(val);
332  return FW_SERIALIZE_OK;
333  }
334 
336  // check for room
337  if (this->getBuffLength() == this->m_deserLoc) {
339  } else if (this->getBuffLength() - this->m_deserLoc < (NATIVE_UINT_TYPE)sizeof(val)) {
341  }
342  // read from current location
343  FW_ASSERT(this->getBuffAddr());
344  // MSB first
345  val = (I16) (this->getBuffAddr()[this->m_deserLoc + 1] << 0)
346  | (I16) (this->getBuffAddr()[this->m_deserLoc + 0] << 8);
347  this->m_deserLoc += sizeof(val);
348  return FW_SERIALIZE_OK;
349  }
350 #endif
351 #if FW_HAS_32_BIT==1
353  // check for room
354  if (this->getBuffLength() == this->m_deserLoc) {
356  } else if (this->getBuffLength() - this->m_deserLoc < (NATIVE_UINT_TYPE)sizeof(val)) {
358  }
359  // read from current location
360  FW_ASSERT(this->getBuffAddr());
361  // MSB first
362  val = ((U32) this->getBuffAddr()[this->m_deserLoc + 3] << 0)
363  | ((U32) this->getBuffAddr()[this->m_deserLoc + 2] << 8)
364  | ((U32) this->getBuffAddr()[this->m_deserLoc + 1] << 16)
365  | ((U32) this->getBuffAddr()[this->m_deserLoc + 0] << 24);
366  this->m_deserLoc += sizeof(val);
367  return FW_SERIALIZE_OK;
368  }
369 
371  // check for room
372  if (this->getBuffLength() == this->m_deserLoc) {
374  } else if (this->getBuffLength() - this->m_deserLoc < (NATIVE_UINT_TYPE)sizeof(val)) {
376  }
377  // read from current location
378  FW_ASSERT(this->getBuffAddr());
379  // MSB first
380  val = ((U32) this->getBuffAddr()[this->m_deserLoc + 3] << 0)
381  | ((U32) this->getBuffAddr()[this->m_deserLoc + 2] << 8)
382  | ((U32) this->getBuffAddr()[this->m_deserLoc + 1] << 16)
383  | ((U32) this->getBuffAddr()[this->m_deserLoc + 0] << 24);
384  this->m_deserLoc += sizeof(val);
385  return FW_SERIALIZE_OK;
386  }
387 #endif
388 
389 #if FW_HAS_64_BIT==1
390 
392  // check for room
393  if (this->getBuffLength() == this->m_deserLoc) {
395  } else if (this->getBuffLength() - this->m_deserLoc < (NATIVE_UINT_TYPE)sizeof(val)) {
397  }
398  // read from current location
399  FW_ASSERT(this->getBuffAddr());
400  // MSB first
401  val = ((U64) this->getBuffAddr()[this->m_deserLoc + 7] << 0)
402  | ((U64) this->getBuffAddr()[this->m_deserLoc + 6] << 8)
403  | ((U64) this->getBuffAddr()[this->m_deserLoc + 5] << 16)
404  | ((U64) this->getBuffAddr()[this->m_deserLoc + 4] << 24)
405  | ((U64) this->getBuffAddr()[this->m_deserLoc + 3] << 32)
406  | ((U64) this->getBuffAddr()[this->m_deserLoc + 2] << 40)
407  | ((U64) this->getBuffAddr()[this->m_deserLoc + 1] << 48)
408  | ((U64) this->getBuffAddr()[this->m_deserLoc + 0] << 56);
409 
410  this->m_deserLoc += sizeof(val);
411  return FW_SERIALIZE_OK;
412  }
413 
415  // check for room
416  if (this->getBuffLength() == this->m_deserLoc) {
418  } else if (this->getBuffLength() - this->m_deserLoc < (NATIVE_UINT_TYPE)sizeof(val)) {
420  }
421  // read from current location
422  FW_ASSERT(this->getBuffAddr());
423  // MSB first
424  val = ((I64) this->getBuffAddr()[this->m_deserLoc + 7] << 0)
425  | ((I64) this->getBuffAddr()[this->m_deserLoc + 6] << 8)
426  | ((I64) this->getBuffAddr()[this->m_deserLoc + 5] << 16)
427  | ((I64) this->getBuffAddr()[this->m_deserLoc + 4] << 24)
428  | ((I64) this->getBuffAddr()[this->m_deserLoc + 3] << 32)
429  | ((I64) this->getBuffAddr()[this->m_deserLoc + 2] << 40)
430  | ((I64) this->getBuffAddr()[this->m_deserLoc + 1] << 48)
431  | ((I64) this->getBuffAddr()[this->m_deserLoc + 0] << 56);
432  this->m_deserLoc += sizeof(val);
433  return FW_SERIALIZE_OK;
434  }
435 #endif
436 
437 #if FW_HAS_F64
438 
440 
441  // deserialize as 64-bit int to handle endianness
442  U64 tempVal;
443  SerializeStatus stat = this->deserialize(tempVal);
444  if (stat != FW_SERIALIZE_OK) {
445  return stat;
446  }
447  // copy to argument
448  (void) memcpy(&val, &tempVal, (NATIVE_UINT_TYPE)sizeof(val));
449 
450  return FW_SERIALIZE_OK;
451  }
452 
453 #endif
454 
456  // check for room
457  if (this->getBuffLength() == this->m_deserLoc) {
459  } else if (this->getBuffLength() - this->m_deserLoc < (NATIVE_UINT_TYPE)sizeof(U8)) {
461  }
462  // read from current location
463  FW_ASSERT(this->getBuffAddr());
464  if (FW_SERIALIZE_TRUE_VALUE == this->getBuffAddr()[this->m_deserLoc + 0]) {
465  val = true;
466  } else if (FW_SERIALIZE_FALSE_VALUE == this->getBuffAddr()[this->m_deserLoc + 0]) {
467  val = false;
468  } else {
470  }
471 
472  this->m_deserLoc += sizeof(U8);
473  return FW_SERIALIZE_OK;
474  }
475 
477  return this->deserialize((POINTER_CAST&) val);
478  }
479 
481  // deserialize as 64-bit int to handle endianness
482  U32 tempVal;
483  SerializeStatus stat = this->deserialize(tempVal);
484  if (stat != FW_SERIALIZE_OK) {
485  return stat;
486  }
487  (void) memcpy(&val, &tempVal, sizeof(val));
488 
489  return FW_SERIALIZE_OK;
490  }
491 
493 
494  FW_ASSERT(this->getBuffAddr());
495 
496  if (not noLength) {
497  FwBuffSizeType storedLength;
498 
499  SerializeStatus stat = this->deserialize(storedLength);
500 
501  if (stat != FW_SERIALIZE_OK) {
502  return stat;
503  }
504 
505  // make sure it fits
506  if ((storedLength > this->getBuffLeft()) or (storedLength > length)) {
508  }
509 
510  (void) memcpy(buff, &this->getBuffAddr()[this->m_deserLoc], storedLength);
511 
512  length = static_cast<NATIVE_UINT_TYPE>(storedLength);
513 
514  } else {
515  // make sure enough is left
516  if (length > this->getBuffLeft()) {
518  }
519 
520  (void) memcpy(buff, &this->getBuffAddr()[this->m_deserLoc], length);
521  }
522 
523  this->m_deserLoc += length;
524  return FW_SERIALIZE_OK;
525  }
526 
528  return val.deserialize(*this);
529  }
530 
532 
533  FW_ASSERT(val.getBuffAddr());
535 
536  FwBuffSizeType storedLength;
537 
538  stat = this->deserialize(storedLength);
539 
540  if (stat != FW_SERIALIZE_OK) {
541  return stat;
542  }
543 
544  // make sure destination has enough room
545 
546  if ((storedLength > val.getBuffCapacity()) or (storedLength > this->getBuffLeft()) ) {
548  }
549 
550  FW_ASSERT(this->getBuffAddr());
551  (void) memcpy(val.getBuffAddr(), &this->getBuffAddr()[this->m_deserLoc],
552  storedLength);
553 
554  stat = val.setBuffLen(storedLength);
555 
556  if (stat != FW_SERIALIZE_OK) {
557  return stat;
558  }
559 
560  this->m_deserLoc += storedLength;
561 
562  return FW_SERIALIZE_OK;
563  }
564 
566  this->m_deserLoc = 0;
567  this->m_serLoc = 0;
568  }
569 
571  this->m_deserLoc = 0;
572  }
573 
575  {
576  // check for room
577  if (this->getBuffLength() == this->m_deserLoc) {
579  } else if (this->getBuffLength() - this->m_deserLoc < numBytesToSkip) {
581  }
582  // update location in buffer to skip the value
583  this->m_deserLoc += numBytesToSkip;
584  return FW_SERIALIZE_OK;
585  }
586 
588  return this->m_serLoc;
589  }
590 
592  if (this->getBuffCapacity() < length) {
594  } else {
595  FW_ASSERT(src);
596  FW_ASSERT(this->getBuffAddr());
597  memcpy(this->getBuffAddr(), src, length);
598  this->m_serLoc = length;
599  this->m_deserLoc = 0;
600  return FW_SERIALIZE_OK;
601  }
602  }
603 
605  if (this->getBuffCapacity() < length) {
607  } else {
608  this->m_serLoc = length;
609  this->m_deserLoc = 0;
610  return FW_SERIALIZE_OK;
611  }
612  }
613 
615  return this->m_serLoc - this->m_deserLoc;
616  }
617 
619  // make sure there is sufficient size in destination
620  if (dest.getBuffCapacity() < size) {
622  }
623  // otherwise, set destination buffer to data from deserialization pointer plus size
624  SerializeStatus stat = dest.setBuff(&this->getBuffAddr()[this->m_deserLoc],size);
625  if (FW_SERIALIZE_OK) {
626  this->m_deserLoc += size;
627  }
628  return stat;
629 
630  }
631 
633  // make sure there is sufficient size in destination
634  if (dest.getBuffCapacity() < size + dest.getBuffLength()) {
636  }
637  // make sure there is sufficient buffer in source
638  if (this->getBuffLeft() < size) {
640  }
641 
642  // otherwise, serialize bytes to destination without writing length
643  SerializeStatus stat = dest.serialize(&this->getBuffAddr()[this->m_deserLoc], size, true);
644  if (stat == FW_SERIALIZE_OK) {
645  this->m_deserLoc += size;
646  }
647  return stat;
648 
649  }
650 
651  // return address of buffer not yet deserialized. This is used
652  // to copy the remainder of a buffer.
653  const U8* SerializeBufferBase::getBuffAddrLeft(void) const {
654  return &this->getBuffAddr()[this->m_deserLoc];
655  }
656 
659  return &this->getBuffAddr()[this->m_serLoc];
660  }
661 
662 #ifdef BUILD_UT
663  bool SerializeBufferBase::operator==(const SerializeBufferBase& other) const {
664  if (this->getBuffLength() != other.getBuffLength()) {
665  return false;
666  }
667 
668  const U8* us = this->getBuffAddr();
669  const U8* them = other.getBuffAddr();
670 
671  FW_ASSERT(us);
672  FW_ASSERT(them);
673 
674  for (NATIVE_UINT_TYPE byte = 0; byte < this->getBuffLength(); byte++) {
675  if (us[byte] != them[byte]) {
676  return false;
677  }
678  }
679 
680  return true;
681  }
682 
683  std::ostream& operator<<(std::ostream& os, const SerializeBufferBase& buff) {
684 
685  const U8* us = buff.getBuffAddr();
686 
687  FW_ASSERT(us);
688 
689  for (NATIVE_UINT_TYPE byte = 0; byte < buff.getBuffLength(); byte++) {
690  os << "[" << std::setw(2) << std::hex << std::setfill('0') << (NATIVE_UINT_TYPE)us[byte] << "]" << std::dec;
691  }
692 
693  return os;
694  }
695 #endif
696 
698  this->setExtBuffer(buffPtr,size);
699  }
700 
702  this->clear();
703  }
704 
706  FW_ASSERT(buffPtr);
707  this->m_buff = buffPtr;
708  this->m_buffSize = size;
709  }
710 
712  this->m_buff = 0;
713  this->m_buffSize = 0;
714  }
715 
717  return this->m_buffSize;
718  }
719 
721  return this->m_buff;
722  }
723 
725  return this->m_buff;
726  }
727 
728 }
729 
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::SerializeBufferBase::SerializeBufferBase
SerializeBufferBase()
default constructor
Definition: Serializable.cpp:41
Fw::FW_DESERIALIZE_BUFFER_EMPTY
@ FW_DESERIALIZE_BUFFER_EMPTY
Deserialization buffer was empty when trying to read more data.
Definition: Serializable.hpp:18
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:570
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:618
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:565
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::clear
void clear(void)
clear external buffer
Definition: Serializable.cpp:711
Fw::SerializeBufferBase::getBuffLeft
NATIVE_UINT_TYPE getBuffLeft() const
returns how much deserialization buffer is left
Definition: Serializable.cpp:614
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:574
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:604
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:705
FW_ASSERT
#define FW_ASSERT(...)
Definition: Assert.hpp:9
Fw::SerializeBufferBase::getBuffLength
NATIVE_UINT_TYPE getBuffLength() const
returns current buffer size
Definition: Serializable.cpp:587
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:658
Fw::ExternalSerializeBuffer::getBuffCapacity
NATIVE_UINT_TYPE getBuffCapacity(void) const
returns capacity, not current size, of buffer
Definition: Serializable.cpp:716
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:290
Fw::SerializeBufferBase::setBuff
SerializeStatus setBuff(const U8 *src, NATIVE_UINT_TYPE length)
sets buffer contents and size
Definition: Serializable.cpp:591
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:632
Fw::Serializable::serialize
virtual SerializeStatus serialize(SerializeBufferBase &buffer) const =0
serialize contents
Fw::ExternalSerializeBuffer::ExternalSerializeBuffer
ExternalSerializeBuffer()
default constructor
Definition: Serializable.cpp:701
FwBuffSizeType
#define FwBuffSizeType
Type representation for storing a buffer or string size.
Definition: FpConfig.hpp:79
Fw::ExternalSerializeBuffer::getBuffAddr
U8 * getBuffAddr(void)
gets buffer address for data filling
Definition: Serializable.cpp:720
Fw
Definition: Buffer.cpp:21
Fw::SerializeBufferBase::getBuffAddrLeft
const U8 * getBuffAddrLeft(void) const
gets address of remaining non-deserialized data.