MCPcopy Create free account
hub / github.com/boostorg/json / parse_cbor_object

Function parse_cbor_object

example/cbor.cpp:291–326  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

289}
290
291const unsigned char*
292parse_cbor_object(
293 const unsigned char* first, const unsigned char* last, unsigned char ch, value& v )
294{
295 std::uint64_t n;
296 first = parse_cbor_number( first, last, ch, n );
297
298 object & o = v.emplace_object();
299
300 o.reserve( n );
301
302 for( std::size_t i = 0; i < n; ++i )
303 {
304 // key string
305
306 ensure( 1, first, last );
307 unsigned char ch2 = *first++;
308
309 if( ( ch2 >> 5 ) != 3 )
310 throw_format_error( "Object keys must be strings" );
311
312 std::uint64_t m;
313 first = parse_cbor_number( first, last, ch2, m );
314
315 ensure( m, first, last );
316
317 string_view sv( reinterpret_cast<char const*>( first ), m );
318 first += m;
319
320 // value
321
322 first = parse_cbor_value( first, last, o[ sv ] );
323 }
324
325 return first;
326}
327
328const unsigned char*
329parse_cbor_unsigned(

Callers 1

parse_cbor_valueFunction · 0.85

Calls 5

parse_cbor_numberFunction · 0.85
ensureFunction · 0.85
throw_format_errorFunction · 0.85
parse_cbor_valueFunction · 0.85
reserveMethod · 0.45

Tested by

no test coverage detected