Timer Console
Loading...
Searching...
No Matches
detail::binary_reader< BasicJsonType, InputAdapterType, SAX > Class Template Reference

deserialization of CBOR, MessagePack, and UBJSON values More...

#include <json.hpp>

Collaboration diagram for detail::binary_reader< BasicJsonType, InputAdapterType, SAX >:

Public Member Functions

 binary_reader (InputAdapterType &&adapter, const input_format_t format=input_format_t::json) noexcept
 create a binary reader
 
 binary_reader (const binary_reader &)=delete
 
 binary_reader (binary_reader &&)=default
 
binary_readeroperator= (const binary_reader &)=delete
 
binary_readeroperator= (binary_reader &&)=default
 
 ~binary_reader ()=default
 
bool sax_parse (const input_format_t format, json_sax_t *sax_, const bool strict=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
 

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 binary_t = typename BasicJsonType::binary_t
 
using json_sax_t = SAX
 
using char_type = typename InputAdapterType::char_type
 
using char_int_type = typename char_traits<char_type>::int_type
 
using bjd_type = std::pair<char_int_type, string_t>
 

Private Member Functions

bool parse_bson_internal ()
 Reads in a BSON-object and passes it to the SAX-parser.
 
bool get_bson_cstr (string_t &result)
 Parses a C-style string from the BSON input.
 
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.
 
template<typename NumberType>
bool get_bson_binary (const NumberType len, binary_t &result)
 Parses a byte array input of length len from the BSON input.
 
bool parse_bson_element_internal (const char_int_type element_type, const std::size_t element_type_parse_position)
 Read a BSON document element of the given element_type.
 
bool parse_bson_element_list (const bool is_array)
 Read a BSON element list (as specified in the BSON-spec)
 
bool parse_bson_array ()
 Reads an array from the BSON input and passes it to the SAX-parser.
 
bool parse_cbor_internal (const bool get_char, const cbor_tag_handler_t tag_handler)
 
bool get_cbor_string (string_t &result)
 reads a CBOR string
 
bool get_cbor_binary (binary_t &result)
 reads a CBOR byte array
 
bool get_cbor_array (const std::size_t len, const cbor_tag_handler_t tag_handler)
 
bool get_cbor_object (const std::size_t len, const cbor_tag_handler_t tag_handler)
 
bool parse_msgpack_internal ()
 
bool get_msgpack_string (string_t &result)
 reads a MessagePack string
 
bool get_msgpack_binary (binary_t &result)
 reads a MessagePack byte array
 
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
 
bool get_ubjson_ndarray_size (std::vector< size_t > &dim)
 
bool get_ubjson_size_value (std::size_t &result, bool &is_ndarray, char_int_type prefix=0)
 
bool get_ubjson_size_type (std::pair< std::size_t, char_int_type > &result, bool inside_ndarray=false)
 determine the type and size for a container
 
bool get_ubjson_value (const char_int_type prefix)
 
bool get_ubjson_array ()
 
bool get_ubjson_object ()
 
bool get_ubjson_high_precision_number ()
 
char_int_type get ()
 get next character from the input
 
template<class T>
bool get_to (T &dest, const input_format_t format, const char *context)
 get_to read into a primitive type
 
char_int_type 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
 
template<typename NumberType>
bool get_binary (const input_format_t format, const NumberType len, binary_t &result)
 create a byte array by reading bytes from the input
 
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
 

Static Private Member Functions

template<class NumberType>
static void byte_swap (NumberType &number)
 

Private Attributes

InputAdapterType ia
 input adapter
 
char_int_type current = char_traits<char_type>::eof()
 the current character
 
std::size_t chars_read = 0
 the number of characters read
 
const bool is_little_endian = little_endianness()
 whether we can assume little endianness
 
const input_format_t input_format = input_format_t::json
 input format
 
json_sax_tsax = nullptr
 the SAX parser
 
JSON_PRIVATE_UNLESS_TESTED : const decltype(JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_) bjd_optimized_type_markers = JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_
 
const decltype(JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_bjd_types_map
 

Static Private Attributes

static JSON_INLINE_VARIABLE constexpr std::size_t npos = detail::unknown_size()
 

Detailed Description

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
class detail::binary_reader< BasicJsonType, InputAdapterType, SAX >

deserialization of CBOR, MessagePack, and UBJSON values

Member Typedef Documentation

◆ binary_t

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
using detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::binary_t = typename BasicJsonType::binary_t
private

◆ bjd_type

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
using detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::bjd_type = std::pair<char_int_type, string_t>
private

◆ char_int_type

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
using detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::char_int_type = typename char_traits<char_type>::int_type
private

◆ char_type

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
using detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::char_type = typename InputAdapterType::char_type
private

◆ json_sax_t

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
using detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::json_sax_t = SAX
private

◆ number_float_t

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
using detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::number_float_t = typename BasicJsonType::number_float_t
private

◆ number_integer_t

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
using detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::number_integer_t = typename BasicJsonType::number_integer_t
private

◆ number_unsigned_t

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
using detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::number_unsigned_t = typename BasicJsonType::number_unsigned_t
private

◆ string_t

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
using detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::string_t = typename BasicJsonType::string_t
private

Constructor & Destructor Documentation

◆ binary_reader() [1/3]

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::binary_reader ( InputAdapterType && adapter,
const input_format_t format = input_format_t::json )
inlineexplicitnoexcept

create a binary reader

Parameters
[in]adapterinput adapter to read from

◆ binary_reader() [2/3]

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::binary_reader ( const binary_reader< BasicJsonType, InputAdapterType, SAX > & )
delete

◆ binary_reader() [3/3]

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::binary_reader ( binary_reader< BasicJsonType, InputAdapterType, SAX > && )
default

◆ ~binary_reader()

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::~binary_reader ( )
default

Member Function Documentation

◆ byte_swap()

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
template<class NumberType>
static void detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::byte_swap ( NumberType & number)
inlinestaticprivate

◆ exception_message()

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
std::string detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::exception_message ( const input_format_t format,
const std::string & detail,
const std::string & context ) const
inlineprivate
Parameters
[in]formatthe current format
[in]detaila detailed error message
[in]contextfurther context information
Returns
a message string to use in the parse_error exceptions

◆ get()

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
char_int_type detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::get ( )
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 char_traits<char_type>::eof() in that case.

Returns
character read from the input

◆ get_binary()

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
template<typename NumberType>
bool detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::get_binary ( const input_format_t format,
const NumberType len,
binary_t & result )
inlineprivate

create a byte array by reading bytes from the input

Template Parameters
NumberTypethe type of the number
Parameters
[in]formatthe current format (for diagnostics)
[in]lennumber of bytes to read
[out]resultbyte array created by reading len bytes
Returns
whether byte array creation completed
Note
We can not reserve len bytes for the result, because len may be too large. Usually, unexpect_eof() detects the end of the input before we run out of memory.

◆ get_bson_binary()

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
template<typename NumberType>
bool detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::get_bson_binary ( const NumberType len,
binary_t & result )
inlineprivate

Parses a byte array input of length len from the BSON input.

Parameters
[in]lenThe length of the byte array to be read.
[in,out]resultA reference to the binary variable where the read array is to be stored.
Template Parameters
NumberTypeThe type of the length len
Precondition
len >= 0
Returns
true if the byte array was successfully parsed

◆ get_bson_cstr()

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
bool detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::get_bson_cstr ( string_t & result)
inlineprivate

Parses a C-style string from the BSON input.

Parameters
[in,out]resultA reference to the string variable where the read string is to be stored.
Returns
true if the \x00-byte indicating the end of the string was encountered before the EOF; false` indicates an unexpected EOF.

◆ get_bson_string()

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
template<typename NumberType>
bool detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::get_bson_string ( const NumberType len,
string_t & result )
inlineprivate

Parses a zero-terminated string of length len from the BSON input.

Parameters
[in]lenThe length (including the zero-byte at the end) of the string to be read.
[in,out]resultA reference to the string variable where the read string is to be stored.
Template Parameters
NumberTypeThe type of the length len
Precondition
len >= 1
Returns
true if the string was successfully parsed

◆ get_cbor_array()

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
bool detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::get_cbor_array ( const std::size_t len,
const cbor_tag_handler_t tag_handler )
inlineprivate
Parameters
[in]lenthe length of the array or detail::unknown_size() for an array of indefinite size
[in]tag_handlerhow CBOR tags should be treated
Returns
whether array creation completed

◆ get_cbor_binary()

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
bool detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::get_cbor_binary ( binary_t & result)
inlineprivate

reads a CBOR byte array

This function first reads starting bytes to determine the expected byte array length and then copies this number of bytes into the byte array. Additionally, CBOR's byte arrays with indefinite lengths are supported.

Parameters
[out]resultcreated byte array
Returns
whether byte array creation completed

◆ get_cbor_object()

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
bool detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::get_cbor_object ( const std::size_t len,
const cbor_tag_handler_t tag_handler )
inlineprivate
Parameters
[in]lenthe length of the object or detail::unknown_size() for an object of indefinite size
[in]tag_handlerhow CBOR tags should be treated
Returns
whether object creation completed

◆ get_cbor_string()

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
bool detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::get_cbor_string ( string_t & result)
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.

Parameters
[out]resultcreated string
Returns
whether string creation completed

◆ get_ignore_noop()

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
char_int_type detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::get_ignore_noop ( )
inlineprivate
Returns
character read from the input after ignoring all 'N' entries

◆ get_msgpack_array()

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
bool detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::get_msgpack_array ( const std::size_t len)
inlineprivate
Parameters
[in]lenthe length of the array
Returns
whether array creation completed

◆ get_msgpack_binary()

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
bool detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::get_msgpack_binary ( binary_t & result)
inlineprivate

reads a MessagePack byte array

This function first reads starting bytes to determine the expected byte array length and then copies this number of bytes into a byte array.

Parameters
[out]resultcreated byte array
Returns
whether byte array creation completed

◆ get_msgpack_object()

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
bool detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::get_msgpack_object ( const std::size_t len)
inlineprivate
Parameters
[in]lenthe length of the object
Returns
whether object creation completed

◆ get_msgpack_string()

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
bool detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::get_msgpack_string ( string_t & result)
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.

Parameters
[out]resultcreated string
Returns
whether string creation completed

◆ get_number()

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
template<typename NumberType, bool InputIsLittleEndian = false>
bool detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::get_number ( const input_format_t format,
NumberType & result )
inlineprivate

◆ get_string()

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
template<typename NumberType>
bool detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::get_string ( const input_format_t format,
const NumberType len,
string_t & result )
inlineprivate

create a string by reading characters from the input

Template Parameters
NumberTypethe type of the number
Parameters
[in]formatthe current format (for diagnostics)
[in]lennumber of characters to read
[out]resultstring created by reading len bytes
Returns
whether string creation completed
Note
We can not reserve len bytes for the result, because len may be too large. Usually, unexpect_eof() detects the end of the input before we run out of string memory.

◆ get_to()

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
template<class T>
bool detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::get_to ( T & dest,
const input_format_t format,
const char * context )
inlineprivate

get_to read into a primitive type

This function provides the interface to the used input adapter. It does not throw in case the input reached EOF, but returns false instead

Returns
bool, whether the read was successful

◆ get_token_string()

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
std::string detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::get_token_string ( ) const
inlineprivate
Returns
a string representation of the last read byte

◆ get_ubjson_array()

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
bool detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::get_ubjson_array ( )
inlineprivate
Returns
whether array creation completed

◆ get_ubjson_high_precision_number()

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
bool detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::get_ubjson_high_precision_number ( )
inlineprivate

◆ get_ubjson_ndarray_size()

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
bool detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::get_ubjson_ndarray_size ( std::vector< size_t > & dim)
inlineprivate
Parameters
[out]diman integer vector storing the ND array dimensions
Returns
whether reading ND array size vector is successful

◆ get_ubjson_object()

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
bool detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::get_ubjson_object ( )
inlineprivate
Returns
whether object creation completed

◆ get_ubjson_size_type()

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
bool detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::get_ubjson_size_type ( std::pair< std::size_t, char_int_type > & result,
bool inside_ndarray = false )
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.

Parameters
[out]resultpair of the size and the type
[in]inside_ndarraywhether the parser is parsing an ND array dimensional vector
Returns
whether pair creation completed

◆ get_ubjson_size_value()

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
bool detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::get_ubjson_size_value ( std::size_t & result,
bool & is_ndarray,
char_int_type prefix = 0 )
inlineprivate
Parameters
[out]resultdetermined size
[in,out]is_ndarrayfor input, true means already inside an ndarray vector or ndarray dimension is not allowed; false means ndarray is allowed; for output, true means an ndarray is found; is_ndarray can only return true when its initial value is false
[in]prefixtype marker if already read, otherwise set to 0
Returns
whether size determination completed

◆ get_ubjson_string()

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
bool detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::get_ubjson_string ( string_t & result,
const bool get_char = true )
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.

Parameters
[out]resultcreated string
[in]get_charwhether a new character should be retrieved from the input (true, default) or whether the last read character should be considered instead
Returns
whether string creation completed

◆ get_ubjson_value()

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
bool detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::get_ubjson_value ( const char_int_type prefix)
inlineprivate
Parameters
prefixthe previously read or set type prefix
Returns
whether value creation completed

◆ operator=() [1/2]

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
binary_reader & detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::operator= ( binary_reader< BasicJsonType, InputAdapterType, SAX > && )
default

◆ operator=() [2/2]

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
binary_reader & detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::operator= ( const binary_reader< BasicJsonType, InputAdapterType, SAX > & )
delete

◆ parse_bson_array()

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
bool detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::parse_bson_array ( )
inlineprivate

Reads an array from the BSON input and passes it to the SAX-parser.

Returns
whether a valid BSON-array was passed to the SAX parser

◆ parse_bson_element_internal()

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
bool detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::parse_bson_element_internal ( const char_int_type element_type,
const std::size_t element_type_parse_position )
inlineprivate

Read a BSON document element of the given element_type.

Parameters
[in]element_typeThe BSON element type, c.f. http://bsonspec.org/spec.html
[in]element_type_parse_positionThe position in the input stream, where the element_type was read.
Warning
Not all BSON element types are supported yet. An unsupported element_type will give rise to a parse_error.114: Unsupported BSON record type 0x...
Returns
whether a valid BSON-object/array was passed to the SAX parser

◆ parse_bson_element_list()

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
bool detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::parse_bson_element_list ( const bool is_array)
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).

Parameters
[in]is_arrayDetermines if the element list being read is to be treated as an object (is_array == false), or as an array (is_array == true).
Returns
whether a valid BSON-object/array was passed to the SAX parser

◆ parse_bson_internal()

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
bool detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::parse_bson_internal ( )
inlineprivate

Reads in a BSON-object and passes it to the SAX-parser.

Returns
whether a valid BSON-value was passed to the SAX parser

◆ parse_cbor_internal()

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
bool detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::parse_cbor_internal ( const bool get_char,
const cbor_tag_handler_t tag_handler )
inlineprivate
Parameters
[in]get_charwhether a new character should be retrieved from the input (true) or whether the last read character should be considered instead (false)
[in]tag_handlerhow CBOR tags should be treated
Returns
whether a valid CBOR value was passed to the SAX parser

◆ parse_msgpack_internal()

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
bool detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::parse_msgpack_internal ( )
inlineprivate
Returns
whether a valid MessagePack value was passed to the SAX parser

◆ parse_ubjson_internal()

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
bool detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::parse_ubjson_internal ( const bool get_char = true)
inlineprivate
Parameters
[in]get_charwhether a new character should be retrieved from the input (true, default) or whether the last read character should be considered instead
Returns
whether a valid UBJSON value was passed to the SAX parser

◆ sax_parse()

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
bool detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::sax_parse ( const input_format_t format,
json_sax_t * sax_,
const bool strict = true,
const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error )
inline
Parameters
[in]formatthe binary format to parse
[in]sax_a SAX event processor
[in]strictwhether to expect the input to be consumed completed
[in]tag_handlerhow to treat CBOR tags
Returns
whether parsing was successful

◆ unexpect_eof()

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
bool detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::unexpect_eof ( const input_format_t format,
const char * context ) const
inlineprivate
Parameters
[in]formatthe current format (for diagnostics)
[in]contextfurther context information (for diagnostics)
Returns
whether the last read character is not EOF

Member Data Documentation

◆ __pad0__

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
JSON_PRIVATE_UNLESS_TESTED detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::__pad0__
private

◆ bjd_types_map

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
const decltype(JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_) detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::bjd_types_map
private
Initial value:
=
#define JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_
Definition json.hpp:12793

◆ chars_read

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
std::size_t detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::chars_read = 0
private

the number of characters read

◆ current

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
char_int_type detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::current = char_traits<char_type>::eof()
private

the current character

◆ ia

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
InputAdapterType detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::ia
private

input adapter

◆ input_format

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
const input_format_t detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::input_format = input_format_t::json
private

input format

◆ is_little_endian

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
const bool detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::is_little_endian = little_endianness()
private

whether we can assume little endianness

◆ npos

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
JSON_INLINE_VARIABLE constexpr std::size_t detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::npos = detail::unknown_size()
staticconstexprprivate

◆ sax

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
json_sax_t* detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::sax = nullptr
private

the SAX parser


The documentation for this class was generated from the following file: