MCPcopy Create free account
hub / github.com/Predelnik/DSpellCheck / parse_bson_element_internal

Method parse_bson_element_internal

deps/json/json.hpp:9350–9416  ·  view source on GitHub ↗

! @brief Read a BSON document element of the given @a element_type. @param[in] element_type The BSON element type, c.f. http://bsonspec.org/spec.html @param[in] element_type_parse_position The position in the input stream, where the `element_type` was read. @warning Not all BSON element types are supported yet. An unsupported @a element_type will give ri

Source from the content-addressed store, hash-verified

9348 @return whether a valid BSON-object/array was passed to the SAX parser
9349 */
9350 bool parse_bson_element_internal(const char_int_type element_type,
9351 const std::size_t element_type_parse_position)
9352 {
9353 switch (element_type)
9354 {
9355 case 0x01: // double
9356 {
9357 double number{};
9358 return get_number<double, true>(input_format_t::bson, number) && sax->number_float(static_cast<number_float_t>(number), "");
9359 }
9360
9361 case 0x02: // string
9362 {
9363 std::int32_t len{};
9364 string_t value;
9365 return get_number<std::int32_t, true>(input_format_t::bson, len) && get_bson_string(len, value) && sax->string(value);
9366 }
9367
9368 case 0x03: // object
9369 {
9370 return parse_bson_internal();
9371 }
9372
9373 case 0x04: // array
9374 {
9375 return parse_bson_array();
9376 }
9377
9378 case 0x05: // binary
9379 {
9380 std::int32_t len{};
9381 binary_t value;
9382 return get_number<std::int32_t, true>(input_format_t::bson, len) && get_bson_binary(len, value) && sax->binary(value);
9383 }
9384
9385 case 0x08: // boolean
9386 {
9387 return sax->boolean(get() != 0);
9388 }
9389
9390 case 0x0A: // null
9391 {
9392 return sax->null();
9393 }
9394
9395 case 0x10: // int32
9396 {
9397 std::int32_t value{};
9398 return get_number<std::int32_t, true>(input_format_t::bson, value) && sax->number_integer(value);
9399 }
9400
9401 case 0x12: // int64
9402 {
9403 std::int64_t value{};
9404 return get_number<std::int64_t, true>(input_format_t::bson, value) && sax->number_integer(value);
9405 }
9406
9407 default: // anything else not supported (yet)

Callers

nothing calls this directly

Calls 12

getFunction · 0.85
createFunction · 0.85
concatFunction · 0.85
dataMethod · 0.80
number_floatMethod · 0.45
stringMethod · 0.45
binaryMethod · 0.45
booleanMethod · 0.45
nullMethod · 0.45
number_integerMethod · 0.45
sizeMethod · 0.45
parse_errorMethod · 0.45

Tested by

no test coverage detected