MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / binary_reader

Class binary_reader

3rd/nlohmann_json/single_include/nlohmann/json.hpp:8447–10910  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8445*/
8446template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType>>
8447class binary_reader
8448{
8449 using number_integer_t = typename BasicJsonType::number_integer_t;
8450 using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
8451 using number_float_t = typename BasicJsonType::number_float_t;
8452 using string_t = typename BasicJsonType::string_t;
8453 using binary_t = typename BasicJsonType::binary_t;
8454 using json_sax_t = SAX;
8455 using char_type = typename InputAdapterType::char_type;
8456 using char_int_type = typename std::char_traits<char_type>::int_type;
8457
8458 public:
8459 /*!
8460 @brief create a binary reader
8461
8462 @param[in] adapter input adapter to read from
8463 */
8464 explicit binary_reader(InputAdapterType&& adapter) noexcept : ia(std::move(adapter))
8465 {
8466 (void)detail::is_sax_static_asserts<SAX, BasicJsonType> {};
8467 }
8468
8469 // make class move-only
8470 binary_reader(const binary_reader&) = delete;
8471 binary_reader(binary_reader&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor)
8472 binary_reader& operator=(const binary_reader&) = delete;
8473 binary_reader& operator=(binary_reader&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor)
8474 ~binary_reader() = default;
8475
8476 /*!
8477 @param[in] format the binary format to parse
8478 @param[in] sax_ a SAX event processor
8479 @param[in] strict whether to expect the input to be consumed completed
8480 @param[in] tag_handler how to treat CBOR tags
8481
8482 @return whether parsing was successful
8483 */
8484 JSON_HEDLEY_NON_NULL(3)
8485 bool sax_parse(const input_format_t format,
8486 json_sax_t* sax_,
8487 const bool strict = true,
8488 const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error)
8489 {
8490 sax = sax_;
8491 bool result = false;
8492
8493 switch (format)
8494 {
8495 case input_format_t::bson:
8496 result = parse_bson_internal();
8497 break;
8498
8499 case input_format_t::cbor:
8500 result = parse_cbor_internal(true, tag_handler);
8501 break;
8502
8503 case input_format_t::msgpack:
8504 result = parse_msgpack_internal();

Callers

nothing calls this directly

Calls 5

getFunction · 0.70
get_token_stringFunction · 0.70
createFunction · 0.70
little_endianessFunction · 0.70
parse_errorMethod · 0.45

Tested by

no test coverage detected