All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
nlohmann::detail::binary_reader< BasicJsonType, SAX > Class Template Reference

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_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)
 

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_tsax = nullptr
 the SAX parser More...
 

Detailed Description

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

deserialization of CBOR, MessagePack, and UBJSON values

Definition at line 5175 of file json.hpp.

Member Typedef Documentation

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

Definition at line 5181 of file json.hpp.

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

Definition at line 5179 of file json.hpp.

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

Definition at line 5177 of file json.hpp.

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

Definition at line 5178 of file json.hpp.

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

Definition at line 5180 of file json.hpp.

Constructor & Destructor Documentation

template<typename BasicJsonType , typename SAX = json_sax_dom_parser<BasicJsonType>>
nlohmann::detail::binary_reader< BasicJsonType, SAX >::binary_reader ( input_adapter_t  adapter)
inlineexplicit

create a binary reader

Parameters
[in]adapterinput adapter to read from

Definition at line 5189 of file json.hpp.

5189  : ia(std::move(adapter))
5190  {
5191  (void)detail::is_sax_static_asserts<SAX, BasicJsonType> {};
5192  assert(ia);
5193  }
input_adapter_t ia
input adapter
Definition: json.hpp:7108
j template void())
Definition: json.hpp:3108
template<typename BasicJsonType , typename SAX = json_sax_dom_parser<BasicJsonType>>
nlohmann::detail::binary_reader< BasicJsonType, SAX >::binary_reader ( const binary_reader< BasicJsonType, SAX > &  )
delete
template<typename BasicJsonType , typename SAX = json_sax_dom_parser<BasicJsonType>>
nlohmann::detail::binary_reader< BasicJsonType, SAX >::binary_reader ( binary_reader< BasicJsonType, SAX > &&  )
default
template<typename BasicJsonType , typename SAX = json_sax_dom_parser<BasicJsonType>>
nlohmann::detail::binary_reader< BasicJsonType, SAX >::~binary_reader ( )
default

Member Function Documentation

template<typename BasicJsonType , typename SAX = json_sax_dom_parser<BasicJsonType>>
std::string nlohmann::detail::binary_reader< BasicJsonType, 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

Definition at line 7075 of file json.hpp.

7078  {
7079  std::string error_msg = "syntax error while parsing ";
7080 
7081  switch (format)
7082  {
7083  case input_format_t::cbor:
7084  error_msg += "CBOR";
7085  break;
7086 
7088  error_msg += "MessagePack";
7089  break;
7090 
7092  error_msg += "UBJSON";
7093  break;
7094 
7095  case input_format_t::bson:
7096  error_msg += "BSON";
7097  break;
7098 
7099  default: // LCOV_EXCL_LINE
7100  assert(false); // LCOV_EXCL_LINE
7101  }
7102 
7103  return error_msg + " " + context + ": " + detail;
7104  }
static std::string format(PyObject *obj, unsigned int pos, unsigned int indent, unsigned int maxlen, unsigned int depth)
Definition: fclmodule.cxx:374
template<typename BasicJsonType , typename SAX = json_sax_dom_parser<BasicJsonType>>
int nlohmann::detail::binary_reader< BasicJsonType, 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 std::char_traits<char>::eof() in that case.

Returns
character read from the input

Definition at line 6949 of file json.hpp.

6950  {
6951  ++chars_read;
6952  return current = ia->get_character();
6953  }
input_adapter_t ia
input adapter
Definition: json.hpp:7108
int current
the current character
Definition: json.hpp:7111
std::size_t chars_read
the number of characters read
Definition: json.hpp:7114
template<typename BasicJsonType , typename SAX = json_sax_dom_parser<BasicJsonType>>
bool nlohmann::detail::binary_reader< BasicJsonType, 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 -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.

5308  {
5309  auto out = std::back_inserter(result);
5310  while (true)
5311  {
5312  get();
5314  {
5315  return false;
5316  }
5317  if (current == 0x00)
5318  {
5319  return true;
5320  }
5321  *out++ = static_cast<char>(current);
5322  }
5323 
5324  return true;
5325  }
bool unexpect_eof(const input_format_t format, const char *context) const
Definition: json.hpp:7049
int current
the current character
Definition: json.hpp:7111
#define JSON_HEDLEY_UNLIKELY(expr)
Definition: json.hpp:1124
template<typename BasicJsonType , typename SAX = json_sax_dom_parser<BasicJsonType>>
template<typename NumberType >
bool nlohmann::detail::binary_reader< BasicJsonType, 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

Definition at line 5339 of file json.hpp.

5340  {
5341  if (JSON_HEDLEY_UNLIKELY(len < 1))
5342  {
5343  auto last_token = get_token_string();
5344  return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::bson, "string length must be at least 1, is " + std::to_string(len), "string")));
5345  }
5346 
5347  return get_string(input_format_t::bson, len - static_cast<NumberType>(1), result) and get() != std::char_traits<char>::eof();
5348  }
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
Definition: UtilFunc.cxx:42
int get()
get next character from the input
Definition: json.hpp:6949
return match has_match and(match.match_pdg==11 or match.match_pdg==-11)
std::string get_token_string() const
Definition: json.hpp:7062
bool get_string(const input_format_t format, const NumberType len, string_t &result)
create a string by reading characters from the input
Definition: json.hpp:7026
std::string to_string(WindowPattern const &pattern)
std::string exception_message(const input_format_t format, const std::string &detail, const std::string &context) const
Definition: json.hpp:7075
std::size_t chars_read
the number of characters read
Definition: json.hpp:7114
#define JSON_HEDLEY_UNLIKELY(expr)
Definition: json.hpp:1124
static parse_error create(int id_, const position_t &pos, const std::string &what_arg)
create a parse error exception
Definition: json.hpp:1947
json_sax_t * sax
the SAX parser
Definition: json.hpp:7120
template<typename BasicJsonType , typename SAX = json_sax_dom_parser<BasicJsonType>>
bool nlohmann::detail::binary_reader< BasicJsonType, SAX >::get_cbor_array ( const std::size_t  len)
inlineprivate
Parameters
[in]lenthe length of the array or std::size_t(-1) for an array of indefinite size
Returns
whether array creation completed

Definition at line 5928 of file json.hpp.

5929  {
5930  if (JSON_HEDLEY_UNLIKELY(not sax->start_array(len)))
5931  {
5932  return false;
5933  }
5934 
5935  if (len != std::size_t(-1))
5936  {
5937  for (std::size_t i = 0; i < len; ++i)
5938  {
5940  {
5941  return false;
5942  }
5943  }
5944  }
5945  else
5946  {
5947  while (get() != 0xFF)
5948  {
5949  if (JSON_HEDLEY_UNLIKELY(not parse_cbor_internal(false)))
5950  {
5951  return false;
5952  }
5953  }
5954  }
5955 
5956  return sax->end_array();
5957  }
bool parse_cbor_internal(const bool get_char=true)
Definition: json.hpp:5497
#define JSON_HEDLEY_UNLIKELY(expr)
Definition: json.hpp:1124
json_sax_t * sax
the SAX parser
Definition: json.hpp:7120
template<typename BasicJsonType , typename SAX = json_sax_dom_parser<BasicJsonType>>
bool nlohmann::detail::binary_reader< BasicJsonType, SAX >::get_cbor_object ( const std::size_t  len)
inlineprivate
Parameters
[in]lenthe length of the object or std::size_t(-1) for an object of indefinite size
Returns
whether object creation completed

Definition at line 5964 of file json.hpp.

5965  {
5966  if (JSON_HEDLEY_UNLIKELY(not sax->start_object(len)))
5967  {
5968  return false;
5969  }
5970 
5971  string_t key;
5972  if (len != std::size_t(-1))
5973  {
5974  for (std::size_t i = 0; i < len; ++i)
5975  {
5976  get();
5977  if (JSON_HEDLEY_UNLIKELY(not get_cbor_string(key) or not sax->key(key)))
5978  {
5979  return false;
5980  }
5981 
5983  {
5984  return false;
5985  }
5986  key.clear();
5987  }
5988  }
5989  else
5990  {
5991  while (get() != 0xFF)
5992  {
5993  if (JSON_HEDLEY_UNLIKELY(not get_cbor_string(key) or not sax->key(key)))
5994  {
5995  return false;
5996  }
5997 
5999  {
6000  return false;
6001  }
6002  key.clear();
6003  }
6004  }
6005 
6006  return sax->end_object();
6007  }
typename BasicJsonType::string_t string_t
Definition: json.hpp:5180
bool parse_cbor_internal(const bool get_char=true)
Definition: json.hpp:5497
bool get_cbor_string(string_t &result)
reads a CBOR string
Definition: json.hpp:5839
#define JSON_HEDLEY_UNLIKELY(expr)
Definition: json.hpp:1124
json_sax_t * sax
the SAX parser
Definition: json.hpp:7120
template<typename BasicJsonType , typename SAX = json_sax_dom_parser<BasicJsonType>>
bool nlohmann::detail::binary_reader< BasicJsonType, 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

Definition at line 5839 of file json.hpp.

