MCPcopy Create free account
hub / github.com/BayshoreNetworks/yextend / get_cbor_string

Method get_cbor_string

libs/json.hpp:5296–5369  ·  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. @return string @throw parse_error.110 if input ended @throw parse_error.113 if an unexpected byte is read */

Source from the content-addressed store, hash-verified

5294 @throw parse_error.113 if an unexpected byte is read
5295 */
5296 std::string get_cbor_string()
5297 {
5298 check_eof();
5299
5300 switch (current)
5301 {
5302 // UTF-8 string (0x00..0x17 bytes follow)
5303 case 0x60:
5304 case 0x61:
5305 case 0x62:
5306 case 0x63:
5307 case 0x64:
5308 case 0x65:
5309 case 0x66:
5310 case 0x67:
5311 case 0x68:
5312 case 0x69:
5313 case 0x6a:
5314 case 0x6b:
5315 case 0x6c:
5316 case 0x6d:
5317 case 0x6e:
5318 case 0x6f:
5319 case 0x70:
5320 case 0x71:
5321 case 0x72:
5322 case 0x73:
5323 case 0x74:
5324 case 0x75:
5325 case 0x76:
5326 case 0x77:
5327 {
5328 return j_get_string(current & 0x1f);
5329 }
5330
5331 case 0x78: // UTF-8 string (one-byte uint8_t for n follows)
5332 {
5333 return j_get_string(get_number<uint8_t>());
5334 }
5335
5336 case 0x79: // UTF-8 string (two-byte uint16_t for n follow)
5337 {
5338 return j_get_string(get_number<uint16_t>());
5339 }
5340
5341 case 0x7a: // UTF-8 string (four-byte uint32_t for n follow)
5342 {
5343 return j_get_string(get_number<uint32_t>());
5344 }
5345
5346 case 0x7b: // UTF-8 string (eight-byte uint64_t for n follow)
5347 {
5348 return j_get_string(get_number<uint64_t>());
5349 }
5350
5351 case 0x7f: // UTF-8 string (indefinite length)
5352 {
5353 std::string result;

Callers

nothing calls this directly

Calls 2

getFunction · 0.85
createFunction · 0.85

Tested by

no test coverage detected