deserialization of CBOR, MessagePack, and UBJSON values More...
#include <json.hpp>
Public Member Functions | |
binary_reader (input_adapter_t adapter) | |
create a binary reader More... | |
binary_reader (const binary_reader &)=delete | |
binary_reader (binary_reader &&)=default | |
binary_reader & | operator= (const binary_reader &)=delete |
binary_reader & | operator= (binary_reader &&)=default |
~binary_reader ()=default | |
bool | sax_parse (const input_format_t format, json_sax_t *sax_, const bool strict=true) |
Static Public Member Functions | |
static constexpr bool | little_endianess (int num=1) noexcept |
determine system byte order More... | |
Private Types | |
using | number_integer_t = typename BasicJsonType::number_integer_t |
using | number_unsigned_t = typename BasicJsonType::number_unsigned_t |
using | number_float_t = typename BasicJsonType::number_float_t |
using | string_t = typename BasicJsonType::string_t |
using | json_sax_t = SAX |
Private Member Functions | |
bool | parse_bson_internal () |
Reads in a BSON-object and passes it to the SAX-parser. More... | |
bool | get_bson_cstr (string_t &result) |
Parses a C-style string from the BSON input. More... | |
template<typename NumberType > | |
bool | get_bson_string (const NumberType len, string_t &result) |
Parses a zero-terminated string of length len from the BSON input. More... | |
bool | parse_bson_element_internal (const int element_type, const std::size_t element_type_parse_position) |
Read a BSON document element of the given element_type. More... | |
bool | parse_bson_element_list (const bool is_array) |
Read a BSON element list (as specified in the BSON-spec) More... | |
bool | parse_bson_array () |
Reads an array from the BSON input and passes it to the SAX-parser. More... | |
bool | parse_cbor_internal (const bool get_char=true) |
bool | get_cbor_string (string_t &result) |
reads a CBOR string More... | |
bool | get_cbor_array (const std::size_t len) |
bool | get_cbor_object (const std::size_t len) |
bool | parse_msgpack_internal () |
bool | get_msgpack_string (string_t &result) |
reads a MessagePack string More... | |
bool | get_msgpack_array (const std::size_t len) |
bool | get_msgpack_object (const std::size_t len) |
bool | parse_ubjson_internal (const bool get_char=true) |
bool | get_ubjson_string (string_t &result, const bool get_char=true) |
reads a UBJSON string More... | |
bool | get_ubjson_size_value (std::size_t &result) |
bool | get_ubjson_size_type (std::pair< std::size_t, int > &result) |
determine the type and size for a container More... | |
bool | get_ubjson_value (const int prefix) |
bool | get_ubjson_array () |
bool | get_ubjson_object () |
int | get () |
get next character from the input More... | |
int | get_ignore_noop () |
template<typename NumberType , bool InputIsLittleEndian = false> | |
bool | get_number (const input_format_t format, NumberType &result) |
template<typename NumberType > | |
bool | get_string (const input_format_t format, const NumberType len, string_t &result) |
create a string by reading characters from the input More... | |
bool | unexpect_eof (const input_format_t format, const char *context) const |
std::string | get_token_string () const |
std::string | exception_message (const input_format_t format, const std::string &detail, const std::string &context) const |
Private Attributes | |
input_adapter_t | ia = nullptr |
input adapter More... | |
int | current = std::char_traits<char>::eof() |
the current character More... | |
std::size_t | chars_read = 0 |
the number of characters read More... | |
const bool | is_little_endian = little_endianess() |
whether we can assume little endianess More... | |
json_sax_t * | sax = nullptr |
the SAX parser More... | |
deserialization of CBOR, MessagePack, and UBJSON values
|
private |
|
private |
|
private |
|
private |
|
private |
|
inlineexplicit |
|
delete |
|
default |
|
default |
|
inlineprivate |
[in] | format | the current format |
[in] | detail | a detailed error message |
[in] | context | further context information |
Definition at line 7075 of file json.hpp.
|
inlineprivate |
get next character from the input
This function provides the interface to the used input adapter. It does not throw in case the input reached EOF, but returns a -'ve valued std::char_traits<char>::eof()
in that case.
Definition at line 6949 of file json.hpp.
|
inlineprivate |
Parses a C-style string from the BSON input.
[in,out] | result | A reference to the string variable where the read string is to be stored. |
true
if the -byte indicating the end of the string was encountered before the EOF; false` indicates an unexpected EOF. Definition at line 5307 of file json.hpp.
|
inlineprivate |
Parses a zero-terminated string of length len from the BSON input.
[in] | len | The length (including the zero-byte at the end) of the string to be read. |
[in,out] | result | A reference to the string variable where the read string is to be stored. |
NumberType | The type of the length len |
true
if the string was successfully parsed Definition at line 5339 of file json.hpp.
|
inlineprivate |
[in] | len | the length of the array or std::size_t(-1) for an array of indefinite size |
Definition at line 5928 of file json.hpp.
|
inlineprivate |
[in] | len | the length of the object or std::size_t(-1) for an object of indefinite size |
Definition at line 5964 of file json.hpp.
|
inlineprivate |
reads a CBOR string
This function first reads starting bytes to determine the expected string length and then copies this number of bytes into a string. Additionally, CBOR's strings with indefinite lengths are supported.
[out] | result | created string |
Definition at line 5839 of file json.hpp.
|
inlineprivate |
|
inlineprivate |
[in] | len | the length of the array |
Definition at line 6456 of file json.hpp.
|
inlineprivate |
[in] | len | the length of the object |
Definition at line 6478 of file json.hpp.
|
inlineprivate |
reads a MessagePack string
This function first reads starting bytes to determine the expected string length and then copies this number of bytes into a string.
[out] | result | created string |
Definition at line 6380 of file json.hpp.
|
inlineprivate |
Definition at line 6983 of file json.hpp.
|
inlineprivate |
create a string by reading characters from the input
NumberType | the type of the number |
[in] | format | the current format (for diagnostics) |
[in] | len | number of characters to read |
[out] | result | string created by reading len bytes |
Definition at line 7026 of file json.hpp.
|
inlineprivate |
|
inlineprivate |
Definition at line 6802 of file json.hpp.
|
inlineprivate |
Definition at line 6864 of file json.hpp.
|
inlineprivate |
determine the type and size for a container
In the optimized UBJSON format, a type and a size can be provided to allow for a more compact representation.
[out] | result | pair of the size and the type |
Definition at line 6665 of file json.hpp.
|
inlineprivate |
[out] | result | determined size |
Definition at line 6588 of file json.hpp.
|
inlineprivate |
reads a UBJSON string
This function is either called after reading the 'S' byte explicitly indicating a string, or in case of an object key where the 'S' byte can be left out.
[out] | result | created string |
[in] | get_char | whether a new character should be retrieved from the input (true, default) or whether the last read character should be considered instead |
Definition at line 6534 of file json.hpp.
|
inlineprivate |
prefix | the previously read or set type prefix |
Definition at line 6706 of file json.hpp.
|
inlinestaticnoexcept |
determine system byte order
|
delete |
|
default |
|
inlineprivate |
Reads an array from the BSON input and passes it to the SAX-parser.
Definition at line 5468 of file json.hpp.
|
inlineprivate |
Read a BSON document element of the given element_type.
[in] | element_type | The BSON element type, c.f. http://bsonspec.org/spec.html |
[in] | element_type_parse_position | The position in the input stream, where the element_type was read. |
Definition at line 5360 of file json.hpp.
|
inlineprivate |
Read a BSON element list (as specified in the BSON-spec)
The same binary layout is used for objects and arrays, hence it must be indicated with the argument is_array which one is expected (true –> array, false –> object).
[in] | is_array | Determines if the element list being read is to be treated as an object (is_array == false), or as an array (is_array == true). |
Definition at line 5431 of file json.hpp.
|
inlineprivate |
Reads in a BSON-object and passes it to the SAX-parser.
Definition at line 5282 of file json.hpp.
|
inlineprivate |
[in] | get_char | whether a new character should be retrieved from the input (true, default) or whether the last read character should be considered instead |
Definition at line 5497 of file json.hpp.
|
inlineprivate |
Definition at line 6016 of file json.hpp.
|
inlineprivate |
[in] | get_char | whether a new character should be retrieved from the input (true, default) or whether the last read character should be considered instead |
Definition at line 6515 of file json.hpp.
|
inline |
[in] | format | the binary format to parse |
[in] | sax_ | a SAX event processor |
[in] | strict | whether to expect the input to be consumed completed |
Definition at line 5210 of file json.hpp.
|
inlineprivate |
[in] | format | the current format (for diagnostics) |
[in] | context | further context information (for diagnostics) |
Definition at line 7049 of file json.hpp.
|
private |
|
private |
|
private |
|
private |
|
private |