5840  {
5842  {
5843  return false;
5844  }
5845 
5846  switch (current)
5847  {
5848  // UTF-8 string (0x00..0x17 bytes follow)
5849  case 0x60:
5850  case 0x61:
5851  case 0x62:
5852  case 0x63:
5853  case 0x64:
5854  case 0x65:
5855  case 0x66:
5856  case 0x67:
5857  case 0x68:
5858  case 0x69:
5859  case 0x6A:
5860  case 0x6B:
5861  case 0x6C:
5862  case 0x6D:
5863  case 0x6E:
5864  case 0x6F:
5865  case 0x70:
5866  case 0x71:
5867  case 0x72:
5868  case 0x73:
5869  case 0x74:
5870  case 0x75:
5871  case 0x76:
5872  case 0x77:
5873  {
5874  return get_string(input_format_t::cbor, static_cast<unsigned int>(current) & 0x1Fu, result);
5875  }
5876 
5877  case 0x78: // UTF-8 string (one-byte uint8_t for n follows)
5878  {
5879  std::uint8_t len;
5880  return get_number(input_format_t::cbor, len) and get_string(input_format_t::cbor, len, result);
5881  }
5882 
5883  case 0x79: // UTF-8 string (two-byte uint16_t for n follow)
5884  {
5885  std::uint16_t len;
5886  return get_number(input_format_t::cbor, len) and get_string(input_format_t::cbor, len, result);
5887  }
5888 
5889  case 0x7A: // UTF-8 string (four-byte uint32_t for n follow)
5890  {
5891  std::uint32_t len;
5892  return get_number(input_format_t::cbor, len) and get_string(input_format_t::cbor, len, result);
5893  }
5894 
5895  case 0x7B: // UTF-8 string (eight-byte uint64_t for n follow)
5896  {
5897  std::uint64_t len;
5898  return get_number(input_format_t::cbor, len) and get_string(input_format_t::cbor, len, result);
5899  }
5900 
5901  case 0x7F: // UTF-8 string (indefinite length)
5902  {
5903  while (get() != 0xFF)
5904  {
5905  string_t chunk;
5906  if (not get_cbor_string(chunk))
5907  {
5908  return false;
5909  }
5910  result.append(chunk);
5911  }
5912  return true;
5913  }
5914 
5915  default:
5916  {
5917  auto last_token = get_token_string();
5918  return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::cbor, "expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0x" + last_token, "string")));
5919  }
5920  }
5921  }
bool unexpect_eof(const input_format_t format, const char *context) const
Definition: json.hpp:7049
do case
typename BasicJsonType::string_t string_t
Definition: json.hpp:5180
bool get_number(const input_format_t format, NumberType &result)
Definition: json.hpp:6983
return match has_match and(match.match_pdg==11 or match.match_pdg==-11)
std::string get_token_string() const
Definition: json.hpp:7062
bool get_string(const input_format_t format, const NumberType len, string_t &result)
create a string by reading characters from the input
Definition: json.hpp:7026
std::string exception_message(const input_format_t format, const std::string &detail, const std::string &context) const
Definition: json.hpp:7075
int current
the current character
Definition: json.hpp:7111
input_format_t
the supported input formats
Definition: json.hpp:3887
std::size_t chars_read
the number of characters read
Definition: json.hpp:7114
bool get_cbor_string(string_t &result)
reads a CBOR string
Definition: json.hpp:5839
#define JSON_HEDLEY_UNLIKELY(expr)
Definition: json.hpp:1124
static parse_error create(int id_, const position_t &pos, const std::string &what_arg)
create a parse error exception
Definition: json.hpp:1947
json_sax_t * sax
the SAX parser
Definition: json.hpp:7120
template<typename BasicJsonType , typename SAX = json_sax_dom_parser<BasicJsonType>>
int nlohmann::detail::binary_reader< BasicJsonType, SAX >::get_ignore_noop ( )
inlineprivate
Returns
character read from the input after ignoring all 'N' entries

Definition at line 6958 of file json.hpp.

6959  {
6960  do
6961  {
6962  get();
6963  }
6964  while (current == 'N');
6965 
6966  return current;
6967  }
int current
the current character
Definition: json.hpp:7111
template<typename BasicJsonType , typename SAX = json_sax_dom_parser<BasicJsonType>>
bool nlohmann::detail::binary_reader< BasicJsonType, SAX >::get_msgpack_array ( const std::size_t  len)
inlineprivate
Parameters
[in]lenthe length of the array
Returns
whether array creation completed

Definition at line 6456 of file json.hpp.

6457  {
6458  if (JSON_HEDLEY_UNLIKELY(not sax->start_array(len)))
6459  {
6460  return false;
6461  }
6462 
6463  for (std::size_t i = 0; i < len; ++i)
6464  {
6466  {
6467  return false;
6468  }
6469  }
6470 
6471  return sax->end_array();
6472  }
#define JSON_HEDLEY_UNLIKELY(expr)
Definition: json.hpp:1124
json_sax_t * sax
the SAX parser
Definition: json.hpp:7120
template<typename BasicJsonType , typename SAX = json_sax_dom_parser<BasicJsonType>>
bool nlohmann::detail::binary_reader< BasicJsonType, SAX >::get_msgpack_object ( const std::size_t  len)
inlineprivate
Parameters
[in]lenthe length of the object
Returns
whether object creation completed

Definition at line 6478 of file json.hpp.

6479  {
6480  if (JSON_HEDLEY_UNLIKELY(not sax->start_object(len)))
6481  {
6482  return false;
6483  }
6484 
6485  string_t key;
6486  for (std::size_t i = 0; i < len; ++i)
6487  {
6488  get();
6489  if (JSON_HEDLEY_UNLIKELY(not get_msgpack_string(key) or not sax->key(key)))
6490  {
6491  return false;
6492  }
6493 
6495  {
6496  return false;
6497  }
6498  key.clear();
6499  }
6500 
6501  return sax->end_object();
6502  }
typename BasicJsonType::string_t string_t
Definition: json.hpp:5180
bool get_msgpack_string(string_t &result)
reads a MessagePack string
Definition: json.hpp:6380
#define JSON_HEDLEY_UNLIKELY(expr)
Definition: json.hpp:1124
json_sax_t * sax
the SAX parser
Definition: json.hpp:7120
template<typename BasicJsonType , typename SAX = json_sax_dom_parser<BasicJsonType>>
bool nlohmann::detail::binary_reader< BasicJsonType, 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

Definition at line 6380 of file json.hpp.

6381  {
6383  {
6384  return false;
6385  }
6386 
6387  switch (current)
6388  {
6389  // fixstr
6390  case 0xA0:
6391  case 0xA1:
6392  case 0xA2:
6393  case 0xA3:
6394  case 0xA4:
6395  case 0xA5:
6396  case 0xA6:
6397  case 0xA7:
6398  case 0xA8:
6399  case 0xA9:
6400  case 0xAA:
6401  case 0xAB:
6402  case 0xAC:
6403  case 0xAD:
6404  case 0xAE:
6405  case 0xAF:
6406  case 0xB0:
6407  case 0xB1:
6408  case 0xB2:
6409  case 0xB3:
6410  case 0xB4:
6411  case 0xB5:
6412  case 0xB6:
6413  case 0xB7:
6414  case 0xB8:
6415  case 0xB9:
6416  case 0xBA:
6417  case 0xBB:
6418  case 0xBC:
6419  case 0xBD:
6420  case 0xBE:
6421  case 0xBF:
6422  {
6423  return get_string(input_format_t::msgpack, static_cast<unsigned int>(current) & 0x1Fu, result);
6424  }
6425 
6426  case 0xD9: // str 8
6427  {
6428  std::uint8_t len;
6430  }
6431 
6432  case 0xDA: // str 16
6433  {
6434  std::uint16_t len;
6435  return get_number(input_format_t::msgpack, len) and get_string(input_format_t::msgpack, len, result);
6436  }
6437 
6438  case 0xDB: // str 32
6439  {
6440  std::uint32_t len;
6441  return get_number(input_format_t::msgpack, len) and get_string(input_format_t::msgpack, len, result);
6442  }
6443 
6444  default:
6445  {
6446  auto last_token = get_token_string();
6447  return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::msgpack, "expected length specification (0xA0-0xBF, 0xD9-0xDB); last byte: 0x" + last_token, "string")));
6448  }
6449  }
6450  }
bool unexpect_eof(const input_format_t format, const char *context) const
Definition: json.hpp:7049
do case
bool get_number(const input_format_t format, NumberType &result)
Definition: json.hpp:6983
BEGIN_PROLOG default
return match has_match and(match.match_pdg==11 or match.match_pdg==-11)
std::string get_token_string() const
Definition: json.hpp:7062
bool get_string(const input_format_t format, const NumberType len, string_t &result)
create a string by reading characters from the input
Definition: json.hpp:7026
std::string exception_message(const input_format_t format, const std::string &detail, const std::string &context) const
Definition: json.hpp:7075
int current
the current character
Definition: json.hpp:7111
input_format_t
the supported input formats
Definition: json.hpp:3887
std::size_t chars_read
the number of characters read
Definition: json.hpp:7114
#define JSON_HEDLEY_UNLIKELY(expr)
Definition: json.hpp:1124
static parse_error create(int id_, const position_t &pos, const std::string &what_arg)
create a parse error exception
Definition: json.hpp:1947
json_sax_t * sax
the SAX parser
Definition: json.hpp:7120
template<typename BasicJsonType , typename SAX = json_sax_dom_parser<BasicJsonType>>
template<typename NumberType , bool InputIsLittleEndian = false>
bool nlohmann::detail::binary_reader< BasicJsonType, SAX >::get_number ( const input_format_t  format,
NumberType &  result 
)
inlineprivate

