F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
FileSystemStatusEnumAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title FileSystemStatusEnumAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for FileSystemStatus enum
5 // ======================================================================
6 
7 #include <cstring>
8 #include <limits>
9 
11 
12 namespace Os {
13 
14  // ----------------------------------------------------------------------
15  // Operators
16  // ----------------------------------------------------------------------
17 
18  FileSystemStatus& FileSystemStatus ::
20  {
21  this->e = obj.e;
22 #ifdef BUILD_UT
23  this->m_serializeValueIsSet = obj.m_serializeValueIsSet;
24  this->m_serializeValue = obj.m_serializeValue;
25 #endif
26  return *this;
27  }
28 
31  {
32  FW_ASSERT(isValid(e1), static_cast<FwAssertArgType>(e1));
33  this->e = static_cast<enum T>(e1);
34 #ifdef BUILD_UT
35  this->m_serializeValueIsSet = false;
36  this->m_serializeValue = 0;
37 #endif
38  return *this;
39  }
40 
42  operator=(enum T e1)
43  {
44  FW_ASSERT(isValid(e1), static_cast<FwAssertArgType>(e1));
45  this->e = e1;
46 #ifdef BUILD_UT
47  this->m_serializeValueIsSet = false;
48  this->m_serializeValue = 0;
49 #endif
50  return *this;
51  }
52 
53 #ifdef BUILD_UT
54 
55  std::ostream& operator<<(std::ostream& os, const FileSystemStatus& obj) {
56  Fw::String s;
57  obj.toString(s);
58  os << s;
59  return os;
60  }
61 
62 #endif
63 
64  // ----------------------------------------------------------------------
65  // Member functions
66  // ----------------------------------------------------------------------
67 
69  isValid() const
70  {
71  return FileSystemStatus::isValid(this->e);
72  }
73 
76  Fw::SerialBufferBase& buffer,
77  Fw::Endianness mode
78  ) const
79  {
80  SerialType es = static_cast<SerialType>(this->e);
81 #ifdef BUILD_UT
82  // Unit testing only: On request, override the enum value
83  // with the numeric value, which is allowed to be invalid
84  if (this->m_serializeValueIsSet) {
85  es = this->m_serializeValue;
86  }
87 #endif
88  const Fw::SerializeStatus status = buffer.serializeFrom(es, mode);
89  return status;
90  }
91 
94  Fw::SerialBufferBase& buffer,
95  Fw::Endianness mode
96  )
97  {
98  SerialType es;
99  Fw::SerializeStatus status = buffer.deserializeTo(es, mode);
100  if ((status == Fw::FW_SERIALIZE_OK) && !FileSystemStatus::isValid(es)) {
102  }
103  if (status == Fw::FW_SERIALIZE_OK) {
104  this->e = static_cast<enum T>(es);
105  }
106  return status;
107  }
108 
109 #if FW_SERIALIZABLE_TO_STRING
110 
111  void FileSystemStatus ::
112  toString(Fw::StringBase& sb) const
113  {
114  Fw::String s;
115  switch (e) {
116  case OP_OK:
117  s = "OP_OK";
118  break;
119  case ALREADY_EXISTS:
120  s = "ALREADY_EXISTS";
121  break;
122  case NO_SPACE:
123  s = "NO_SPACE";
124  break;
125  case NO_PERMISSION:
126  s = "NO_PERMISSION";
127  break;
128  case NOT_DIR:
129  s = "NOT_DIR";
130  break;
131  case IS_DIR:
132  s = "IS_DIR";
133  break;
134  case NOT_EMPTY:
135  s = "NOT_EMPTY";
136  break;
137  case INVALID_PATH:
138  s = "INVALID_PATH";
139  break;
140  case DOESNT_EXIST:
141  s = "DOESNT_EXIST";
142  break;
143  case FILE_LIMIT:
144  s = "FILE_LIMIT";
145  break;
146  case BUSY:
147  s = "BUSY";
148  break;
149  case NO_MORE_FILES:
150  s = "NO_MORE_FILES";
151  break;
152  case BUFFER_TOO_SMALL:
153  s = "BUFFER_TOO_SMALL";
154  break;
155  case EXDEV_ERROR:
156  s = "EXDEV_ERROR";
157  break;
158  case OVERFLOW_ERROR:
159  s = "OVERFLOW_ERROR";
160  break;
161  case NOT_SUPPORTED:
162  s = "NOT_SUPPORTED";
163  break;
164  case OTHER_ERROR:
165  s = "OTHER_ERROR";
166  break;
167  default:
168  s = "[invalid]";
169  break;
170  }
171  sb.format("%s (%" PRIu8 ")", s.toChar(), e);
172  }
173 
174 #endif
175 
176 #ifdef BUILD_UT
177 
178  void FileSystemStatus ::
179  setSerializeValue(SerialType serializeValue)
180  {
181  this->m_serializeValue = serializeValue;
182  this->m_serializeValueIsSet = true;
183  }
184 
185 #endif
186 
187  // ----------------------------------------------------------------------
188  // Static functions
189  // ----------------------------------------------------------------------
190 
192  isValid(SerialType serialTypeValue)
193  {
194  return (serialTypeValue <= OTHER_ERROR);
195  }
196 
197 }
Buffer size is too small to hold full path (for getWorkingDirectory)
Serialization/Deserialization operation was successful.
FileSystemStatus & operator=(const FileSystemStatus &obj)
Copy assignment operator (object)
Path is too long, too many sym links, etc.
FPP shadow-enum representing Os::FileSystem::Status.
Directory stream has no more files.
Operation was successful.
Deserialization data had incorrect values (unexpected data types)
virtual SerializeStatus serializeFrom(U8 val, Endianness mode=Endianness::BIG)=0
Serialize an 8-bit unsigned integer value.
Operation is not supported by the current implementation.
SerializeStatus
forward declaration for string
virtual SerializeStatus deserializeTo(U8 &val, Endianness mode=Endianness::BIG)=0
Deserialize an 8-bit unsigned integer value.
Operation failed due to overflow in calculation of the result.
enum T e
The raw enum value.
bool isValid() const
Check raw enum value for validity.
Operand is in use by the system or by a process.
const char * toChar() const
Convert to a C-style char*.
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:58
U8 SerialType
The serial representation type.
Fw::SerializeStatus serializeTo(Fw::SerialBufferBase &buffer, Fw::Endianness mode=Fw::Endianness::BIG) const
Serialize raw enum value to SerialType.
Endianness
Operation not supported across devices (e.g. rename)
Fw::SerializeStatus deserializeFrom(Fw::SerialBufferBase &buffer, Fw::Endianness mode=Fw::Endianness::BIG)
Deserialize raw enum value from SerialType.
#define FW_ASSERT(...)
Definition: Assert.hpp:14
ComCfg::Apid::SerialType SerialType
Definition: TestUtils.cpp:14