Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
nlohmann::detail::binary_reader< BasicJsonType > Class Template Reference

deserialization of CBOR and MessagePack values More...

#include <json.hpp>

Public Member Functions

 binary_reader (input_adapter_t adapter)
 create a binary reader More...
 
BasicJsonType parse_cbor (const bool strict)
 create a JSON value from CBOR input More...
 
BasicJsonType parse_msgpack (const bool strict)
 create a JSON value from MessagePack input More...
 
BasicJsonType parse_ubjson (const bool strict)
 create a JSON value from UBJSON input More...
 

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 string_t = typename BasicJsonType::string_t
 

Private Member Functions

void expect_eof () const
 throw if end of input is not reached More...
 
int get ()
 get next character from the input More...
 
template<typename NumberType >
BasicJsonType get_cbor_array (const NumberType len)
 
template<typename NumberType >
BasicJsonType get_cbor_object (const NumberType len)
 
string_t get_cbor_string ()
 reads a CBOR string More...
 
int get_ignore_noop ()
 
template<typename NumberType >
BasicJsonType get_msgpack_array (const NumberType len)
 
template<typename NumberType >
BasicJsonType get_msgpack_object (const NumberType len)
 
string_t get_msgpack_string ()
 reads a MessagePack string More...
 
template<typename NumberType >
NumberType get_number ()
 
template<typename NumberType >
string_t get_string (const NumberType len)
 create a string by reading characters from the input More...
 
BasicJsonType get_ubjson_array ()
 
BasicJsonType get_ubjson_object ()
 
std::pair< std::size_t, int > get_ubjson_size_type ()
 determine the type and size for a container More...
 
string_t get_ubjson_string (const bool get_char=true)
 reads a UBJSON string More...
 
BasicJsonType get_ubjson_value (const int prefix)
 
BasicJsonType parse_cbor_internal (const bool get_char=true)
 
BasicJsonType parse_msgpack_internal ()
 
BasicJsonType parse_ubjson_internal (const bool get_char=true)
 
void unexpect_eof () const
 

Private Attributes

std::size_t chars_read = 0
 the number of characters read More...
 
int current = std::char_traits<char>::eof()
 the current character More...
 
input_adapter_t ia = nullptr
 input adapter More...
 
const bool is_little_endian = little_endianess()
 whether we can assume little endianess More...
 

Detailed Description

template<typename BasicJsonType>
class nlohmann::detail::binary_reader< BasicJsonType >

deserialization of CBOR and MessagePack values

Definition at line 4865 of file json.hpp.

Member Typedef Documentation

template<typename BasicJsonType >
using nlohmann::detail::binary_reader< BasicJsonType >::number_integer_t = typename BasicJsonType::number_integer_t
private

Definition at line 4867 of file json.hpp.

template<typename BasicJsonType >
using nlohmann::detail::binary_reader< BasicJsonType >::number_unsigned_t = typename BasicJsonType::number_unsigned_t
private

Definition at line 4868 of file json.hpp.

template<typename BasicJsonType >
using nlohmann::detail::binary_reader< BasicJsonType >::string_t = typename BasicJsonType::string_t
private

Definition at line 4869 of file json.hpp.

Constructor & Destructor Documentation

template<typename BasicJsonType >
nlohmann::detail::binary_reader< BasicJsonType >::binary_reader ( input_adapter_t  adapter)
inlineexplicit

create a binary reader

Parameters
[in]adapterinput adapter to read from

Definition at line 4877 of file json.hpp.

Member Function Documentation

template<typename BasicJsonType >
void nlohmann::detail::binary_reader< BasicJsonType >::expect_eof ( ) const
inlineprivate

throw if end of input is not reached

Exceptions
parse_error.110if input not ended

Definition at line 6170 of file json.hpp.

template<typename BasicJsonType >
int nlohmann::detail::binary_reader< BasicJsonType >::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 std::char_traits<char>::eof() in that case.

Returns
character read from the input

Definition at line 5624 of file json.hpp.

template<typename BasicJsonType >
template<typename NumberType >
BasicJsonType nlohmann::detail::binary_reader< BasicJsonType >::get_cbor_array ( const NumberType  len)
inlineprivate

Definition at line 5796 of file json.hpp.

template<typename BasicJsonType >
template<typename NumberType >
BasicJsonType nlohmann::detail::binary_reader< BasicJsonType >::get_cbor_object ( const NumberType  len)
inlineprivate

Definition at line 5807 of file json.hpp.

template<typename BasicJsonType >
string_t nlohmann::detail::binary_reader< BasicJsonType >::get_cbor_string ( )
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.

Returns
string
Exceptions
parse_error.110if input ended
parse_error.113if an unexpected byte is read

Definition at line 5721 of file json.hpp.

template<typename BasicJsonType >
int nlohmann::detail::binary_reader< BasicJsonType >::get_ignore_noop ( )
inlineprivate
Returns
character read from the input after ignoring all 'N' entries

Definition at line 5633 of file json.hpp.

template<typename BasicJsonType >
template<typename NumberType >
BasicJsonType nlohmann::detail::binary_reader< BasicJsonType >::get_msgpack_array ( const NumberType  len)
inlineprivate

Definition at line 5902 of file json.hpp.

template<typename BasicJsonType >
template<typename NumberType >
BasicJsonType nlohmann::detail::binary_reader< BasicJsonType >::get_msgpack_object ( const NumberType  len)
inlineprivate

Definition at line 5913 of file json.hpp.

