MCPcopy Create free account
hub / github.com/danielaparker/jsoncons / working_with_cbor4

Function working_with_cbor4

examples/src/cbor_examples.cpp:484–508  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

482}
483
484void working_with_cbor4()
485{
486 auto filter = [&](const staj_event& ev, const ser_context&) -> bool
487 {
488 return (ev.tag() == semantic_tag::bigdec) || (ev.tag() == semantic_tag::bigfloat);
489 };
490
491 cbor::cbor_bytes_cursor cursor(data);
492
493 auto filtered_c = cursor | filter;
494 for (; !filtered_c.done(); filtered_c.next())
495 {
496 const auto& event = filtered_c.current();
497 switch (event.event_type())
498 {
499 case staj_event_type::string_value:
500 // Or std::string_view, if supported
501 std::cout << event.event_type() << ": " << event.get<jsoncons::string_view>() << " " << "(" << event.tag() << ")\n";
502 break;
503 default:
504 std::cout << "Unhandled event type " << event.event_type() << " " << "(" << event.tag() << ")\n";
505 break;
506 }
507 }
508}
509
510void ext_type_example()
511{

Callers 1

mainFunction · 0.85

Calls 5

currentMethod · 0.80
event_typeMethod · 0.80
tagMethod · 0.45
doneMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected