OGLplus  (0.59.0) a C++ wrapper for rendering APIs

result.hpp
Go to the documentation of this file.
1 
9 #ifndef EAGINE_SERIALIZE_RESULT_HPP
10 #define EAGINE_SERIALIZE_RESULT_HPP
11 
12 #include "../bitfield.hpp"
13 #include "../reflect/map_enumerators.hpp"
14 #include "../valid_if/indicated.hpp"
15 #include <cstdint>
16 
17 namespace eagine {
18 //------------------------------------------------------------------------------
24 enum class serialization_error_code : std::uint8_t {
26  not_supported = 1U << 0U,
28  too_much_data = 1U << 1U,
30  incomplete_write = 1U << 2U,
32  data_sink_error = 1U << 3U,
34  backend_error = 1U << 4U
35 };
36 //------------------------------------------------------------------------------
37 template <typename Selector>
38 constexpr auto
39 enumerator_mapping(type_identity<serialization_error_code>, Selector) noexcept {
40  return enumerator_map_type<serialization_error_code, 5>{
41  {{"not_supported", serialization_error_code::not_supported},
42  {"too_much_data", serialization_error_code::too_much_data},
43  {"incomplete_write", serialization_error_code::incomplete_write},
44  {"data_sink_error", serialization_error_code::data_sink_error},
45  {"backend_error", serialization_error_code::backend_error}}};
46 }
47 //------------------------------------------------------------------------------
53 enum class deserialization_error_code : std::uint16_t {
55  not_supported = 1U << 0U,
57  not_enough_data = 1U << 1U,
59  unexpected_data = 1U << 2U,
61  incomplete_read = 1U << 3U,
63  missing_element = 1U << 4U,
65  excess_element = 1U << 5U,
67  missing_member = 1U << 6U,
69  excess_member = 1U << 7U,
71  invalid_format = 1U << 8U,
73  data_source_error = 1U << 9U,
75  backend_error = 1U << 10U
76 };
77 //------------------------------------------------------------------------------
78 template <typename Selector>
79 constexpr auto enumerator_mapping(
80  type_identity<deserialization_error_code>,
81  Selector) noexcept {
82  return enumerator_map_type<deserialization_error_code, 11>{
92  {"data_source_error", deserialization_error_code::data_source_error},
93  {"backend_error", deserialization_error_code::backend_error}}};
94 }
95 //------------------------------------------------------------------------------
101 
107 //------------------------------------------------------------------------------
112 template <typename T>
113 using serialization_result =
115 //------------------------------------------------------------------------------
118 template <typename T>
119 static inline auto get_errors(const serialization_result<T>& result) noexcept
121  return result.policy()._indicator;
122 }
123 //------------------------------------------------------------------------------
128 template <typename T>
131 //------------------------------------------------------------------------------
134 template <typename T>
135 static inline auto get_errors(const deserialization_result<T>& result) noexcept
137  return result.policy()._indicator;
138 }
139 //------------------------------------------------------------------------------
140 } // namespace eagine
141 
142 #endif // EAGINE_SERIALIZE_RESULT_HPP
valid_if_indicated< T, deserialization_errors, bool, false > deserialization_result
Alias for result type of deserialization operations.
Definition: result.hpp:130
@ data_source_error
Internal error in the deserialization data source.
@ invalid_format
Invalid data format.
@ data_sink_error
Internal error in the serialization data sink.
Common code is placed in this namespace.
Definition: eagine.hpp:21
Primary template for conditionally valid values.
Definition: decl.hpp:49
Class for manipulating and testing a group of enumeration-based bits.
Definition: bitfield.hpp:19
deserialization_error_code
Deserialization error code bits enumeration.
Definition: result.hpp:53
serialization_error_code
Serialization error code bits enumeration.
Definition: result.hpp:24
@ incomplete_write
Incomplete write, remaining data should be written later.
@ not_enough_data
Not enough data to deserialize the value.
@ not_supported
Value type or format not supported.
@ excess_member
Superfluous data for class data member.
@ incomplete_read
Incomplete read, remaining data should be read later.
@ missing_element
Missing data for container element.
@ unexpected_data
Superfluous data in the deserialization source.
@ backend_error
Internal error in the serialization backend.
static auto get_errors(const serialization_result< T > &result) noexcept -> serialization_errors
Returns the error bitfield from a serialization result.
Definition: result.hpp:119
@ too_much_data
Too much data to fit into serialization data sink.
@ excess_element
Superfluous data for container element.
@ backend_error
Internal error in the deserialization backend.
@ missing_member
Missing data for class data member.
@ not_supported
Value type or format not supported.

Copyright © 2015-2021 Matúš Chochlík.
<chochlik -at -gmail.com>
Documentation generated on Tue Apr 13 2021 by Doxygen (version 1.8.17).