Definition at line 6983 of file json.hpp.

6984  {
6985  // step 1: read input into array with system's byte order
6986  std::array<std::uint8_t, sizeof(NumberType)> vec;
6987  for (std::size_t i = 0; i < sizeof(NumberType); ++i)
6988  {
6989  get();
6990  if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(format, "number")))
6991  {
6992  return false;
6993  }
6994 
6995  // reverse byte order prior to conversion if necessary
6996  if (is_little_endian != InputIsLittleEndian)
6997  {
6998  vec[sizeof(NumberType) - i - 1] = static_cast<std::uint8_t>(current);
6999  }
7000  else
7001  {
7002  vec[i] = static_cast<std::uint8_t>(current); // LCOV_EXCL_LINE
7003  }
7004  }
7005 
7006  // step 2: convert array into number of type T and return
7007  std::memcpy(&result, vec.data(), sizeof(NumberType));
7008  return true;
7009  }
bool unexpect_eof(const input_format_t format, const char *context) const
Definition: json.hpp:7049
static std::string format(PyObject *obj, unsigned int pos, unsigned int indent, unsigned int maxlen, unsigned int depth)
Definition: fclmodule.cxx:374
const bool is_little_endian
whether we can assume little endianess
Definition: json.hpp:7117
int current
the current character
Definition: json.hpp:7111
#define JSON_HEDLEY_UNLIKELY(expr)
Definition: json.hpp:1124
template<typename BasicJsonType , typename SAX = json_sax_dom_parser<BasicJsonType>>
template<typename NumberType >
bool nlohmann::detail::binary_reader< BasicJsonType, 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.

Definition at line 7026 of file json.hpp.

7029  {
7030  bool success = true;
7031  std::generate_n(std::back_inserter(result), len, [this, &success, &format]()
7032  {
7033  get();
7034  if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(format, "string")))
7035  {
7036  success = false;
7037  }
7038  return static_cast<char>(current);
7039  });
7040  return success;
7041  }
bool unexpect_eof(const input_format_t format, const char *context) const
Definition: json.hpp:7049
static std::string format(PyObject *obj, unsigned int pos, unsigned int indent, unsigned int maxlen, unsigned int depth)
Definition: fclmodule.cxx:374
int current
the current character
Definition: json.hpp:7111
#define JSON_HEDLEY_UNLIKELY(expr)
Definition: json.hpp:1124
template<typename BasicJsonType , typename SAX = json_sax_dom_parser<BasicJsonType>>
std::string nlohmann::detail::binary_reader< BasicJsonType, SAX >::get_token_string ( ) const
inlineprivate
Returns
a string representation of the last read byte

Definition at line 7062 of file json.hpp.

7063  {
7064  std::array<char, 3> cr{{}};
7065  (std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast<unsigned char>(current));
7066  return std::string{cr.data()};
7067  }
int current
the current character
Definition: json.hpp:7111
template<typename BasicJsonType , typename SAX = json_sax_dom_parser<BasicJsonType>>
bool nlohmann::detail::binary_reader< BasicJsonType, SAX >::get_ubjson_array ( )
inlineprivate
Returns
whether array creation completed

Definition at line 6802 of file json.hpp.

6803  {
6804  std::pair<std::size_t, int> size_and_type;
6805  if (JSON_HEDLEY_UNLIKELY(not get_ubjson_size_type(size_and_type)))
6806  {
6807  return false;
6808  }
6809 
6810  if (size_and_type.first != string_t::npos)
6811  {
6812  if (JSON_HEDLEY_UNLIKELY(not sax->start_array(size_and_type.first)))
6813  {
6814  return false;
6815  }
6816 
6817  if (size_and_type.second != 0)
6818  {
6819  if (size_and_type.second != 'N')
6820  {
6821  for (std::size_t i = 0; i < size_and_type.first; ++i)
6822  {
6823  if (JSON_HEDLEY_UNLIKELY(not get_ubjson_value(size_and_type.second)))
6824  {
6825  return false;
6826  }
6827  }
6828  }
6829  }
6830  else
6831  {
6832  for (std::size_t i = 0; i < size_and_type.first; ++i)
6833  {
6835  {
6836  return false;
6837  }
6838  }
6839  }
6840  }
6841  else
6842  {
6843  if (JSON_HEDLEY_UNLIKELY(not sax->start_array(std::size_t(-1))))
6844  {
6845  return false;
6846  }
6847 
6848  while (current != ']')
6849  {
6851  {
6852  return false;
6853  }
6854  get_ignore_noop();
6855  }
6856  }
6857 
6858  return sax->end_array();
6859  }
bool parse_ubjson_internal(const bool get_char=true)
Definition: json.hpp:6515
bool get_ubjson_value(const int prefix)
Definition: json.hpp:6706
int current
the current character
Definition: json.hpp:7111
bool get_ubjson_size_type(std::pair< std::size_t, int > &result)
determine the type and size for a container
Definition: json.hpp:6665
#define JSON_HEDLEY_UNLIKELY(expr)
Definition: json.hpp:1124
json_sax_t * sax
the SAX parser
Definition: json.hpp:7120
template<typename BasicJsonType , typename SAX = json_sax_dom_parser<BasicJsonType>>
bool nlohmann::detail::binary_reader< BasicJsonType, SAX >::get_ubjson_object ( )
inlineprivate
Returns
whether object creation completed

Definition at line 6864 of file json.hpp.

6865  {
6866  std::pair<std::size_t, int> size_and_type;
6867  if (JSON_HEDLEY_UNLIKELY(not get_ubjson_size_type(size_and_type)))
6868  {
6869  return false;
6870  }
6871 
6872  string_t key;
6873  if (size_and_type.first != string_t::npos)
6874  {
6875  if (JSON_HEDLEY_UNLIKELY(not sax->start_object(size_and_type.first)))
6876  {
6877  return false;
6878  }
6879 
6880  if (size_and_type.second != 0)
6881  {
6882  for (std::size_t i = 0; i < size_and_type.first; ++i)
6883  {
6884  if (JSON_HEDLEY_UNLIKELY(not get_ubjson_string(key) or not sax->key(key)))
6885  {
6886  return false;
6887  }
6888  if (JSON_HEDLEY_UNLIKELY(not get_ubjson_value(size_and_type.second)))
6889  {
6890  return false;
6891  }
6892  key.clear();
6893  }
6894  }
6895  else
6896  {
6897  for (std::size_t i = 0; i < size_and_type.first; ++i)
6898  {
6899  if (JSON_HEDLEY_UNLIKELY(not get_ubjson_string(key) or not sax->key(key)))
6900  {
6901  return false;
6902  }
6904  {
6905  return false;
6906  }
6907  key.clear();
6908  }
6909  }
6910  }
6911  else
6912  {
6913  if (JSON_HEDLEY_UNLIKELY(not sax->start_object(std::size_t(-1))))
6914  {
6915  return false;
6916  }
6917 
6918  while (current != '}')
6919  {
6920  if (JSON_HEDLEY_UNLIKELY(not get_ubjson_string(key, false) or not sax->key(key)))
6921  {
6922  return false;
6923  }
6925  {
6926  return false;
6927  }
6928  get_ignore_noop();
6929  key.clear();
6930  }
6931  }
6932 
6933  return sax->end_object();
6934  }
typename BasicJsonType::string_t string_t
Definition: json.hpp:5180
bool get_ubjson_string(string_t &result, const bool get_char=true)
reads a UBJSON string
Definition: json.hpp:6534
bool parse_ubjson_internal(const bool get_char=true)
Definition: json.hpp:6515
bool get_ubjson_value(const int prefix)
Definition: json.hpp:6706
int current
the current character
Definition: json.hpp:7111
bool get_ubjson_size_type(std::pair< std::size_t, int > &result)
determine the type and size for a container
Definition: json.hpp:6665
#define JSON_HEDLEY_UNLIKELY(expr)
Definition: json.hpp:1124
json_sax_t * sax
the SAX parser
Definition: json.hpp:7120
template<typename BasicJsonType , typename SAX = json_sax_dom_parser<BasicJsonType>>
bool nlohmann::detail::binary_reader< BasicJsonType, SAX >::get_ubjson_size_type ( std::pair< std::size_t, int > &  result)
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
Returns
whether pair creation completed

Definition at line 6665 of file json.hpp.

6666  {
6667  result.first = string_t::npos; // size
6668  result.second = 0; // type
6669 
6670  get_ignore_noop();
6671 
6672  if (current == '$')
6673  {
6674  result.second = get(); // must not ignore 'N', because 'N' maybe the type
6676  {
6677  return false;
6678  }
6679 
6680  get_ignore_noop();
6681  if (JSON_HEDLEY_UNLIKELY(current != '#'))
6682  {
6684  {
6685  return false;
6686  }
6687  auto last_token = get_token_string();
6688  return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::ubjson, "expected '#' after type information; last byte: 0x" + last_token, "size")));
6689  }
6690 
6691  return get_ubjson_size_value(result.first);
6692  }
6693 
6694  if (current == '#')
6695  {
6696  return get_ubjson_size_value(result.first);
6697  }
6698 
6699  return true;
6700  }
bool unexpect_eof(const input_format_t format, const char *context) const
Definition: json.hpp:7049
std::string get_token_string() const
Definition: json.hpp:7062
bool get_ubjson_size_value(std::size_t &result)
Definition: json.hpp:6588
std::string exception_message(const input_format_t format, const std::string &detail, const std::string &context) const
Definition: json.hpp:7075
int current
the current character
Definition: json.hpp:7111
std::size_t chars_read
the number of characters read
Definition: json.hpp:7114
#define JSON_HEDLEY_UNLIKELY(expr)
Definition: json.hpp:1124
static parse_error create(int id_, const position_t &pos, const std::string &what_arg)
create a parse error exception
Definition: json.hpp:1947
json_sax_t * sax
the SAX parser
Definition: json.hpp:7120
template<typename BasicJsonType , typename SAX = json_sax_dom_parser<BasicJsonType>>
bool nlohmann::detail::binary_reader< BasicJsonType, SAX >::get_ubjson_size_value ( std::size_t &  result)
inlineprivate
Parameters
[out]resultdetermined size
Returns
whether size determination completed

