MCPcopy Create free account
hub / github.com/GDRETools/gdsdecomp / get_cbor_string

Method get_cbor_string

external/tinygltf/json.hpp:9283–9365  ·  view source on GitHub ↗

! @brief reads a CBOR string This function first reads starting bytes to determine the expected string length and then copies this number of bytes into a string. Additionally, CBOR's strings with indefinite lengths are supported. @param[out] result created string @return whether string creation completed */

Source from the content-addressed store, hash-verified

9281 @return whether string creation completed
9282 */
9283 bool get_cbor_string(string_t& result)
9284 {
9285 if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::cbor, "string")))
9286 {
9287 return false;
9288 }
9289
9290 switch (current)
9291 {
9292 // UTF-8 string (0x00..0x17 bytes follow)
9293 case 0x60:
9294 case 0x61:
9295 case 0x62:
9296 case 0x63:
9297 case 0x64:
9298 case 0x65:
9299 case 0x66:
9300 case 0x67:
9301 case 0x68:
9302 case 0x69:
9303 case 0x6A:
9304 case 0x6B:
9305 case 0x6C:
9306 case 0x6D:
9307 case 0x6E:
9308 case 0x6F:
9309 case 0x70:
9310 case 0x71:
9311 case 0x72:
9312 case 0x73:
9313 case 0x74:
9314 case 0x75:
9315 case 0x76:
9316 case 0x77:
9317 {
9318 return get_string(input_format_t::cbor, static_cast<unsigned int>(current) & 0x1Fu, result);
9319 }
9320
9321 case 0x78: // UTF-8 string (one-byte uint8_t for n follows)
9322 {
9323 std::uint8_t len{};
9324 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
9325 }
9326
9327 case 0x79: // UTF-8 string (two-byte uint16_t for n follow)
9328 {
9329 std::uint16_t len{};
9330 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
9331 }
9332
9333 case 0x7A: // UTF-8 string (four-byte uint32_t for n follow)
9334 {
9335 std::uint32_t len{};
9336 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
9337 }
9338
9339 case 0x7B: // UTF-8 string (eight-byte uint64_t for n follow)
9340 {

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected