[Interest] CBOR Questions

Thiago Macieira thiago.macieira at intel.com
Wed Mar 6 05:42:15 CET 2019


On Tuesday, 5 March 2019 11:09:52 PST Jason H wrote:
> It seems the simplest, most reliable way to implement complete reads is to
> serialize the QByteArray data in a QDataStream. Unfortunately it looks like
> CBOR types do not have QDataStream support? If I were to request anything
> in terms of new API that would probably be it.

The simplest is to use the QCborValue::fromCbor overload that takes a 
QByteArray (your buffer) and QCborParserError. Every time you receive data, 
you try to parse and then you check the error
 - if it's QCborError::EndOfFile, wait for more data
 - if it's QCborError::NoError, remove "offset" bytes from the beginning of 
   the buffer and process the loaded map
 - if it's anything else, give up

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel System Software Products






More information about the Interest mailing list