Definition at line 6588 of file json.hpp.

6589  {
6590  switch (get_ignore_noop())
6591  {
6592  case 'U':
6593  {
6594  std::uint8_t number;
6596  {
6597  return false;
6598  }
6599  result = static_cast<std::size_t>(number);
6600  return true;
6601  }
6602 
6603  case 'i':
6604  {
6605  std::int8_t number;
6607  {
6608  return false;
6609  }
6610  result = static_cast<std::size_t>(number);
6611  return true;
6612  }
6613 
6614  case 'I':
6615  {
6616  std::int16_t number;
6618  {
6619  return false;
6620  }
6621  result = static_cast<std::size_t>(number);
6622  return true;
6623  }
6624 
6625  case 'l':
6626  {
6627  std::int32_t number;
6629  {
6630  return false;
6631  }
6632  result = static_cast<std::size_t>(number);
6633  return true;
6634  }
6635 
6636  case 'L':
6637  {
6638  std::int64_t number;
6640  {
6641  return false;
6642  }
6643  result = static_cast<std::size_t>(number);
6644  return true;
6645  }
6646 
6647  default:
6648  {
6649  auto last_token = get_token_string();
6650  return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::ubjson, "expected length type specification (U, i, I, l, L) after '#'; last byte: 0x" + last_token, "size")));
6651  }
6652  }
6653  }
bool get_number(const input_format_t format, NumberType &result)
Definition: json.hpp:6983
std::string get_token_string() const
Definition: json.hpp:7062
std::string exception_message(const input_format_t format, const std::string &detail, const std::string &context) const
Definition: json.hpp:7075
std::size_t chars_read
the number of characters read
Definition: json.hpp:7114
#define JSON_HEDLEY_UNLIKELY(expr)
Definition: json.hpp:1124
static parse_error create(int id_, const position_t &pos, const std::string &what_arg)
create a parse error exception
Definition: json.hpp:1947
json_sax_t * sax
the SAX parser
Definition: json.hpp:7120
template<typename BasicJsonType , typename SAX = json_sax_dom_parser<BasicJsonType>>
bool nlohmann::detail::binary_reader< BasicJsonType, 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

Definition at line 6534 of file json.hpp.

6535  {
6536  if (get_char)
6537  {
6538  get(); // TODO(niels): may we ignore N here?
6539  }
6540 
6542  {
6543  return false;
6544  }
6545 
6546  switch (current)
6547  {
6548  case 'U':
6549  {
6550  std::uint8_t len;
6552  }
6553 
6554  case 'i':
6555  {
6556  std::int8_t len;
6557  return get_number(input_format_t::ubjson, len) and get_string(input_format_t::ubjson, len, result);
6558  }
6559 
6560  case 'I':
6561  {
6562  std::int16_t len;
6563  return get_number(input_format_t::ubjson, len) and get_string(input_format_t::ubjson, len, result);
6564  }
6565 
6566  case 'l':
6567  {
6568  std::int32_t len;
6569  return get_number(input_format_t::ubjson, len) and get_string(input_format_t::ubjson, len, result);
6570  }
6571 
6572  case 'L':
6573  {
6574  std::int64_t len;
6575  return get_number(input_format_t::ubjson, len) and get_string(input_format_t::ubjson, len, result);
6576  }
6577 
6578  default:
6579  auto last_token = get_token_string();
6580  return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::ubjson, "expected length type specification (U, i, I, l, L); last byte: 0x" + last_token, "string")));
6581  }
6582  }
see a below echo or echo I(indirect symbol).'echo" If the symbol is local (non-external)
bool unexpect_eof(const input_format_t format, const char *context) const
Definition: json.hpp:7049
do case
process_name opflash particleana ie x
bool get_number(const input_format_t format, NumberType &result)
Definition: json.hpp:6983
BEGIN_PROLOG default
return match has_match and(match.match_pdg==11 or match.match_pdg==-11)
std::string get_token_string() const
Definition: json.hpp:7062
bool get_string(const input_format_t format, const NumberType len, string_t &result)
create a string by reading characters from the input
Definition: json.hpp:7026
std::string exception_message(const input_format_t format, const std::string &detail, const std::string &context) const
Definition: json.hpp:7075
byte_as<> byte
Type of data size stored in bytes, in long long precision.
Definition: datasize.h:98
int current
the current character
Definition: json.hpp:7111
input_format_t
the supported input formats
Definition: json.hpp:3887
std::size_t chars_read
the number of characters read
Definition: json.hpp:7114
#define JSON_HEDLEY_UNLIKELY(expr)
Definition: json.hpp:1124
json_sax_t * sax
the SAX parser
Definition: json.hpp:7120
template<typename BasicJsonType , typename SAX = json_sax_dom_parser<BasicJsonType>>
bool nlohmann::detail::binary_reader< BasicJsonType, SAX >::get_ubjson_value ( const int  prefix)
inlineprivate
Parameters
prefixthe previously read or set type prefix
Returns
whether value creation completed

Definition at line 6706 of file json.hpp.

6707  {
6708  switch (prefix)
6709  {
6710  case std::char_traits<char>::eof(): // EOF
6711  return unexpect_eof(input_format_t::ubjson, "value");
6712 
6713  case 'T': // true
6714  return sax->boolean(true);
6715  case 'F': // false
6716  return sax->boolean(false);
6717 
6718  case 'Z': // null
6719  return sax->null();
6720 
6721  case 'U':
6722  {
6723  std::uint8_t number;
6724  return get_number(input_format_t::ubjson, number) and sax->number_unsigned(number);
6725  }
6726 
6727  case 'i':
6728  {
6729  std::int8_t number;
6730  return get_number(input_format_t::ubjson, number) and sax->number_integer(number);
6731  }
6732 
6733  case 'I':
6734  {
6735  std::int16_t number;
6736  return get_number(input_format_t::ubjson, number) and sax->number_integer(number);
6737  }
6738 
6739  case 'l':
6740  {
6741  std::int32_t number;
6742  return get_number(input_format_t::ubjson, number) and sax->number_integer(number);
6743  }
6744 
6745  case 'L':
6746  {
6747  std::int64_t number;
6748  return get_number(input_format_t::ubjson, number) and sax->number_integer(number);
6749  }
6750 
6751  case 'd':
6752  {
6753  float number;
6754  return get_number(input_format_t::ubjson, number) and sax->number_float(static_cast<number_float_t>(number), "");
6755  }
6756 
6757  case 'D':
6758  {
6759  double number;
6760  return get_number(input_format_t::ubjson, number) and sax->number_float(static_cast<number_float_t>(number), "");
6761  }
6762 
6763  case 'C': // char
6764  {
6765  get();
6767  {
6768  return false;
6769  }
6770  if (JSON_HEDLEY_UNLIKELY(current > 127))
6771  {
6772  auto last_token = get_token_string();
6773  return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::ubjson, "byte after 'C' must be in range 0x00..0x7F; last byte: 0x" + last_token, "char")));
6774  }
6775  string_t s(1, static_cast<char>(current));
6776  return sax->string(s);
6777  }
6778 
6779  case 'S': // string
6780  {
6781  string_t s;
6782  return get_ubjson_string(s) and sax->string(s);
6783  }
6784 
6785  case '[': // array
6786  return get_ubjson_array();
6787 
6788  case '{': // object
6789  return get_ubjson_object();
6790 
6791  default: // anything else
6792  {
6793  auto last_token = get_token_string();
6794  return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::ubjson, "invalid byte: 0x" + last_token, "value")));
6795  }
6796  }
6797  }
see a below echo or echo I(indirect symbol).'echo" If the symbol is local (non-external)
bool unexpect_eof(const input_format_t format, const char *context) const
Definition: json.hpp:7049
do case
typename BasicJsonType::string_t string_t
Definition: json.hpp:5180
bool get_ubjson_string(string_t &result, const bool get_char=true)
reads a UBJSON string
Definition: json.hpp:6534
number value (signed integer)
bool get_number(const input_format_t format, NumberType &result)
Definition: json.hpp:6983
return match has_match and(match.match_pdg==11 or match.match_pdg==-11)
std::string get_token_string() const
Definition: json.hpp:7062
then echo File list $list not found else cat $list while read file do echo $file sed s
Definition: file_to_url.sh:60
std::string exception_message(const input_format_t format, const std::string &detail, const std::string &context) const
Definition: json.hpp:7075
int current
the current character
Definition: json.hpp:7111
input_format_t
the supported input formats
Definition: json.hpp:3887
number value (unsigned integer)
std::size_t chars_read
the number of characters read
Definition: json.hpp:7114
number value (floating-point)
#define JSON_HEDLEY_UNLIKELY(expr)
Definition: json.hpp:1124
static parse_error create(int id_, const position_t &pos, const std::string &what_arg)
create a parse error exception
Definition: json.hpp:1947
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:5179
json_sax_t * sax
the SAX parser
Definition: json.hpp:7120
template<typename BasicJsonType , typename SAX = json_sax_dom_parser<BasicJsonType>>
static constexpr bool nlohmann::detail::binary_reader< BasicJsonType, SAX >::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 5268 of file json.hpp.

