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

Function usingValues

test/snippets.cpp:354–473  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

352//----------------------------------------------------------
353
354void
355usingValues()
356{
357 {
358 // tag::snippet_value_1[]
359
360 value jv1;
361 value jv2( nullptr );
362
363 assert( jv1.is_null() );
364 assert( jv2.is_null() );
365
366 // end::snippet_value_1[]
367 }
368 {
369 // tag::snippet_value_2[]
370
371 value jv( object_kind );
372
373 assert( jv.kind() == kind::object );
374 assert( jv.is_object() );
375 assert( ! jv.is_number() );
376
377 // end::snippet_value_2[]
378 }
379 {
380 auto f = []{
381 // tag::snippet_value_3[]
382
383 value jv( object_kind );
384
385 if( auto p = jv.if_object() )
386 return p->size();
387
388 // end::snippet_value_3[]
389 return std::size_t(0);
390 };
391 (void)f;
392 }
393 {
394 // tag::snippet_value_4[]
395
396 value jv;
397 jv = value( array_kind );
398
399 assert( jv.is_array() );
400
401 jv.emplace_string();
402
403 assert( jv.is_string() );
404
405 // end::snippet_value_4[]
406 }
407 {
408 // tag::snippet_value_5[]
409
410 value jv;
411 jv.emplace_string() = "Hello, world!";

Callers 1

runMethod · 0.85

Calls 13

size_tClass · 0.85
is_nullMethod · 0.80
kindMethod · 0.80
is_objectMethod · 0.80
is_numberMethod · 0.80
if_objectMethod · 0.80
is_arrayMethod · 0.80
is_stringMethod · 0.80
is_int64Method · 0.80
if_stringMethod · 0.80
valueMethod · 0.80
valueClass · 0.70

Tested by

no test coverage detected