1#ifndef SIMDJSON_ERROR_H
2#define SIMDJSON_ERROR_H
4#include "simdjson/base.h"
86inline std::ostream& operator<<(std::ostream& out,
error_code error)
noexcept;
133struct simdjson_result_base :
protected std::pair<T, error_code> {
138 simdjson_inline simdjson_result_base() noexcept;
143 simdjson_inline simdjson_result_base(
error_code error) noexcept;
148 simdjson_inline simdjson_result_base(T &&value) noexcept;
153 simdjson_inline simdjson_result_base(T &&value,
error_code error) noexcept;
161 simdjson_inline
void tie(T &value,
error_code &error) && noexcept;
168 simdjson_inline
error_code get(T &value) && noexcept;
173 simdjson_inline
error_code error() const noexcept;
178 simdjson_inline
bool has_value() const noexcept;
179#if SIMDJSON_EXCEPTIONS
186 simdjson_inline T& operator*() &
noexcept(
false);
187 simdjson_inline T&& operator*() &&
noexcept(
false);
193 simdjson_inline T* operator->() noexcept(false);
194 simdjson_inline const T* operator->() const noexcept(false);
201 simdjson_inline T& value() & noexcept(false);
208 simdjson_inline T&& value() && noexcept(false);
215 simdjson_inline T&& take_value() && noexcept(false);
222 simdjson_inline operator T&&() && noexcept(false);
244 simdjson_inline
const T& value_unsafe() const& noexcept;
266 simdjson_inline T&& value_unsafe() && noexcept;
268 using value_type = T;
305 simdjson_inline
void tie(T &value,
error_code &error) &&
noexcept;
312 simdjson_warn_unused simdjson_inline
error_code get(T &value) &&
noexcept;
319 template <
typename U = T>
320 simdjson_warn_unused simdjson_inline
error_code get(std::string &value) &&
noexcept {
321 static_assert(std::is_same<U, std::string_view>::value,
"SFINAE");
323 error_code error = std::forward<simdjson_result<T>>(*this).get(v);
325 value.assign(v.data(), v.size());
333 simdjson_inline
error_code error() const noexcept;
337#if SIMDJSON_EXCEPTIONS
338 using internal::simdjson_result_base<T>::operator*;
339 using internal::simdjson_result_base<T>::operator->;
345 simdjson_inline T& value() &
noexcept(
false);
352 simdjson_inline T&& value() &&
noexcept(
false);
359 simdjson_inline T&& take_value() &&
noexcept(
false);
366 simdjson_inline
operator T&&() &&
noexcept(
false);
373 simdjson_inline
const T& value_unsafe() const& noexcept;
379 simdjson_inline T&& value_unsafe() && noexcept;
381 using value_type = T;
385#if SIMDJSON_EXCEPTIONS
388inline std::ostream& operator<<(std::ostream& out,
simdjson_result<T> value) {
return out << value.value(); }
391#ifndef SIMDJSON_DISABLE_DEPRECATED_API
400[[deprecated(
"Error codes should be stored and returned as `error_code`, use `error_message()` instead.")]]
The top level simdjson namespace, containing everything the library provides.
const char * error_message(error_code error) noexcept
It is the convention throughout the code that the macro SIMDJSON_DEVELOPMENT_CHECKS determines whethe...
error_code
All possible errors returned by simdjson.
@ SCALAR_DOCUMENT_AS_VALUE
A scalar document is treated as a value.
@ DEPTH_ERROR
Your document exceeds the user-specified depth limitation.
@ UNCLOSED_STRING
missing quote at the end
@ INCORRECT_TYPE
JSON element has a different type than user expected.
@ CAPACITY
This parser can't support a document that big.
@ OUT_OF_ORDER_ITERATION
tried to iterate an array or object out of order (checked when SIMDJSON_DEVELOPMENT_CHECKS=1)
@ UTF8_ERROR
the input is not valid UTF-8
@ OUT_OF_CAPACITY
The capacity was exceeded, we cannot allocate enough memory.
@ OUT_OF_BOUNDS
Attempted to access location outside of document.
@ TAPE_ERROR
Something went wrong, this is a generic error. Fatal/unrecoverable error.
@ NO_SUCH_FIELD
JSON field not found in object.
@ UNSUPPORTED_ARCHITECTURE
unsupported architecture
@ N_ATOM_ERROR
Problem while parsing an atom starting with the letter 'n'.
@ NUM_ERROR_CODES
Placeholder for end of error code list.
@ EMPTY
no structural element found
@ INVALID_URI_FRAGMENT
Invalid URI fragment.
@ INDEX_OUT_OF_BOUNDS
JSON array index too large.
@ NUMBER_OUT_OF_RANGE
JSON number does not fit in 64 bits.
@ STRING_ERROR
Problem while parsing a string.
@ MEMALLOC
Error allocating memory, most likely out of memory.
@ T_ATOM_ERROR
Problem while parsing an atom starting with the letter 't'.
@ TRAILING_CONTENT
Unexpected trailing content in the JSON input.
@ INCOMPLETE_ARRAY_OR_OBJECT
The document ends early. Fatal/unrecoverable error.
@ UNEXPECTED_ERROR
indicative of a bug in simdjson
@ UNINITIALIZED
unknown error, or uninitialized document
@ UNESCAPED_CHARS
found unescaped characters in a string.
@ IO_ERROR
Error reading a file.
@ NUMBER_ERROR
Problem while parsing a number.
@ BIGINT_ERROR
The integer value exceeds 64 bits.
@ F_ATOM_ERROR
Problem while parsing an atom starting with the letter 'f'.
@ PARSER_IN_USE
parser is already in use.
@ INSUFFICIENT_PADDING
The JSON doesn't have enough padding for simdjson to safely parse it.
@ INVALID_JSON_POINTER
Invalid JSON pointer syntax.
bool is_fatal(error_code error) noexcept
Some errors are fatal and invalidate the document.
Exception thrown when an exception-supporting simdjson method is called.
const char * what() const noexcept override
The error message.
error_code error() const noexcept
The error code.
simdjson_error(error_code error) noexcept
Create an exception from a simdjson error code.
The result of a simdjson operation that could fail.
simdjson_warn_unused simdjson_inline error_code get(std::string &value) &&noexcept
Copy the value to a provided std::string, only enabled for std::string_view.