5269  {
5270  return *reinterpret_cast<char*>(&num) == 1;
5271  }
template<typename BasicJsonType , typename SAX = json_sax_dom_parser<BasicJsonType>>
binary_reader& nlohmann::detail::binary_reader< BasicJsonType, SAX >::operator= ( const binary_reader< BasicJsonType, SAX > &  )
delete
template<typename BasicJsonType , typename SAX = json_sax_dom_parser<BasicJsonType>>
binary_reader& nlohmann::detail::binary_reader< BasicJsonType, SAX >::operator= ( binary_reader< BasicJsonType, SAX > &&  )
default
template<typename BasicJsonType , typename SAX = json_sax_dom_parser<BasicJsonType>>
bool nlohmann::detail::binary_reader< BasicJsonType, 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

Definition at line 5468 of file json.hpp.

5469  {
5470  std::int32_t document_size;
5471  get_number<std::int32_t, true>(input_format_t::bson, document_size);
5472 
5473  if (JSON_HEDLEY_UNLIKELY(not sax->start_array(std::size_t(-1))))
5474  {
5475  return false;
5476  }
5477 
5478  if (JSON_HEDLEY_UNLIKELY(not parse_bson_element_list(/*is_array*/true)))
5479  {
5480  return false;
5481  }
5482 
5483  return sax->end_array();
5484  }
bool parse_bson_element_list(const bool is_array)
Read a BSON element list (as specified in the BSON-spec)
Definition: json.hpp:5431
#define JSON_HEDLEY_UNLIKELY(expr)
Definition: json.hpp:1124
json_sax_t * sax
the SAX parser
Definition: json.hpp:7120
template<typename BasicJsonType , typename SAX = json_sax_dom_parser<BasicJsonType>>
bool nlohmann::detail::binary_reader< BasicJsonType, SAX >::parse_bson_element_internal ( const int  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

Definition at line 5360 of file json.hpp.

5362  {
5363  switch (element_type)
5364  {
5365  case 0x01: // double
5366  {
5367  double number;
5368  return get_number<double, true>(input_format_t::bson, number) and sax->number_float(static_cast<number_float_t>(number), "");
5369  }
5370 
5371  case 0x02: // string
5372  {
5373  std::int32_t len;
5374  string_t value;
5375  return get_number<std::int32_t, true>(input_format_t::bson, len) and get_bson_string(len, value) and sax->string(value);
5376  }
5377 
5378  case 0x03: // object
5379  {
5380  return parse_bson_internal();
5381  }
5382 
5383  case 0x04: // array
5384  {
5385  return parse_bson_array();
5386  }
5387 
5388  case 0x08: // boolean
5389  {
5390  return sax->boolean(get() != 0);
5391  }
5392 
5393  case 0x0A: // null
5394  {
5395  return sax->null();
5396  }
5397 
5398  case 0x10: // int32
5399  {
5400  std::int32_t value;
5401  return get_number<std::int32_t, true>(input_format_t::bson, value) and sax->number_integer(value);
5402  }
5403 
5404  case 0x12: // int64
5405  {
5406  std::int64_t value;
5407  return get_number<std::int64_t, true>(input_format_t::bson, value) and sax->number_integer(value);
5408  }
5409 
5410  default: // anything else not supported (yet)
5411  {
5412  std::array<char, 3> cr{{}};
5413  (std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast<unsigned char>(element_type));
5414  return sax->parse_error(element_type_parse_position, std::string(cr.data()), parse_error::create(114, element_type_parse_position, "Unsupported BSON record type 0x" + std::string(cr.data())));
5415  }
5416  }
5417  }
bool get_bson_string(const NumberType len, string_t &result)
Parses a zero-terminated string of length len from the BSON input.
Definition: json.hpp:5339
do case
typename BasicJsonType::string_t string_t
Definition: json.hpp:5180
bool parse_bson_array()
Reads an array from the BSON input and passes it to the SAX-parser.
Definition: json.hpp:5468
bool parse_bson_internal()
Reads in a BSON-object and passes it to the SAX-parser.
Definition: json.hpp:5282
return match has_match and(match.match_pdg==11 or match.match_pdg==-11)
temporary value
static parse_error create(int id_, const position_t &pos, const std::string &what_arg)
create a parse error exception
Definition: json.hpp:1947
json_sax_t * sax
the SAX parser
Definition: json.hpp:7120
template<typename BasicJsonType , typename SAX = json_sax_dom_parser<BasicJsonType>>
bool nlohmann::detail::binary_reader< BasicJsonType, 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

Definition at line 5431 of file json.hpp.

5432  {
5433  string_t key;
5434  while (int element_type = get())
5435  {
5436  if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::bson, "element list")))
5437  {
5438  return false;
5439  }
5440 
5441  const std::size_t element_type_parse_position = chars_read;
5442  if (JSON_HEDLEY_UNLIKELY(not get_bson_cstr(key)))
5443  {
5444  return false;
5445  }
5446 
5447  if (not is_array and not sax->key(key))
5448  {
5449  return false;
5450  }
5451 
5452  if (JSON_HEDLEY_UNLIKELY(not parse_bson_element_internal(element_type, element_type_parse_position)))
5453  {
5454  return false;
5455  }
5456 
5457  // get_bson_cstr only appends
5458  key.clear();
5459  }
5460 
5461  return true;
5462  }
bool unexpect_eof(const input_format_t format, const char *context) const
Definition: json.hpp:7049
typename BasicJsonType::string_t string_t
Definition: json.hpp:5180
return match has_match and(match.match_pdg==11 or match.match_pdg==-11)
bool get_bson_cstr(string_t &result)
Parses a C-style string from the BSON input.
Definition: json.hpp:5307
std::size_t chars_read
the number of characters read
Definition: json.hpp:7114
#define JSON_HEDLEY_UNLIKELY(expr)
Definition: json.hpp:1124
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.
Definition: json.hpp:5360
json_sax_t * sax
the SAX parser
Definition: json.hpp:7120
template<typename BasicJsonType , typename SAX = json_sax_dom_parser<BasicJsonType>>
bool nlohmann::detail::binary_reader< BasicJsonType, 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

Definition at line 5282 of file json.hpp.

5283  {
5284  std::int32_t document_size;
5285  get_number<std::int32_t, true>(input_format_t::bson, document_size);
5286 
5287  if (JSON_HEDLEY_UNLIKELY(not sax->start_object(std::size_t(-1))))
5288  {
5289  return false;
5290  }
5291 
5292  if (JSON_HEDLEY_UNLIKELY(not parse_bson_element_list(/*is_array*/false)))
5293  {
5294  return false;
5295  }
5296 
5297  return sax->end_object();
5298  }
bool parse_bson_element_list(const bool is_array)
Read a BSON element list (as specified in the BSON-spec)
Definition: json.hpp:5431
#define JSON_HEDLEY_UNLIKELY(expr)
Definition: json.hpp:1124
json_sax_t * sax
the SAX parser
Definition: json.hpp:7120
template<typename BasicJsonType , typename SAX = json_sax_dom_parser<BasicJsonType>>
bool nlohmann::detail::binary_reader< BasicJsonType, SAX >::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
Returns
whether a valid CBOR value was passed to the SAX parser

Definition at line 5497 of file json.hpp.

