[Interest] Can't understand how to use QCborStreamReader/QCborStreamWriter
Alexander Dyagilev
alervdvcw at gmail.com
Fri May 20 05:36:39 CEST 2022
Oh, OK, I should write them inside of array (i.e. use
QCborStreamWriter::startArray). Sorry... xD
On 5/20/2022 6:28 AM, Alexander Dyagilev wrote:
>
> 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/893cf6a8/attachment.htm>
More information about the Interest
mailing list