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

Function main

example/cbor.cpp:444–471  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

442}
443
444int
445main(int argc, const char** argv)
446{
447 if( argc != 2 )
448 {
449 std::cerr << "Usage: cbor FILE_NAME\n";
450 return EXIT_FAILURE;
451 }
452
453 std::ifstream is(argv[1]);
454 is.exceptions(std::ios::badbit);
455
456 const value jv = parse(is);
457
458 std::vector<unsigned char> out;
459 serialize_cbor_value( jv, out );
460
461 value jv2;
462 parse_cbor_value( out.data(), out.data() + out.size(), jv2 );
463
464 if( jv != jv2 )
465 {
466 std::cerr << "Roundtrip check failed\n";
467 return EXIT_FAILURE;
468 }
469
470 return EXIT_SUCCESS;
471}
472
473// end::example_cbor[]

Callers

nothing calls this directly

Calls 4

serialize_cbor_valueFunction · 0.85
parse_cbor_valueFunction · 0.85
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected