xref: /freebsd-src/contrib/libcbor/doc/source/api/streaming_decoding.rst (revision 5d3e7166f6a0187fa3f8831b16a06bd9955c21ff)
1*5d3e7166SEd MasteStreaming Decoding
2*5d3e7166SEd Maste=============================
3*5d3e7166SEd Maste
4*5d3e7166SEd Maste*libcbor* exposes a stateless decoder that reads a stream of input bytes from a buffer and invokes user-provided callbacks as it decodes the input:
5*5d3e7166SEd Maste
6*5d3e7166SEd Maste.. doxygenfunction:: cbor_stream_decode
7*5d3e7166SEd Maste
8*5d3e7166SEd MasteFor example, when :func:`cbor_stream_decode` encounters a 1B unsigned integer, it will invoke the function pointer stored in ``cbor_callbacks.uint8``.
9*5d3e7166SEd MasteComplete usage example: `examples/streaming_parser.c <https://github.com/PJK/libcbor/blob/master/examples/streaming_parser.c>`_
10*5d3e7166SEd Maste
11*5d3e7166SEd MasteThe callbacks are defined by
12*5d3e7166SEd Maste
13*5d3e7166SEd Maste.. doxygenstruct:: cbor_callbacks
14*5d3e7166SEd Maste    :members:
15*5d3e7166SEd Maste
16*5d3e7166SEd MasteWhen building custom sets of callbacks, feel free to start from
17*5d3e7166SEd Maste
18*5d3e7166SEd Maste.. doxygenvariable:: cbor_empty_callbacks
19*5d3e7166SEd Maste
20*5d3e7166SEd Maste
21*5d3e7166SEd MasteCallback types definition
22*5d3e7166SEd Maste~~~~~~~~~~~~~~~~~~~~~~~~~~~~
23*5d3e7166SEd Maste
24*5d3e7166SEd Maste
25*5d3e7166SEd Maste.. doxygentypedef:: cbor_int8_callback
26*5d3e7166SEd Maste.. doxygentypedef:: cbor_int16_callback
27*5d3e7166SEd Maste.. doxygentypedef:: cbor_int32_callback
28*5d3e7166SEd Maste.. doxygentypedef:: cbor_int64_callback
29*5d3e7166SEd Maste.. doxygentypedef:: cbor_simple_callback
30*5d3e7166SEd Maste.. doxygentypedef:: cbor_string_callback
31*5d3e7166SEd Maste.. doxygentypedef:: cbor_collection_callback
32*5d3e7166SEd Maste.. doxygentypedef:: cbor_float_callback
33*5d3e7166SEd Maste.. doxygentypedef:: cbor_double_callback
34*5d3e7166SEd Maste.. doxygentypedef:: cbor_bool_callback
35