xentara-utils v2.0.4
The Xentara Utility Library
|
JSON decoder. More...
Classes | |
struct | AllowLegacyMicrosecondsTag |
Type used to specify that a time duration should allow a number of microseconds as well as a duration string. More... | |
class | Array |
An accessor used for reading the elements of a JSON array. More... | |
class | Document |
A JSON document. More... | |
class | Exception |
Mixin class for exceptions that occurred in a JSON document. More... | |
class | Location |
A class that can be used to log messages related to a specific line in a specific JSON document. More... | |
class | Name |
The name of a member of a JSON object. More... | |
class | NullValueError |
An Exception that is thrown when attempting to access a null value. More... | |
class | Object |
An accessor used for reading the members of a JSON object. More... | |
class | String |
An accessor used for reading a JSON string progressively. More... | |
class | SyntaxError |
An Exception that is thrown when a JSON stream is not valid. More... | |
class | TypeMismatchError |
An Exception that is thrown when a value has the wrong type. More... | |
class | Value |
A single value in a JSON document. More... | |
Typedefs | |
using | Number = std::variant< std::intmax_t, std::uintmax_t, double > |
A generic number for decoding arbitrary numeric types from JSON documents. | |
Functions | |
template<typename StdException > | |
auto | throwWithLocation (const Location &location, StdException &&exception) |
Throws an exception related to a location in a JSON document. | |
template<typename StdException > | |
auto | throwWithLocation (std::reference_wrapper< const Document > document, StdException &&exception) |
Throws an exception related to the current line in a JSON document. | |
template<typename StdException > | |
auto | throwWithLocation (std::reference_wrapper< const Document > document, std::uint_least32_t lineNumber, StdException &&exception) |
Throws an exception related to an arbitrary line in a JSON document. | |
template<typename StdException > | |
auto | throwWithLocation (std::reference_wrapper< const Value > value, StdException &&exception) |
Throws an exception related to a JSON value. | |
template<typename StdException > | |
auto | throwWithLocation (std::reference_wrapper< const Name > name, StdException &&exception) |
Throws an exception related to the name of a JSON object member. | |
template<typename StdException > | |
auto | throwWithLocation (std::reference_wrapper< const Object > object, StdException &&exception) |
Throws an exception related to the an entire JSON object. | |
template<typename StdException > | |
auto | throwWithLocation (std::reference_wrapper< const Array > array, StdException &&exception) |
Throws an exception related to the an entire JSON array. | |
template<typename StdException > | |
auto | throwNestedWithLocation (const Location &location, StdException &&exception) |
Throws a nested exception related to a location in a JSON document. | |
template<typename StdException > | |
auto | throwNestedWithLocation (std::reference_wrapper< const Document > document, StdException &&exception) |
Throws a nested exception related to the current line in a JSON document. | |
template<typename StdException > | |
auto | throwNestedWithLocation (std::reference_wrapper< const Document > document, std::uint_least32_t lineNumber, StdException &&exception) |
Throws a nested exception related to an arbitrary line in a JSON document. | |
template<typename StdException > | |
auto | throwNestedWithLocation (std::reference_wrapper< const Value > value, StdException &&exception) |
Throws a nested exception related to a JSON value. | |
template<typename StdException > | |
auto | throwNestedWithLocation (std::reference_wrapper< const Name > name, StdException &&exception) |
Throws an exception related to the name of a JSON object member. | |
template<typename StdException > | |
auto | throwNestedWithLocation (std::reference_wrapper< const Object > object, StdException &&exception) |
Throws an exception related to the an entire JSON object. | |
template<typename StdException > | |
auto | throwNestedWithLocation (std::reference_wrapper< const Array > array, StdException &&exception) |
Throws an exception related to the an entire JSON array. | |
Variables | |
constexpr AllowLegacyMicrosecondsTag | kAllowLegacyMicroseconds |
A marker used to specify that a time duration should allow a number of microseconds as well as a duration string. | |
JSON decoder.
This namespace contains tools for parsing JSON formatted text data.
using xentara::utils::json::decoder::Number = typedef std::variant<std::intmax_t, std::uintmax_t, double> |
A generic number for decoding arbitrary numeric types from JSON documents.
#include <xentara/utils/json/decoder/Types.hpp>
auto xentara::utils::json::decoder::throwNestedWithLocation | ( | const Location & | location, |
StdException && | exception | ||
) |
Throws a nested exception related to a location in a JSON document.
This function behaves just like throwWithLocation(), but throws the appropriate exception using std::throw_with_nested().
#include <xentara/utils/json/decoder/Errors.hpp>
location | The location |
exception | The exception to throw |
auto xentara::utils::json::decoder::throwNestedWithLocation | ( | std::reference_wrapper< const Array > | array, |
StdException && | exception | ||
) |
Throws an exception related to the an entire JSON array.
This function behaves just like throwWithLocation(), but throws the appropriate exception using std::throw_with_nested().
#include <xentara/utils/json/decoder/Errors.hpp>
array | The array |
exception | The exception to throw |
auto xentara::utils::json::decoder::throwNestedWithLocation | ( | std::reference_wrapper< const Document > | document, |
std::uint_least32_t | lineNumber, | ||
StdException && | exception | ||
) |
Throws a nested exception related to an arbitrary line in a JSON document.
This function behaves just like throwWithLocation(), but throws the appropriate exception using std::throw_with_nested().
#include <xentara/utils/json/decoder/Errors.hpp>
document | The document the error occurred in |
lineNumber | The line number |
exception | The exception to throw |
auto xentara::utils::json::decoder::throwNestedWithLocation | ( | std::reference_wrapper< const Document > | document, |
StdException && | exception | ||
) |
Throws a nested exception related to the current line in a JSON document.
This function behaves just like throwWithLocation(), but throws the appropriate exception using std::throw_with_nested().
#include <xentara/utils/json/decoder/Errors.hpp>
document | The document the error occurred in |
exception | The exception to throw |
auto xentara::utils::json::decoder::throwNestedWithLocation | ( | std::reference_wrapper< const Name > | name, |
StdException && | exception | ||
) |
Throws an exception related to the name of a JSON object member.
This function behaves just like throwWithLocation(), but throws the appropriate exception using std::throw_with_nested().
#include <xentara/utils/json/decoder/Errors.hpp>
name | The name |
exception | The exception to throw |
auto xentara::utils::json::decoder::throwNestedWithLocation | ( | std::reference_wrapper< const Object > | object, |
StdException && | exception | ||
) |
Throws an exception related to the an entire JSON object.
This function behaves just like throwWithLocation(), but throws the appropriate exception using std::throw_with_nested().
#include <xentara/utils/json/decoder/Errors.hpp>
object | The object |
exception | The exception to throw |
auto xentara::utils::json::decoder::throwNestedWithLocation | ( | std::reference_wrapper< const Value > | value, |
StdException && | exception | ||
) |
Throws a nested exception related to a JSON value.
This function behaves just like throwWithLocation(), but throws the appropriate exception using std::throw_with_nested().
#include <xentara/utils/json/decoder/Errors.hpp>
value | The value |
exception | The exception to throw |
auto xentara::utils::json::decoder::throwWithLocation | ( | const Location & | location, |
StdException && | exception | ||
) |
Throws an exception related to a location in a JSON document.
If location contains a valid location, this function throws an exception of an internal type derived publicly both Exception and std::decay_t<StdException>. The what() string of the thrown exception is prefixed with the given location.
If location does not contain a valid location, exception is thrown as-is, without location information.
#include <xentara/utils/json/decoder/Errors.hpp>
location | The location |
exception | The exception to throw |
auto xentara::utils::json::decoder::throwWithLocation | ( | std::reference_wrapper< const Array > | array, |
StdException && | exception | ||
) |
Throws an exception related to the an entire JSON array.
This function throws an exception of an internal type derived publicly from both Exception and std::decay_t<StdException>. The what() string of the thrown exception is prefixed with the location of the begining of the given array.
#include <xentara/utils/json/decoder/Errors.hpp>
array | The array |
exception | The exception to throw |
auto xentara::utils::json::decoder::throwWithLocation | ( | std::reference_wrapper< const Document > | document, |
std::uint_least32_t | lineNumber, | ||
StdException && | exception | ||
) |
Throws an exception related to an arbitrary line in a JSON document.
If lineNumber is greater than 0, this function throws an exception of an internal type derived publicly from both Exception and std::decay_t<StdException>. The what() string of the thrown exception is prefixed with the given line number in the given document.
If lineNumber is 0, exception is thrown as-is, without location information.
#include <xentara/utils/json/decoder/Errors.hpp>
document | The document the error occurred in |
lineNumber | The line number |
exception | The exception to throw |
auto xentara::utils::json::decoder::throwWithLocation | ( | std::reference_wrapper< const Document > | document, |
StdException && | exception | ||
) |
Throws an exception related to the current line in a JSON document.
This function throws an exception of an internal type derived publicly from both Exception and std::decay_t<StdException>. The what() string of the thrown exception is prefixed with the current line number in the given document.
#include <xentara/utils/json/decoder/Errors.hpp>
document | The document the error occurred in |
exception | The exception to throw |
auto xentara::utils::json::decoder::throwWithLocation | ( | std::reference_wrapper< const Name > | name, |
StdException && | exception | ||
) |
Throws an exception related to the name of a JSON object member.
If name is not default constructed, this function throws an exception of an internal type derived publicly from both Exception and std::decay_t<StdException>. The what() string of the thrown exception is prefixed with the location of the given name.
If name is default constructed, exception is thrown as-is, without location information.
#include <xentara/utils/json/decoder/Errors.hpp>
name | The name |
exception | The exception to throw |
auto xentara::utils::json::decoder::throwWithLocation | ( | std::reference_wrapper< const Object > | object, |
StdException && | exception | ||
) |
Throws an exception related to the an entire JSON object.
This function throws an exception of an internal type derived publicly from both Exception and std::decay_t<StdException>. The what() string of the thrown exception is prefixed with the location of the begining of the given object.
#include <xentara/utils/json/decoder/Errors.hpp>
object | The object |
exception | The exception to throw |
auto xentara::utils::json::decoder::throwWithLocation | ( | std::reference_wrapper< const Value > | value, |
StdException && | exception | ||
) |
Throws an exception related to a JSON value.
If value is not default constructed, this function throws an exception of an internal type derived publicly from both Exception and std::decay_t<StdException>. The what() string of the thrown exception is prefixed with the location of the given value.
If value is default constructed, exception is thrown as-is, without location information.
#include <xentara/utils/json/decoder/Errors.hpp>
value | The value |
exception | The exception to throw |
|
constexpr |
A marker used to specify that a time duration should allow a number of microseconds as well as a duration string.
This marker is used to select overloads of conversion functions that allow specifying a duration in a JSON file as a number instead of a string. This is used for backwards compatibility with older JSON formats that required duration to be specified as a numer of microseconds rather than a string.