5498  {
5499  switch (get_char ? get() : current)
5500  {
5501  // EOF
5502  case std::char_traits<char>::eof():
5503  return unexpect_eof(input_format_t::cbor, "value");
5504 
5505  // Integer 0x00..0x17 (0..23)
5506  case 0x00:
5507  case 0x01:
5508  case 0x02:
5509  case 0x03:
5510  case 0x04:
5511  case 0x05:
5512  case 0x06:
5513  case 0x07:
5514  case 0x08:
5515  case 0x09:
5516  case 0x0A:
5517  case 0x0B:
5518  case 0x0C:
5519  case 0x0D:
5520  case 0x0E:
5521  case 0x0F:
5522  case 0x10:
5523  case 0x11:
5524  case 0x12:
5525  case 0x13:
5526  case 0x14:
5527  case 0x15:
5528  case 0x16:
5529  case 0x17:
5530  return sax->number_unsigned(static_cast<number_unsigned_t>(current));
5531 
5532  case 0x18: // Unsigned integer (one-byte uint8_t follows)
5533  {
5534  std::uint8_t number;
5535  return get_number(input_format_t::cbor, number) and sax->number_unsigned(number);
5536  }
5537 
5538  case 0x19: // Unsigned integer (two-byte uint16_t follows)
5539  {
5540  std::uint16_t number;
5541  return get_number(input_format_t::cbor, number) and sax->number_unsigned(number);
5542  }
5543 
5544  case 0x1A: // Unsigned integer (four-byte uint32_t follows)
5545  {
5546  std::uint32_t number;
5547  return get_number(input_format_t::cbor, number) and sax->number_unsigned(number);
5548  }
5549 
5550  case 0x1B: // Unsigned integer (eight-byte uint64_t follows)
5551  {
5552  std::uint64_t number;
5553  return get_number(input_format_t::cbor, number) and sax->number_unsigned(number);
5554  }
5555 
5556  // Negative integer -1-0x00..-1-0x17 (-1..-24)
5557  case 0x20:
5558  case 0x21:
5559  case 0x22:
5560  case 0x23:
5561  case 0x24:
5562  case 0x25:
5563  case 0x26:
5564  case 0x27:
5565  case 0x28:
5566  case 0x29:
5567  case 0x2A:
5568  case 0x2B:
5569  case 0x2C:
5570  case 0x2D:
5571  case 0x2E:
5572  case 0x2F:
5573  case 0x30:
5574  case 0x31:
5575  case 0x32:
5576  case 0x33:
5577  case 0x34:
5578  case 0x35:
5579  case 0x36:
5580  case 0x37:
5581  return sax->number_integer(static_cast<std::int8_t>(0x20 - 1 - current));
5582 
5583  case 0x38: // Negative integer (one-byte uint8_t follows)
5584  {
5585  std::uint8_t number;
5586  return get_number(input_format_t::cbor, number) and sax->number_integer(static_cast<number_integer_t>(-1) - number);
5587  }
5588 
5589  case 0x39: // Negative integer -1-n (two-byte uint16_t follows)
5590  {
5591  std::uint16_t number;
5592  return get_number(input_format_t::cbor, number) and sax->number_integer(static_cast<number_integer_t>(-1) - number);
5593  }
5594 
5595  case 0x3A: // Negative integer -1-n (four-byte uint32_t follows)
5596  {
5597  std::uint32_t number;
5598  return get_number(input_format_t::cbor, number) and sax->number_integer(static_cast<number_integer_t>(-1) - number);
5599  }
5600 
5601  case 0x3B: // Negative integer -1-n (eight-byte uint64_t follows)
5602  {
5603  std::uint64_t number;
5604  return get_number(input_format_t::cbor, number) and sax->number_integer(static_cast<number_integer_t>(-1)
5605  - static_cast<number_integer_t>(number));
5606  }
5607 
5608  // UTF-8 string (0x00..0x17 bytes follow)
5609  case 0x60:
5610  case 0x61:
5611  case 0x62:
5612  case 0x63:
5613  case 0x64:
5614  case 0x65:
5615  case 0x66:
5616  case 0x67:
5617  case 0x68:
5618  case 0x69:
5619  case 0x6A:
5620  case 0x6B:
5621  case 0x6C:
5622  case 0x6D:
5623  case 0x6E:
5624  case 0x6F:
5625  case 0x70:
5626  case 0x71:
5627  case 0x72:
5628  case 0x73:
5629  case 0x74:
5630  case 0x75:
5631  case 0x76:
5632  case 0x77:
5633  case 0x78: // UTF-8 string (one-byte uint8_t for n follows)
5634  case 0x79: // UTF-8 string (two-byte uint16_t for n follow)
5635  case 0x7A: // UTF-8 string (four-byte uint32_t for n follow)
5636  case 0x7B: // UTF-8 string (eight-byte uint64_t for n follow)
5637  case 0x7F: // UTF-8 string (indefinite length)
5638  {
5639  string_t s;
5640  return get_cbor_string(s) and sax->string(s);
5641  }
5642 
5643  // array (0x00..0x17 data items follow)
5644  case 0x80:
5645  case 0x81:
5646  case 0x82:
5647  case 0x83:
5648  case 0x84:
5649  case 0x85:
5650  case 0x86:
5651  case 0x87:
5652  case 0x88:
5653  case 0x89:
5654  case 0x8A:
5655  case 0x8B:
5656  case 0x8C:
5657  case 0x8D:
5658  case 0x8E:
5659  case 0x8F:
5660  case 0x90:
5661  case 0x91:
5662  case 0x92:
5663  case 0x93:
5664  case 0x94:
5665  case 0x95:
5666  case 0x96:
5667  case 0x97:
5668  return get_cbor_array(static_cast<std::size_t>(static_cast<unsigned int>(current) & 0x1Fu));
5669 
5670  case 0x98: // array (one-byte uint8_t for n follows)
5671  {
5672  std::uint8_t len;
5673  return get_number(input_format_t::cbor, len) and get_cbor_array(static_cast<std::size_t>(len));
5674  }
5675 
5676  case 0x99: // array (two-byte uint16_t for n follow)
5677  {
5678  std::uint16_t len;
5679  return get_number(input_format_t::cbor, len) and get_cbor_array(static_cast<std::size_t>(len));
5680  }
5681 
5682  case 0x9A: // array (four-byte uint32_t for n follow)
5683  {
5684  std::uint32_t len;
5685  return get_number(input_format_t::cbor, len) and get_cbor_array(static_cast<std::size_t>(len));
5686  }
5687 
5688  case 0x9B: // array (eight-byte uint64_t for n follow)
5689  {
5690  std::uint64_t len;
5691  return get_number(input_format_t::cbor, len) and get_cbor_array(static_cast<std::size_t>(len));
5692  }
5693 
5694  case 0x9F: // array (indefinite length)
5695  return get_cbor_array(std::size_t(-1));
5696 
5697  // map (0x00..0x17 pairs of data items follow)
5698  case 0xA0:
5699  case 0xA1:
5700  case 0xA2:
5701  case 0xA3:
5702  case 0xA4:
5703  case 0xA5:
5704  case 0xA6:
5705  case 0xA7:
5706  case 0xA8:
5707  case 0xA9:
5708  case 0xAA:
5709  case 0xAB:
5710  case 0xAC:
5711  case 0xAD:
5712  case 0xAE:
5713  case 0xAF:
5714  case 0xB0:
5715  case 0xB1:
5716  case 0xB2:
5717  case 0xB3:
5718  case 0xB4:
5719  case 0xB5:
5720  case 0xB6:
5721  case 0xB7:
5722  return get_cbor_object(static_cast<std::size_t>(static_cast<unsigned int>(current) & 0x1Fu));
5723 
5724  case 0xB8: // map (one-byte uint8_t for n follows)
5725  {
5726  std::uint8_t len;
5727  return get_number(input_format_t::cbor, len) and get_cbor_object(static_cast<std::size_t>(len));
5728  }
5729 
5730  case 0xB9: // map (two-byte uint16_t for n follow)
5731  {
5732  std::uint16_t len;
5733  return get_number(input_format_t::cbor, len) and get_cbor_object(static_cast<std::size_t>(len));
5734  }
5735 
5736  case 0xBA: // map (four-byte uint32_t for n follow)
5737  {
5738  std::uint32_t len;
5739  return get_number(input_format_t::cbor, len) and get_cbor_object(static_cast<std::size_t>(len));
5740  }
5741 
5742  case 0xBB: // map (eight-byte uint64_t for n follow)
5743  {
5744  std::uint64_t len;
5745  return get_number(input_format_t::cbor, len) and get_cbor_object(static_cast<std::size_t>(len));
5746  }
5747 
5748  case 0xBF: // map (indefinite length)
5749  return get_cbor_object(std::size_t(-1));
5750 
5751  case 0xF4: // false
5752  return sax->boolean(false);
5753 
5754  case 0xF5: // true
5755  return sax->boolean(true);
5756 
5757  case 0xF6: // null
5758  return sax->null();
5759 
5760  case 0xF9: // Half-Precision Float (two-byte IEEE 754)
5761  {
5762  const int byte1_raw = get();
5764  {
5765  return false;
5766  }
5767  const int byte2_raw = get();
5769  {
5770  return false;
5771  }
5772 
5773  const auto byte1 = static_cast<unsigned char>(byte1_raw);
5774  const auto byte2 = static_cast<unsigned char>(byte2_raw);
5775 
5776  // code from RFC 7049, Appendix D, Figure 3:
5777  // As half-precision floating-point numbers were only added
5778  // to IEEE 754 in 2008, today's programming platforms often
5779  // still only have limited support for them. It is very
5780  // easy to include at least decoding support for them even
5781  // without such support. An example of a small decoder for
5782  // half-precision floating-point numbers in the C language
5783  // is shown in Fig. 3.
5784  const auto half = static_cast<unsigned int>((byte1 << 8u) + byte2);
5785  const double val = [&half]
5786  {
5787  const int exp = (half >> 10u) & 0x1Fu;
5788  const unsigned int mant = half & 0x3FFu;
5789  assert(0 <= exp and exp <= 32);
5790  assert(mant <= 1024);
5791  switch (exp)
5792  {
5793  case 0:
5794  return std::ldexp(mant, -24);
5795  case 31:
5796  return (mant == 0)
5797  ? std::numeric_limits<double>::infinity()
5798  : std::numeric_limits<double>::quiet_NaN();
5799  default:
5800  return std::ldexp(mant + 1024, exp - 25);
5801  }
5802  }();
5803  return sax->number_float((half & 0x8000u) != 0
5804  ? static_cast<number_float_t>(-val)
5805  : static_cast<number_float_t>(val), "");
5806  }
5807 
5808  case 0xFA: // Single-Precision Float (four-byte IEEE 754)
5809  {
5810  float number;
5811  return get_number(input_format_t::cbor, number) and sax->number_float(static_cast<number_float_t>(number), "");
5812  }
5813 
5814  case 0xFB: // Double-Precision Float (eight-byte IEEE 754)
5815  {
5816  double number;
5817  return get_number(input_format_t::cbor, number) and sax->number_float(static_cast<number_float_t>(number), "");
5818  }
5819 
5820  default: // anything else (0xFF is handled inside the other types)
5821  {
5822  auto last_token = get_token_string();
5823  return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::cbor, "invalid byte: 0x" + last_token, "value")));
5824  }
5825  }
5826  }
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
Definition: UtilFunc.cxx:42
bool unexpect_eof(const input_format_t format, const char *context) const
Definition: json.hpp:7049
do case
typename BasicJsonType::string_t string_t
Definition: json.hpp:5180
number value (signed integer)
typename BasicJsonType::number_integer_t number_integer_t
Definition: json.hpp:5177
bool get_number(const input_format_t format, NumberType &result)
Definition: json.hpp:6983
bool get_cbor_object(const std::size_t len)
Definition: json.hpp:5964
BEGIN_PROLOG default
bool get_cbor_array(const std::size_t len)
Definition: json.hpp:5928
return match has_match and(match.match_pdg==11 or match.match_pdg==-11)
std::string get_token_string() const
Definition: json.hpp:7062
then echo File list $list not found else cat $list while read file do echo $file sed s
Definition: file_to_url.sh:60
std::string exception_message(const input_format_t format, const std::string &detail, const std::string &context) const
Definition: json.hpp:7075
int current
the current character
Definition: json.hpp:7111
input_format_t
the supported input formats
Definition: json.hpp:3887
number value (unsigned integer)
std::size_t chars_read
the number of characters read
Definition: json.hpp:7114
number value (floating-point)
bool get_cbor_string(string_t &result)
reads a CBOR string
Definition: json.hpp:5839
#define JSON_HEDLEY_UNLIKELY(expr)
Definition: json.hpp:1124
BEGIN_PROLOG don t mess with this pandoraTrackGausCryoW true
static parse_error create(int id_, const position_t &pos, const std::string &what_arg)
create a parse error exception
Definition: json.hpp:1947
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:5179
json_sax_t * sax
the SAX parser
Definition: json.hpp:7120
template<typename BasicJsonType , typename SAX = json_sax_dom_parser<BasicJsonType>>
bool nlohmann::detail::binary_reader< BasicJsonType, SAX >::parse_msgpack_internal ( )
inlineprivate
Returns
whether a valid MessagePack value was passed to the SAX parser

