MCPcopy Create free account
hub / github.com/AllentDan/LibtorchTutorials / binary_reader

Class binary_reader

lesson6-Segmentation/json.hpp:7695–10096  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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