template<typename BasicJsonType >
string_t nlohmann::detail::binary_reader< BasicJsonType >::get_msgpack_string ( )
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.

Returns
string
Exceptions
parse_error.110if input ended
parse_error.113if an unexpected byte is read

Definition at line 5833 of file json.hpp.

template<typename BasicJsonType >
template<typename NumberType >
NumberType nlohmann::detail::binary_reader< BasicJsonType >::get_number ( )
inlineprivate

Definition at line 5657 of file json.hpp.

template<typename BasicJsonType >
template<typename NumberType >
string_t nlohmann::detail::binary_reader< BasicJsonType >::get_string ( const NumberType  len)
inlineprivate

create a string by reading characters from the input

Parameters
[in]lennumber of bytes to read
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.
Returns
string created by reading len bytes
Exceptions
parse_error.110if input has less than len bytes

Definition at line 5697 of file json.hpp.

template<typename BasicJsonType >
BasicJsonType nlohmann::detail::binary_reader< BasicJsonType >::get_ubjson_array ( )
inlineprivate

Definition at line 6072 of file json.hpp.

template<typename BasicJsonType >
BasicJsonType nlohmann::detail::binary_reader< BasicJsonType >::get_ubjson_object ( )
inlineprivate

Definition at line 6117 of file json.hpp.

template<typename BasicJsonType >
std::pair<std::size_t, int> nlohmann::detail::binary_reader< BasicJsonType >::get_ubjson_size_type ( )
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.

Returns
pair of the size and the type

Definition at line 5981 of file json.hpp.

template<typename BasicJsonType >
string_t nlohmann::detail::binary_reader< BasicJsonType >::get_ubjson_string ( 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
[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
string
Exceptions
parse_error.110if input ended
parse_error.113if an unexpected byte is read

Definition at line 5944 of file json.hpp.

template<typename BasicJsonType >
BasicJsonType nlohmann::detail::binary_reader< BasicJsonType >::get_ubjson_value ( const int  prefix)
inlineprivate

Definition at line 6011 of file json.hpp.

template<typename BasicJsonType >
static constexpr bool nlohmann::detail::binary_reader< BasicJsonType >::little_endianess ( int  num = 1)
inlinestaticnoexcept

determine system byte order

Returns
true if and only if system's byte order is little endian
Note
from http://stackoverflow.com/a/1001328/266378

Definition at line 4952 of file json.hpp.

template<typename BasicJsonType >
BasicJsonType nlohmann::detail::binary_reader< BasicJsonType >::parse_cbor ( const bool  strict)
inline

create a JSON value from CBOR input

Parameters
[in]strictwhether to expect the input to be consumed completed
Returns
JSON value created from CBOR input
Exceptions
parse_error.110if input ended unexpectedly or the end of file was not reached when strict was set to true
parse_error.112if unsupported byte was read

Definition at line 4892 of file json.hpp.

template<typename BasicJsonType >
BasicJsonType nlohmann::detail::binary_reader< BasicJsonType >::parse_cbor_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

Definition at line 4963 of file json.hpp.

template<typename BasicJsonType >
BasicJsonType nlohmann::detail::binary_reader< BasicJsonType >::parse_msgpack ( const bool  strict)
inline

create a JSON value from MessagePack input

Parameters
[in]strictwhether to expect the input to be consumed completed
Returns
JSON value created from MessagePack input
Exceptions
parse_error.110if input ended unexpectedly or the end of file was not reached when strict was set to true
parse_error.112if unsupported byte was read

Definition at line 4913 of file json.hpp.

template<typename BasicJsonType >
BasicJsonType nlohmann::detail::binary_reader< BasicJsonType >::parse_msgpack_internal ( )
inlineprivate

Definition at line 5280 of file json.hpp.

template<typename BasicJsonType >
BasicJsonType nlohmann::detail::binary_reader< BasicJsonType >::parse_ubjson ( const bool  strict)
inline

create a JSON value from UBJSON input

Parameters
[in]strictwhether to expect the input to be consumed completed
Returns
JSON value created from UBJSON input
Exceptions
parse_error.110if input ended unexpectedly or the end of file was not reached when strict was set to true
parse_error.112if unsupported byte was read

Definition at line 4934 of file json.hpp.

template<typename BasicJsonType >
BasicJsonType nlohmann::detail::binary_reader< BasicJsonType >::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

Definition at line 5610 of file json.hpp.

template<typename BasicJsonType >
void nlohmann::detail::binary_reader< BasicJsonType >::unexpect_eof ( ) const
inlineprivate

if end of input is reached

Exceptions
parse_error.110if input ended

Definition at line 6182 of file json.hpp.

Member Data Documentation

template<typename BasicJsonType >
std::size_t nlohmann::detail::binary_reader< BasicJsonType >::chars_read = 0
private

the number of characters read

Definition at line 6198 of file json.hpp.

template<typename BasicJsonType >
int nlohmann::detail::binary_reader< BasicJsonType >::current = std::char_traits<char>::eof()
private

the current character

Definition at line 6195 of file json.hpp.

template<typename BasicJsonType >
input_adapter_t nlohmann::detail::binary_reader< BasicJsonType >::ia = nullptr
private

input adapter

Definition at line 6192 of file json.hpp.

template<typename BasicJsonType >
const bool nlohmann::detail::binary_reader< BasicJsonType >::is_little_endian = little_endianess()
private

whether we can assume little endianess

Definition at line 6201 of file json.hpp.


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


json_transport
Author(s): Paul Bovbel
autogenerated on Thu Jun 13 2019 19:12:24