Definition at line 6016 of file json.hpp.

6017  {
6018  switch (get())
6019  {
6020  // EOF
6021  case std::char_traits<char>::eof():
6022  return unexpect_eof(input_format_t::msgpack, "value");
6023 
6024  // positive fixint
6025  case 0x00:
6026  case 0x01:
6027  case 0x02:
6028  case 0x03:
6029  case 0x04:
6030  case 0x05:
6031  case 0x06:
6032  case 0x07:
6033  case 0x08:
6034  case 0x09:
6035  case 0x0A:
6036  case 0x0B:
6037  case 0x0C:
6038  case 0x0D:
6039  case 0x0E:
6040  case 0x0F:
6041  case 0x10:
6042  case 0x11:
6043  case 0x12:
6044  case 0x13:
6045  case 0x14:
6046  case 0x15:
6047  case 0x16:
6048  case 0x17:
6049  case 0x18:
6050  case 0x19:
6051  case 0x1A:
6052  case 0x1B:
6053  case 0x1C:
6054  case 0x1D:
6055  case 0x1E:
6056  case 0x1F:
6057  case 0x20:
6058  case 0x21:
6059  case 0x22:
6060  case 0x23:
6061  case 0x24:
6062  case 0x25:
6063  case 0x26:
6064  case 0x27:
6065  case 0x28:
6066  case 0x29:
6067  case 0x2A:
6068  case 0x2B:
6069  case 0x2C:
6070  case 0x2D:
6071  case 0x2E:
6072  case 0x2F:
6073  case 0x30:
6074  case 0x31:
6075  case 0x32:
6076  case 0x33:
6077  case 0x34:
6078  case 0x35:
6079  case 0x36:
6080  case 0x37:
6081  case 0x38:
6082  case 0x39:
6083  case 0x3A:
6084  case 0x3B:
6085  case 0x3C:
6086  case 0x3D:
6087  case 0x3E:
6088  case 0x3F:
6089  case 0x40:
6090  case 0x41:
6091  case 0x42:
6092  case 0x43:
6093  case 0x44:
6094  case 0x45:
6095  case 0x46:
6096  case 0x47:
6097  case 0x48:
6098  case 0x49:
6099  case 0x4A:
6100  case 0x4B:
6101  case 0x4C:
6102  case 0x4D:
6103  case 0x4E:
6104  case 0x4F:
6105  case 0x50:
6106  case 0x51:
6107  case 0x52:
6108  case 0x53:
6109  case 0x54:
6110  case 0x55:
6111  case 0x56:
6112  case 0x57:
6113  case 0x58:
6114  case 0x59:
6115  case 0x5A:
6116  case 0x5B:
6117  case 0x5C:
6118  case 0x5D:
6119  case 0x5E:
6120  case 0x5F:
6121  case 0x60:
6122  case 0x61:
6123  case 0x62:
6124  case 0x63:
6125  case 0x64:
6126  case 0x65:
6127  case 0x66:
6128  case 0x67:
6129  case 0x68:
6130  case 0x69:
6131  case 0x6A:
6132  case 0x6B:
6133  case 0x6C:
6134  case 0x6D:
6135  case 0x6E:
6136  case 0x6F:
6137  case 0x70:
6138  case 0x71:
6139  case 0x72:
6140  case 0x73:
6141  case 0x74:
6142  case 0x75:
6143  case 0x76:
6144  case 0x77:
6145  case 0x78:
6146  case 0x79:
6147  case 0x7A:
6148  case 0x7B:
6149  case 0x7C:
6150  case 0x7D:
6151  case 0x7E:
6152  case 0x7F:
6153  return sax->number_unsigned(static_cast<number_unsigned_t>(current));
6154 
6155  // fixmap
6156  case 0x80:
6157  case 0x81:
6158  case 0x82:
6159  case 0x83:
6160  case 0x84:
6161  case 0x85:
6162  case 0x86:
6163  case 0x87:
6164  case 0x88:
6165  case 0x89:
6166  case 0x8A:
6167  case 0x8B:
6168  case 0x8C:
6169  case 0x8D:
6170  case 0x8E:
6171  case 0x8F:
6172  return get_msgpack_object(static_cast<std::size_t>(static_cast<unsigned int>(current) & 0x0Fu));
6173 
6174  // fixarray
6175  case 0x90:
6176  case 0x91:
6177  case 0x92:
6178  case 0x93:
6179  case 0x94:
6180  case 0x95:
6181  case 0x96:
6182  case 0x97:
6183  case 0x98:
6184  case 0x99:
6185  case 0x9A:
6186  case 0x9B:
6187  case 0x9C:
6188  case 0x9D:
6189  case 0x9E:
6190  case 0x9F:
6191  return get_msgpack_array(static_cast<std::size_t>(static_cast<unsigned int>(current) & 0x0Fu));
6192 
6193  // fixstr
6194  case 0xA0:
6195  case 0xA1:
6196  case 0xA2:
6197  case 0xA3:
6198  case 0xA4:
6199  case 0xA5:
6200  case 0xA6:
6201  case 0xA7:
6202  case 0xA8:
6203  case 0xA9:
6204  case 0xAA:
6205  case 0xAB:
6206  case 0xAC:
6207  case 0xAD:
6208  case 0xAE:
6209  case 0xAF:
6210  case 0xB0:
6211  case 0xB1:
6212  case 0xB2:
6213  case 0xB3:
6214  case 0xB4:
6215  case 0xB5:
6216  case 0xB6:
6217  case 0xB7:
6218  case 0xB8:
6219  case 0xB9:
6220  case 0xBA:
6221  case 0xBB:
6222  case 0xBC:
6223  case 0xBD:
6224  case 0xBE:
6225  case 0xBF:
6226  case 0xD9: // str 8
6227  case 0xDA: // str 16
6228  case 0xDB: // str 32
6229  {
6230  string_t s;
6231  return get_msgpack_string(s) and sax->string(s);
6232  }
6233 
6234  case 0xC0: // nil
6235  return sax->null();
6236 
6237  case 0xC2: // false
6238  return sax->boolean(false);
6239 
6240  case 0xC3: // true
6241  return sax->boolean(true);
6242 
6243  case 0xCA: // float 32
6244  {
6245  float number;
6246  return get_number(input_format_t::msgpack, number) and sax->number_float(static_cast<number_float_t>(number), "");
6247  }
6248 
6249  case 0xCB: // float 64
6250  {
6251  double number;
6252  return get_number(input_format_t::msgpack, number) and sax->number_float(static_cast<number_float_t>(number), "");
6253  }
6254 
6255  case 0xCC: // uint 8
6256  {
6257  std::uint8_t number;
6258  return get_number(input_format_t::msgpack, number) and sax->number_unsigned(number);
6259  }
6260 
6261  case 0xCD: // uint 16
6262  {
6263  std::uint16_t number;
6264  return get_number(input_format_t::msgpack, number) and sax->number_unsigned(number);
6265  }
6266 
6267  case 0xCE: // uint 32
6268  {
6269  std::uint32_t number;
6270  return get_number(input_format_t::msgpack, number) and sax->number_unsigned(number);
6271  }
6272 
6273  case 0xCF: // uint 64
6274  {
6275  std::uint64_t number;
6276  return get_number(input_format_t::msgpack, number) and sax->number_unsigned(number);
6277  }
6278 
6279  case 0xD0: // int 8
6280  {
6281  std::int8_t number;
6282  return get_number(input_format_t::msgpack, number) and sax->number_integer(number);
6283  }
6284 
6285  case 0xD1: // int 16
6286  {
6287  std::int16_t number;
6288  return get_number(input_format_t::msgpack, number) and sax->number_integer(number);
6289  }
6290 
6291  case 0xD2: // int 32
6292  {
6293  std::int32_t number;
6294  return get_number(input_format_t::msgpack, number) and sax->number_integer(number);
6295  }
6296 
6297  case 0xD3: // int 64
6298  {
6299  std::int64_t number;
6300  return get_number(input_format_t::msgpack, number) and sax->number_integer(number);
6301  }
6302 
6303  case 0xDC: // array 16
6304  {
6305  std::uint16_t len;
6306  return get_number(input_format_t::msgpack, len) and get_msgpack_array(static_cast<std::size_t>(len));
6307  }
6308 
6309  case 0xDD: // array 32
6310  {
6311  std::uint32_t len;
6312  return get_number(input_format_t::msgpack, len) and get_msgpack_array(static_cast<std::size_t>(len));
6313  }
6314 
6315  case 0xDE: // map 16
6316  {
6317  std::uint16_t len;
6318  return get_number(input_format_t::msgpack, len) and get_msgpack_object(static_cast<std::size_t>(len));
6319  }
6320 
6321  case 0xDF: // map 32
6322  {
6323  std::uint32_t len;
6324  return get_number(input_format_t::msgpack, len) and get_msgpack_object(static_cast<std::size_t>(len));
6325  }
6326 
6327  // negative fixint
6328  case 0xE0:
6329  case 0xE1:
6330  case 0xE2:
6331  case 0xE3:
6332  case 0xE4:
6333  case 0xE5:
6334  case 0xE6:
6335  case 0xE7:
6336  case 0xE8:
6337  case 0xE9:
6338  case 0xEA:
6339  case 0xEB:
6340  case 0xEC:
6341  case 0xED:
6342  case 0xEE:
6343  case 0xEF:
6344  case 0xF0:
6345  case 0xF1:
6346  case 0xF2:
6347  case 0xF3:
6348  case 0xF4:
6349  case 0xF5:
6350  case 0xF6:
6351  case 0xF7:
6352  case 0xF8:
6353  case 0xF9:
6354  case 0xFA:
6355  case 0xFB:
6356  case 0xFC:
6357  case 0xFD:
6358  case 0xFE:
6359  case 0xFF:
6360  return sax->number_integer(static_cast<std::int8_t>(current));
6361 
6362  default: // anything else
6363  {
6364  auto last_token = get_token_string();
6365  return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::msgpack, "invalid byte: 0x" + last_token, "value")));
6366  }
6367  }
6368  }
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
Definition: UtilFunc.cxx:42
bool unexpect_eof(const input_format_t format, const char *context) const
Definition: json.hpp:7049
do case
typename BasicJsonType::string_t string_t
Definition: json.hpp:5180
number value (signed integer)
bool get_msgpack_object(const std::size_t len)
Definition: json.hpp:6478
bool get_number(const input_format_t format, NumberType &result)
Definition: json.hpp:6983
BEGIN_PROLOG default
return match has_match and(match.match_pdg==11 or match.match_pdg==-11)
std::string get_token_string() const
Definition: json.hpp:7062
bool get_msgpack_string(string_t &result)
reads a MessagePack string
Definition: json.hpp:6380
then echo File list $list not found else cat $list while read file do echo $file sed s
Definition: file_to_url.sh:60
std::string exception_message(const input_format_t format, const std::string &detail, const std::string &context) const
Definition: json.hpp:7075
int current
the current character
Definition: json.hpp:7111
input_format_t
the supported input formats
Definition: json.hpp:3887
number value (unsigned integer)
std::size_t chars_read
the number of characters read
Definition: json.hpp:7114
number value (floating-point)
BEGIN_PROLOG don t mess with this pandoraTrackGausCryoW true
bool get_msgpack_array(const std::size_t len)
Definition: json.hpp:6456
static parse_error create(int id_, const position_t &pos, const std::string &what_arg)
create a parse error exception
Definition: json.hpp:1947
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:5179
json_sax_t * sax
the SAX parser
Definition: json.hpp:7120
template<typename BasicJsonType , typename SAX = json_sax_dom_parser<BasicJsonType>>
bool nlohmann::detail::binary_reader< BasicJsonType, 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

