MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/SPlisHSPlasH / binary_reader

Class binary_reader

extern/json/json.hpp:9145–12080  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9143*/
9144template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType>>
9145class binary_reader
9146{
9147 using number_integer_t = typename BasicJsonType::number_integer_t;
9148 using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
9149 using number_float_t = typename BasicJsonType::number_float_t;
9150 using string_t = typename BasicJsonType::string_t;
9151 using binary_t = typename BasicJsonType::binary_t;
9152 using json_sax_t = SAX;
9153 using char_type = typename InputAdapterType::char_type;
9154 using char_int_type = typename std::char_traits<char_type>::int_type;
9155
9156 public:
9157 /*!
9158 @brief create a binary reader
9159
9160 @param[in] adapter input adapter to read from
9161 */
9162 explicit binary_reader(InputAdapterType&& adapter, const input_format_t format = input_format_t::json) noexcept : ia(std::move(adapter)), input_format(format)
9163 {
9164 (void)detail::is_sax_static_asserts<SAX, BasicJsonType> {};
9165 }
9166
9167 // make class move-only
9168 binary_reader(const binary_reader&) = delete;
9169 binary_reader(binary_reader&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor)
9170 binary_reader& operator=(const binary_reader&) = delete;
9171 binary_reader& operator=(binary_reader&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor)
9172 ~binary_reader() = default;
9173
9174 /*!
9175 @param[in] format the binary format to parse
9176 @param[in] sax_ a SAX event processor
9177 @param[in] strict whether to expect the input to be consumed completed
9178 @param[in] tag_handler how to treat CBOR tags
9179
9180 @return whether parsing was successful
9181 */
9182 JSON_HEDLEY_NON_NULL(3)
9183 bool sax_parse(const input_format_t format,
9184 json_sax_t* sax_,
9185 const bool strict = true,
9186 const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error)
9187 {
9188 sax = sax_;
9189 bool result = false;
9190
9191 switch (format)
9192 {
9193 case input_format_t::bson:
9194 result = parse_bson_internal();
9195 break;
9196
9197 case input_format_t::cbor:
9198 result = parse_cbor_internal(true, tag_handler);
9199 break;
9200
9201 case input_format_t::msgpack:
9202 result = parse_msgpack_internal();

Callers

nothing calls this directly

Calls 6

get_token_stringFunction · 0.85
little_endiannessFunction · 0.85
getFunction · 0.70
createFunction · 0.70
concatFunction · 0.70
parse_errorMethod · 0.45

Tested by

no test coverage detected