1 #ifndef SIMDJSON_ERROR_H
2 #define SIMDJSON_ERROR_H
4 #include "simdjson/common_defs.h"
28 UNSUPPORTED_ARCHITECTURE,
38 OUT_OF_ORDER_ITERATION,
53 inline const char *error_message(error_code error) noexcept;
58 inline std::ostream& operator<<(std::ostream& out, error_code error) noexcept;
70 const char *
what() const noexcept {
return error_message(
error()); }
72 error_code
error() const noexcept {
return _error; }
101 struct simdjson_result_base :
protected std::pair<T, error_code> {
106 simdjson_really_inline simdjson_result_base() noexcept;
111 simdjson_really_inline simdjson_result_base(error_code error) noexcept;
116 simdjson_really_inline simdjson_result_base(T &&value) noexcept;
121 simdjson_really_inline simdjson_result_base(T &&value, error_code error) noexcept;
129 simdjson_really_inline
void tie(T &value, error_code &error) && noexcept;
136 simdjson_really_inline error_code get(T &value) && noexcept;
143 simdjson_really_inline const T &value(error_code &error) const & noexcept;
148 simdjson_really_inline error_code error() const noexcept;
150 #if SIMDJSON_EXCEPTIONS
157 simdjson_really_inline T& value() & noexcept(
false);
164 simdjson_really_inline T&& value() && noexcept(
false);
171 simdjson_really_inline T&& take_value() && noexcept(
false);
178 simdjson_really_inline
operator T&&() && noexcept(
false);
179 #endif // SIMDJSON_EXCEPTIONS
185 simdjson_really_inline
const T& value_unsafe() const& noexcept;
191 simdjson_really_inline T&& value_unsafe() && noexcept;
215 simdjson_really_inline
simdjson_result(error_code error_code) noexcept;
219 simdjson_really_inline
simdjson_result(T &&value, error_code error) noexcept;
227 simdjson_really_inline
void tie(T &value, error_code &error) && noexcept;
234 simdjson_warn_unused simdjson_really_inline error_code get(T &value) && noexcept;
239 simdjson_really_inline error_code error()
const noexcept;
241 #if SIMDJSON_EXCEPTIONS
248 simdjson_really_inline T&
value() & noexcept(
false);
255 simdjson_really_inline T&&
value() && noexcept(
false);
262 simdjson_really_inline T&& take_value() && noexcept(
false);
269 simdjson_really_inline
operator T&&() && noexcept(
false);
270 #endif // SIMDJSON_EXCEPTIONS
282 simdjson_really_inline T&& value_unsafe() && noexcept;
286 #if SIMDJSON_EXCEPTIONS
289 inline std::ostream& operator<<(std::ostream& out,
simdjson_result<T> value) noexcept {
return out << value.value(); }
291 #endif // SIMDJSON_EXCEPTIONS
293 #ifndef SIMDJSON_DISABLE_DEPRECATED_API
297 using ErrorValues [[deprecated(
"This is an alias and will be removed, use error_code instead")]] = error_code;
302 [[deprecated(
"Error codes should be stored and returned as `error_code`, use `error_message()` instead.")]]
303 inline const std::string error_message(
int error) noexcept;
304 #endif // SIMDJSON_DISABLE_DEPRECATED_API
307 #endif // SIMDJSON_ERROR_H