Definition at line 6515 of file json.hpp.

6516  {
6517  return get_ubjson_value(get_char ? get_ignore_noop() : current);
6518  }
bool get_ubjson_value(const int prefix)
Definition: json.hpp:6706
int current
the current character
Definition: json.hpp:7111
template<typename BasicJsonType , typename SAX = json_sax_dom_parser<BasicJsonType>>
bool nlohmann::detail::binary_reader< BasicJsonType, SAX >::sax_parse ( const input_format_t  format,
json_sax_t sax_,
const bool  strict = true 
)
inline
Parameters
[in]formatthe binary format to parse
[in]sax_a SAX event processor
[in]strictwhether to expect the input to be consumed completed
Returns

Definition at line 5210 of file json.hpp.

5213  {
5214  sax = sax_;
5215  bool result = false;
5216 
5217  switch (format)
5218  {
5219  case input_format_t::bson:
5220  result = parse_bson_internal();
5221  break;
5222 
5223  case input_format_t::cbor:
5224  result = parse_cbor_internal();
5225  break;
5226 
5228  result = parse_msgpack_internal();
5229  break;
5230 
5232  result = parse_ubjson_internal();
5233  break;
5234 
5235  default: // LCOV_EXCL_LINE
5236  assert(false); // LCOV_EXCL_LINE
5237  }
5238 
5239  // strict mode: next byte must be EOF
5240  if (result and strict)
5241  {
5243  {
5244  get_ignore_noop();
5245  }
5246  else
5247  {
5248  get();
5249  }
5250 
5251  if (JSON_HEDLEY_UNLIKELY(current != std::char_traits<char>::eof()))
5252  {
5253  return sax->parse_error(chars_read, get_token_string(),
5254  parse_error::create(110, chars_read, exception_message(format, "expected end of input; last byte: 0x" + get_token_string(), "value")));
5255  }
5256  }
5257 
5258  return result;
5259  }
static std::string format(PyObject *obj, unsigned int pos, unsigned int indent, unsigned int maxlen, unsigned int depth)
Definition: fclmodule.cxx:374
bool parse_cbor_internal(const bool get_char=true)
Definition: json.hpp:5497
throw a type_error exception in case of invalid UTF-8
bool parse_ubjson_internal(const bool get_char=true)
Definition: json.hpp:6515
bool parse_bson_internal()
Reads in a BSON-object and passes it to the SAX-parser.
Definition: json.hpp:5282
return match has_match and(match.match_pdg==11 or match.match_pdg==-11)
std::string get_token_string() const
Definition: json.hpp:7062
std::string exception_message(const input_format_t format, const std::string &detail, const std::string &context) const
Definition: json.hpp:7075
int current
the current character
Definition: json.hpp:7111
std::size_t chars_read
the number of characters read
Definition: json.hpp:7114
#define JSON_HEDLEY_UNLIKELY(expr)
Definition: json.hpp:1124
static parse_error create(int id_, const position_t &pos, const std::string &what_arg)
create a parse error exception
Definition: json.hpp:1947
json_sax_t * sax
the SAX parser
Definition: json.hpp:7120
template<typename BasicJsonType , typename SAX = json_sax_dom_parser<BasicJsonType>>
bool nlohmann::detail::binary_reader< BasicJsonType, 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

Definition at line 7049 of file json.hpp.

7050  {
7051  if (JSON_HEDLEY_UNLIKELY(current == std::char_traits<char>::eof()))
7052  {
7053  return sax->parse_error(chars_read, "<end of file>",
7054  parse_error::create(110, chars_read, exception_message(format, "unexpected end of input", context)));
7055  }
7056  return true;
7057  }
static std::string format(PyObject *obj, unsigned int pos, unsigned int indent, unsigned int maxlen, unsigned int depth)
Definition: fclmodule.cxx:374
std::string exception_message(const input_format_t format, const std::string &detail, const std::string &context) const
Definition: json.hpp:7075
int current
the current character
Definition: json.hpp:7111
std::size_t chars_read
the number of characters read
Definition: json.hpp:7114
#define JSON_HEDLEY_UNLIKELY(expr)
Definition: json.hpp:1124
static parse_error create(int id_, const position_t &pos, const std::string &what_arg)
create a parse error exception
Definition: json.hpp:1947
json_sax_t * sax
the SAX parser
Definition: json.hpp:7120

Member Data Documentation

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

the number of characters read

Definition at line 7114 of file json.hpp.

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

the current character

Definition at line 7111 of file json.hpp.

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

input adapter

Definition at line 7108 of file json.hpp.

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

whether we can assume little endianess

Definition at line 7117 of file json.hpp.

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

the SAX parser

Definition at line 7120 of file json.hpp.


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