[Interest] Can't understand how to use QCborStreamReader/QCborStreamWriter

Alexander Dyagilev alervdvcw at gmail.com
Fri May 20 05:28:11 CEST 2022


Hello,

I'm trying to write and read 2 byte arrays. Getting assertion failure 
when reading second array.

Write:

QByteArrayba;

QCborStreamWriterw(&ba);

QByteArraya1(10,'A');

QByteArraya2(10,'B');

w.append(a1);

w.append(a2);

Read:

QByteArrayreadByteArray(QCborStreamReader&cbor)
{

Q_ASSERT(cbor.hasNext());//gettingassertionfailureherewhenreading|aa2|

Q_ASSERT(cbor.isByteArray());

QByteArrayresult;

for(;;)

{

autor=cbor.readByteArray();

Q_ASSERT(r.status!=QCborStreamReader::Error);

result+=r.data;

if(r.status==QCborStreamReader::EndOfString)

returnresult;

}

}

QCborStreamReaderr(ba);

autoaa1=readByteArray(r);
autoaa2=readByteArray(r);


What am I doing wrong?..
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20220520/f85f4065/attachment.htm>


More information about the Interest mailing list