[Interest] CBOR Questions

Jason H jhihn at gmx.com
Tue Mar 5 17:15:40 CET 2019

I am looking at adapting some code to move from JSON/packed data to CBOR. However the first question I have is how do I know when a CBOR object is done?  If I have multiple or partial CBOR objects in a QByteArray how do I handle that? What if it's coming in through a QIODevice? With JSON I could just look for a } of the same stack level (0) and know the object was done.  How is this handled in Qt/CBOR?

Fundamentally I am sending 256-1024 byte objects around which correspond to a QVariantMap, so ideally I would like to do:
QCborMap map = QCborValue::fromDevice(socket).toMap();
if (map.size()==0) { /* partial or no object read, retry on next ReadyRead */ }
QCborMap map = QCborValue::fromByteArray(socket, &byteArray).toMap(); /* modifies bytearray on successful decode to start at next object */

I am not using indeterminate length objects.

Many thanks.

More information about the Interest mailing list