F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
DeserialStatusEnumAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title DeserialStatusEnumAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for DeserialStatus enum
5 // ======================================================================
6 
7 #include <cstring>
8 #include <limits>
9 
10 #include "Fw/Types/Assert.hpp"
12 
13 namespace Fw {
14 
15  // ----------------------------------------------------------------------
16  // Operators
17  // ----------------------------------------------------------------------
18 
19  DeserialStatus& DeserialStatus ::
21  {
22  this->e = obj.e;
23  return *this;
24  }
25 
28  {
29  this->e = e1;
30  return *this;
31  }
32 
33 #ifdef BUILD_UT
34 
35  std::ostream& operator<<(std::ostream& os, const DeserialStatus& obj) {
36  Fw::String s;
37  obj.toString(s);
38  os << s;
39  return os;
40  }
41 
42 #endif
43 
44  // ----------------------------------------------------------------------
45  // Member functions
46  // ----------------------------------------------------------------------
47 
49  isValid() const
50  {
51  return ((e >= OK) && (e <= OK))
52  || ((e >= BUFFER_EMPTY) && (e <= TYPE_MISMATCH));
53  }
54 
57  {
58  const Fw::SerializeStatus status = buffer.serializeFrom(
59  static_cast<SerialType>(this->e)
60  );
61  return status;
62  }
63 
66  {
67  SerialType es;
68  Fw::SerializeStatus status = buffer.deserializeTo(es);
69  if (status == Fw::FW_SERIALIZE_OK) {
70  this->e = static_cast<T>(es);
71  if (!this->isValid()) {
73  }
74  }
75  return status;
76  }
77 
78 #if FW_SERIALIZABLE_TO_STRING
79 
80  void DeserialStatus ::
81  toString(Fw::StringBase& sb) const
82  {
83  Fw::String s;
84  switch (e) {
85  case OK:
86  s = "OK";
87  break;
88  case BUFFER_EMPTY:
89  s = "BUFFER_EMPTY";
90  break;
91  case FORMAT_ERROR:
92  s = "FORMAT_ERROR";
93  break;
94  case SIZE_MISMATCH:
95  s = "SIZE_MISMATCH";
96  break;
97  case TYPE_MISMATCH:
98  s = "TYPE_MISMATCH";
99  break;
100  default:
101  s = "[invalid]";
102  break;
103  }
104  sb.format("%s (%" PRIu8 ")", s.toChar(), e);
105  }
106 
107 #elif FW_ENABLE_TEXT_LOGGING
108 
109  void DeserialStatus ::
110  toString(Fw::StringBase& sb) const
111  {
112  sb.format("%" PRIu8 "", e);
113  }
114 
115 #endif
116 
117 }
Serialization/Deserialization operation was successful.
Deserialized type ID didn&#39;t match.
Deserialization buffer was empty when trying to read data.
Deserialization status.
const char * toChar() const
Definition: String.hpp:50
Deserialization data had incorrect values (unexpected data types)
Deserialization data had incorrect values (unexpected data types)
SerializeStatus
forward declaration for string
T e
The raw enum value.
bool isValid() const
Check raw enum value for validity.
U8 SerialType
The serial representation type.
Data was left in in the buffer, but not enough to deserialize.
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:55
Fw::SerializeStatus deserializeFrom(Fw::SerializeBufferBase &buffer)
Deserialize raw enum value from SerialType.
SerializeStatus serializeFrom(U8 val)
serialize 8-bit unsigned int
T
The raw enum type.
SerializeStatus deserializeTo(U8 &val)
deserialize 8-bit unsigned int
Fw::SerializeStatus serializeTo(Fw::SerializeBufferBase &buffer) const
Serialize raw enum value to SerialType.
DeserialStatus & operator=(const DeserialStatus &obj)
Copy assignment operator (object)