|
SatCat5
|
CBOR (IETF RFC8949) Readable/Writeable interface.
This file provides an API for reading and writing messages encoded using the Concise Binary Object Representation (CBOR), defined in IETF RFC8949. The API is backed by calls to the QCBOR library.
When decoding a CBOR message, the most commonly-used classes are cbor::ListReaderStatic (if the top-level is a list or array) and cbor::MapReaderStatic (if the top-level is a key/value dictionary). Given a data source, these automatically create the required QCBOR objects and working buffer. For lists, items are read sequentially. For key/value maps, items are requested by key. Templates indicate whether the keys integers (s64) or strings (const char*).
When encoding a CBOR message, the most commonly-used clases are cbor::ListWriterStatic and cbor::MapWriterStatic.
When reading or writing complex CBOR messages with nested data structures (e.g., a dictionary containing a list of sub-dictionaries), use the open_list or open_map methods to access the inner QCBOR object. Then, create a cbor::ListReader, cbor::MapReader, cbor::ListWriter, or cbor::MapWriter to continue parsing the inner list or map. Finally, call close_list or close_map to resume parsing of the outer message. These objects do not use the "static" classes because they share the same working buffer, so no additional allocation is required.
Definition in file io_cbor.h.
#include <satcat5/io_readable.h>#include <satcat5/io_writeable.h>#include <satcat5/utils.h>#include <qcbor/qcbor_encode.h>#include <qcbor/qcbor_spiffy_decode.h>Go to the source code of this file.
Classes | |
| class | satcat5::cbor::CborWriter |
| Creates an ephemeral writer for the Concise Binary Object Representation (CBOR, IETF RFC8949), holding underlying objects and adapting output to an io::Writeable destination. More... | |
| class | satcat5::cbor::ListWriter |
| Write a series of consecutive items to a CBOR message. More... | |
| class | satcat5::cbor::MapWriter< KEYTYPE > |
| Write a series of key-value pairs to a CBOR Map. More... | |
| class | satcat5::cbor::ListWriterStatic< SIZE > |
| ListWriter variant with a statically-allocated buffer. More... | |
| class | satcat5::cbor::MapWriterStatic< KEYTYPE, SIZE > |
| MapWriter variant with a statically-allocated buffer. More... | |
| class | satcat5::cbor::CborReader |
| Creates an ephemeral reader for the Concise Binary Object Representation (CBOR, IETF RFC8949), holding underlying objects and providing more concise member functions. More... | |
| class | satcat5::cbor::ListReader |
| Read consecutive values from a CBOR Array/List. More... | |
| class | satcat5::cbor::MapReader< KEYTYPE > |
| Reads a series of key-value pairs from a CBOR Map. More... | |
| class | satcat5::cbor::ListReaderStatic< SIZE > |
| ListReader variant with a statically-allocated buffer. More... | |
| class | satcat5::cbor::MapReaderStatic< KEYTYPE, SIZE > |
| MapReader variant with a statically-allocated buffer. More... | |
| struct | satcat5::cbor::Logger |
| Helper object for logging contents a QCBOR item. More... | |
Macros | |
| #define | SATCAT5_QCBOR_BUFFER 1500 |
| Set the default size for the QCBOR buffer. | |
Typedefs | |
| typedef satcat5::cbor::ListReader | satcat5::io::CborListReader |
| Legacy alias for backwards compatibility. More... | |
| typedef satcat5::cbor::ListWriter | satcat5::io::CborListWriter |
| Legacy alias for backwards compatibility. More... | |
| typedef satcat5::cbor::Logger | satcat5::io::CborLogger |
| Legacy alias for backwards compatibility. More... | |
| template<unsigned SIZE = SATCAT5_QCBOR_BUFFER> | |
| using | satcat5::io::CborListReaderStatic = satcat5::cbor::ListReaderStatic< SIZE > |
| Legacy alias for backwards compatibility. More... | |
| template<unsigned SIZE = SATCAT5_QCBOR_BUFFER> | |
| using | satcat5::io::CborListWriterStatic = satcat5::cbor::ListWriterStatic< SIZE > |
| Legacy alias for backwards compatibility. More... | |
| template<typename KEYTYPE = const char*> | |
| using | satcat5::io::CborMapReader = satcat5::cbor::MapReader< KEYTYPE > |
| Legacy alias for backwards compatibility. More... | |
| template<typename KEYTYPE = const char*> | |
| using | satcat5::io::CborMapWriter = satcat5::cbor::MapReader< KEYTYPE > |
| Legacy alias for backwards compatibility. More... | |
| template<typename KEYTYPE = const char*, unsigned SIZE = SATCAT5_QCBOR_BUFFER> | |
| using | satcat5::io::CborMapReaderStatic = satcat5::cbor::MapReaderStatic< KEYTYPE, SIZE > |
| Legacy alias for backwards compatibility. More... | |
| template<typename KEYTYPE = const char*, unsigned SIZE = SATCAT5_QCBOR_BUFFER> | |
| using | satcat5::io::CborMapWriterStatic = satcat5::cbor::MapWriterStatic< KEYTYPE, SIZE > |
| Legacy alias for backwards compatibility. More... | |
| using satcat5::io::CborListReaderStatic = typedef satcat5::cbor::ListReaderStatic<SIZE> |
| using satcat5::io::CborListWriterStatic = typedef satcat5::cbor::ListWriterStatic<SIZE> |
| using satcat5::io::CborMapReader = typedef satcat5::cbor::MapReader<KEYTYPE> |
| using satcat5::io::CborMapReaderStatic = typedef satcat5::cbor::MapReaderStatic<KEYTYPE, SIZE> |
| using satcat5::io::CborMapWriter = typedef satcat5::cbor::MapReader<KEYTYPE> |
| using satcat5::io::CborMapWriterStatic = typedef satcat5::cbor::MapWriterStatic<KEYTYPE, SIZE> |