MCPcopy Create free account
hub / github.com/OpenFodder/openfodder / binary_reader

Class binary_reader

Source/Utils/json.hpp:7694–10094  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7692 */
7693 template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType>>
7694 class binary_reader
7695 {
7696 using number_integer_t = typename BasicJsonType::number_integer_t;
7697 using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
7698 using number_float_t = typename BasicJsonType::number_float_t;
7699 using string_t = typename BasicJsonType::string_t;
7700 using binary_t = typename BasicJsonType::binary_t;
7701 using json_sax_t = SAX;
7702 using char_type = typename InputAdapterType::char_type;
7703 using char_int_type = typename std::char_traits<char_type>::int_type;
7704
7705 public:
7706 /*!
7707 @brief create a binary reader
7708
7709 @param[in] adapter input adapter to read from
7710 */
7711 explicit binary_reader(InputAdapterType&& adapter) : ia(std::move(adapter))
7712 {
7713 (void)detail::is_sax_static_asserts<SAX, BasicJsonType> {};
7714 }
7715
7716 // make class move-only
7717 binary_reader(const binary_reader&) = delete;
7718 binary_reader(binary_reader&&) = default;
7719 binary_reader& operator=(const binary_reader&) = delete;
7720 binary_reader& operator=(binary_reader&&) = default;
7721 ~binary_reader() = default;
7722
7723 /*!
7724 @param[in] format the binary format to parse
7725 @param[in] sax_ a SAX event processor
7726 @param[in] strict whether to expect the input to be consumed completed
7727 @param[in] tag_handler how to treat CBOR tags
7728
7729 @return
7730 */
7731 JSON_HEDLEY_NON_NULL(3)
7732 bool sax_parse(const input_format_t format,
7733 json_sax_t* sax_,
7734 const bool strict = true,
7735 const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error)
7736 {
7737 sax = sax_;
7738 bool result = false;
7739
7740 switch (format)
7741 {
7742 case input_format_t::bson:
7743 result = parse_bson_internal();
7744 break;
7745
7746 case input_format_t::cbor:
7747 result = parse_cbor_internal(true, tag_handler);
7748 break;
7749
7750 case input_format_t::msgpack:
7751 result = parse_msgpack_internal();

Callers

nothing calls this directly

Calls 5

getFunction · 0.85
get_token_stringFunction · 0.85
createFunction · 0.85
little_endianessFunction · 0.85
parse_errorMethod · 0.45

Tested by

no test coverage detected