CppSerdes  1.0
A serialization/deserialization library designed with embedded systems in mind
serdes_errors.h
Go to the documentation of this file.
1 #ifndef _SERDES_ERRORS_H_
8 #define _SERDES_ERRORS_H_
9 
10 #include <cstddef>
11 
13 namespace serdes
14 {
16  enum class status_e
17  {
19  NO_ERROR = 0,
20 
24 
28 
31  INVALID_FIELD = 3,
32 
36 
40 
44 
48 
51  };
52 
57  inline const char *status2str(status_e err_status) noexcept
58  {
59  switch (err_status)
60  {
61  case status_e::NO_ERROR:
62  return "NO_ERROR";
64  return "EXCEEDED_SERIAL_SIZE";
66  return "ARRAY_SIZE_OVER_MAX";
68  return "INVALID_FIELD";
70  return "NO_LOAD_TO_RVALUE";
72  return "DELIMITER_NOT_FOUND";
74  return "FORMATTER_NOT_SET";
76  return "START_BYTE_PAST_CURRENT";
78  return "NUM_BYTES_OVER_MAX";
79  default:
80  return "(null)";
81  }
82  }
83 
85  struct status_t
86  {
89 
91  size_t bits;
92  };
93 
95  enum class mode_e
96  {
98  LOADING,
99 
101  STORING,
102 
105  };
106 }
107 
108 #endif // _SERDES_ERRORS_H_
serdes::status_e
status_e
error status of serialization/deserialization process
Definition: serdes_errors.h:16
serdes::status_e::NO_LOAD_TO_RVALUE
@ NO_LOAD_TO_RVALUE
tried to loading data from a serial buffer into a temporary rvalue (causes the serdes process to abor...
serdes::mode_e::LOADING
@ LOADING
(deserializing) loading from serial data into variables
serdes::status_e::START_BYTE_PAST_CURRENT
@ START_BYTE_PAST_CURRENT
a byte_iterator was passed a starting byte that was past the current byte position,...
serdes::status_e::NO_ERROR
@ NO_ERROR
no serialization/deserialization errors occurred
serdes::status2str
const char * status2str(status_e err_status) noexcept
converts an error status enum to a c style string
Definition: serdes_errors.h:57
serdes::status_e::EXCEEDED_SERIAL_SIZE
@ EXCEEDED_SERIAL_SIZE
during serialization/deserialization the "serial data" boundary was reached (causes the serdes proces...
serdes::mode_e::UNSPECIFIED
@ UNSPECIFIED
not yet configured for storing/loading
serdes::status_e::FORMATTER_NOT_SET
@ FORMATTER_NOT_SET
a pure_virtual_formatter (a.k.a "serdes::formatter(nullptr)") was used but not overriden (causes the ...
serdes::mode_e
mode_e
the serdes mode of operation
Definition: serdes_errors.h:95
serdes::mode_e::STORING
@ STORING
(serializing) storing variables into serial data
serdes::status_t::bits
size_t bits
number of bits processed
Definition: serdes_errors.h:91
serdes::status_t
status returned after any serialization/deserialization process
Definition: serdes_errors.h:85
serdes::status_e::ARRAY_SIZE_OVER_MAX
@ ARRAY_SIZE_OVER_MAX
the "serdes::array" object's size exceeded the maximum size of the array when evaluated (causes the s...
serdes::status_e::DELIMITER_NOT_FOUND
@ DELIMITER_NOT_FOUND
the specified delimiter in a delimited_array object was not found before the end of the array (causes...
serdes::status_e::NUM_BYTES_OVER_MAX
@ NUM_BYTES_OVER_MAX
a byte_iterator was passed a starting + number of bytes that was past the end of the buffer
serdes
CppSerdes library namespace.
Definition: bitcpy_common.h:68
serdes::status_e::INVALID_FIELD
@ INVALID_FIELD
a fields validation check failed (causes the serdes process to abort)
serdes::status_t::status
status_e status
status of the serdes (load or store) action
Definition: serdes_errors.h:88