summaryrefslogtreecommitdiffstats
path: root/src/corelib/serialization/qcborstream.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Split cborstream feature in twoUlf Hermann2019-12-121-2649/+0
| | | | | | | | | | | | | | | | | | | | | Reading of Cbor streams is substantially more complicated than writing as it requires float16 support. When writing Cbor, we can just choose to always write 32bit floats, even if we could compress the numbers into 16 bits. We need Cbor writing in the bootstrap library, but we cannot easily add float16 support. Furthermore, Cbor reading is required for plugin support, but not Cbor writing. It might make sense for some users to build a custom Qt with Cbor writing disabled. Therefore, provide two features, cborstreamreader and cborstreamwriter, split up the code in cborstream.{h|cpp} into several files, and enable Cbor writing in the bootstrap library. Change-Id: I15450afb0e328a84a22ebca9379cffc4f900a75a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Move CBOR debug stream functions into qcborvalue.cppUlf Hermann2019-10-171-112/+0
| | | | | | | | Some of them were already there, and this way they continue to function, even if the cborstream feature is turned off. Change-Id: I6828d2f525ab0a1437fc940a0fe786f6fa56fd6a Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Merge remote-tracking branch 'origin/5.12' into 5.13Qt Forward Merge Bot2019-07-201-1/+9
|\ | | | | | | Change-Id: Ic34021fbb87d689ee23a5d1b3f50617ada9ec9b9
| * Fix QCborStreamReader not flushing QIODevices due to internal bufferingThiago Macieira2019-07-191-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When successfully finishing a parse, it's reasonable to expect that the QIODevice was advanced to the end of the input data. [ChangeLog][QtCore][QCborStreamReader] Fixed a bug that caused the QIODevice that the data was being read from not to show the entire CBOR message as consumed. This allows the user to consume data that may follow the CBOR payload. Fixes: QTBUG-77076 Change-Id: I1024ee42da0c4323953afffd15b23f5d8fcc6f50 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: BogDan Vatra <bogdan@kdab.com>
* | Merge remote-tracking branch 'origin/5.12' into 5.13Qt Forward Merge Bot2019-04-281-0/+1
|\| | | | | | | Change-Id: Ibce9bfef928ce39070183c488ce86ae32e5ea705
| * qdoc: Fix warnings about missing \inmodule commandKai Koehne2019-04-261-0/+1
| | | | | | | | | | | | | | | | | | | | Fix warnings qtbase/src/corelib/io/qprocess.cpp:776: (qdoc) warning: Class CreateProcessArguments has no \inmodule command; using project name by default: QtCore qtbase/src/corelib/serialization/qcborstream.cpp:1441: (qdoc) warning: Class StringResult has no \inmodule command; using project name by default: QtCore Change-Id: I1c85ca32aff1f89f70898af7b11cfead96c80349 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
* | Merge remote-tracking branch 'origin/5.12' into 5.13Qt Forward Merge Bot2019-04-101-0/+10
|\| | | | | | | Change-Id: I44eda44bf424fdcffab048a2534905d6162e5559
| * Update TinyCBOR with bugfixesThiago Macieira2019-04-081-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Updated to https://github.com/thiagomacieira/tinycbor commit ac9369d8ec8511bc7516266ae6b07f7da860c954. Fabrice Fontaine (1): fix undefined encode_half in json2cbor Pedro Oliveira (1): Fixed minor error in the example code. Svyatoslav Phirsov (2): Typo fixed in stdlib fread(...) usage typo in dumprecursive return type Thiago Macieira (9): Install the tinycbor-version.h header. Update version number for a possible but unlikely 0.5.3 release Fix #137: off-by-one error in UTF-8 decoding Update Travis CI to Ubuntu Xenial Pretty: fix use of uninitialised variable Validation: fix out-of-bounds access when content ends in a string Parser: apply the same memory-check update Tests: remove useless comment Tests: Catch an earlier QCOMPARE failure in compare() phirsov (6): Fix off-by-one causing buffer overflow in open_memstream Protect macro argument expansion using parentheses eliminating misleading messages in case .config file not yet created Run check silently in Travis Make AppVeyor test suit run silent as in Travis enhancement #149 implemented: access half-precision floating point data as single float Change-Id: I9e3d261ad9bf41cfb2b6fffd159088f1cc9b3b02 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* | Merge remote-tracking branch 'origin/5.12' into 5.13Qt Forward Merge Bot2019-03-151-5/+22
|\| | | | | | | Change-Id: I2bf3b4ceb79364330eae4cbf3cdee9a82d1be46d
| * Doc: "UTF" -> "UTF-8"Thiago Macieira2019-03-141-1/+1
| | | | | | | | | | Change-Id: Ifbadc62ac2d04a9a8952fffd158a5a9ba87c30e0 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
| * Add a pair of functions to convert to and from Q/CborErrorThiago Macieira2019-03-141-4/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We've so far made our public API match the TinyCBOR error codes, so the conversion is trivial. Having the two functions allows us to change that, if it becomes necessary. It also effectively concentrates the Coverity warning about mixed enums in a single pair of functions. >>> CID 190307: Incorrect expression (MIXED_ENUMS) >>> Mixing enum types "CborError" and "QCborError::Code" for "err". Change-Id: Ifbadc62ac2d04a9a8952fffd1589e739c7a5b745 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* | Merge remote-tracking branch 'origin/5.12' into 5.13Qt Forward Merge Bot2019-03-111-1/+1
|\| | | | | | | Change-Id: Iecdf00ca61d819bde532daa42f093860ec4a499e
| * Fix Coverity warning about mixing enumsThiago Macieira2019-03-091-1/+1
| | | | | | | | | | | | | | | | | | | | Coverity says: >>> CID 190310: Incorrect expression (MIXED_ENUMS) >>> Mixing enum types "CborType" and "QCborStreamReader::Type" for "type_". Change-Id: Ifbadc62ac2d04a9a8952fffd1589e6e304fc7703 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* | Merge remote-tracking branch 'origin/5.12' into devLiang Qi2018-11-221-2/+4
|\| | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/io/qdir.cpp src/corelib/kernel/qtimer.cpp src/corelib/kernel/qtimer.h Done-With: Edward Welbourne <edward.welbourne@qt.io> Change-Id: I683d897760ec06593136d77955f8bc87fdef3f9f
| * Merge remote-tracking branch 'origin/5.12.0' into 5.12Liang Qi2018-11-161-2/+4
| |\ | | | | | | | | | Change-Id: Ic1dd39044e19f50e1068d4ac70dacaad6440e570
| | * Doc: QCbor classes: Fix \variable commandsTopi Reinio2018-11-061-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | \variable must not include the variable type, QDoc will resolve that. This commit resolves four documentation warnings. Task-number: QTBUG-71502 Change-Id: I5e88cf66d3c3bb8f18495d5477e1271ac2cd9e74 Reviewed-by: Martin Smith <martin.smith@qt.io>
* | | Merge remote-tracking branch 'origin/5.12' into devLiang Qi2018-11-101-0/+2
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/serialization/qcborcommon.h src/corelib/tools/qlocale_data_p.h tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp Done-with: Edward Welbourne <edward.welbourne@qt.io> Change-Id: Ibed987f6d77a0294f78f67d78625237616082416
| * | QCborStreamReader: make sure setDevice() clears the last errorThiago Macieira2018-11-081-0/+2
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | The unit tests weren't running into this problem because the every setDevice() was preceded by the object being initialized with the exact same data, so there was never a previous error state. I've only changed a couple of tests, left the other setDevice() unchanged so we test both behaviors. Fixes: QTBUG-71426 Change-Id: I1bd327aeaf73421a8ec5fffd1561a590e3933376 Reviewed-by: Nils Jeisecke <nils.jeisecke@saltation.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* | Merge remote-tracking branch 'origin/5.12' into devLiang Qi2018-10-251-279/+30
|\| | | | | | | | | | | | | | | | | Conflicts: src/corelib/animation/qpropertyanimation.cpp src/gui/image/qicon.cpp tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp Change-Id: I3698172b7b44ebb487cb38f50fd2c4a9f8a35b21
| * Doc: Move literal code block to a separate fileCristian Maureira-Fredes2018-10-151-279/+30
| | | | | | | | | | | | | | | | | | | | | | We need to override this snippet for the documentation we generate for Qt for Python, and it is easier to have it on a separate file. Task-number: PYSIDE-801 Task-number: PYSIDE-691 Change-Id: Ideb5b6af25024279f167137d3b65660bb9c96a7e Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* | Implement QDataStream operator for QCborSimpleValueJędrzej Nowacki2018-10-031-0/+16
|/ | | | | | | That allows us to remove custom handling in QMetaType. Change-Id: Ic09fb96e1a05c6897803811d70aebbc6ea6e4f2e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* qdoc: Fix remaining qdoc warnings for QCborxxx classesMartin Smith2018-08-171-2/+2
| | | | | | | | | | Several \fn commands are added for functions and operators that were not documented. A few qdoc warnings remain in qcborstream.cpp, but these are because an enum class was used, and qdoc doesn't yet handle those correctly all the time. Change-Id: I02a740c595e36c1b383af242c2a6419d1f37b135 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Update TinyCBOR to 1b233087a6e6b6be297e69bfcce5ed36f338c91dThiago Macieira2018-07-181-22/+5
| | | | | | | | From the fork at https://github.com/thiagomacieira/tinycbor Change-Id: I117816bf0f5e469b8d34fffd153dc88683051208 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* CBOR: Use "noexcept" directlyThiago Macieira2018-07-141-3/+3
| | | | | | | | | | | All supported compilers support it. Doing this just for the new API. We should do it throughout Qt, but only if it won't interfere with the header review. Change-Id: Id59bdd8f1a804b809e22fffd153f9254688e5152 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* CBOR: Add QDebug operators for the Qt CBOR value-like typesThiago Macieira2018-07-041-0/+113
| | | | | | | | | | I added a function that returns the string identifiers for QCborKnownTags and QCborSimpleType, in order to facilitate writing a QTest::toString for those types, as neither enum is part of a Q_OBJECT or Q_GADGET class. Change-Id: I56b444f9d6274221a3b7fffd150d2d26a1925c19 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QCborStreamReader: Fix uninitialized warningLiang Qi2018-06-181-1/+1
| | | | | | | | | | | serialization/qcborstream.cpp: In member function 'QCborStreamReader::StringResult<int> QCborStreamReader::readStringChunk(char*, qsizetype)': serialization/qcborstream.cpp:2845:62: error: 'content' may be used uninitialized in this function [-Werror=maybe-uninitialized] memcpy(ptr, d->buffer.constData() + d->bufferStart + offset, toRead); ^ Task-number: QTBUG-68889 Change-Id: Ieea05672f2fdd7685c2af0e0aa7fa8b281d25618 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QCborStreamReader: update to the new TinyCBOR zero-copy string APIThiago Macieira2018-06-061-45/+64
| | | | | Change-Id: Iab119b62106d40fb8499fffd1510abe5d8f2722a Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QCborStreamReader: use QByteArray directly if possibleThiago Macieira2018-06-061-62/+122
| | | | | | | | | | | | | | | QIODevice represents considreable overhead, even with just QBuffer, for parsing simple things. Benchmarking showed it was spending 25% of the parsing time inside one QIODevice function or another. So this commit accomplishes two things: 1) it increases the buffer size from 9 bytes to up to 256, which should reduce the number of calls into the QIODevice 2) if the source data is a QByteArray, then use it directly and bypass the QIODevice, thus increasing performance considerably Change-Id: I56b444f9d6274221a3b7fffd150c531c9d28e54b Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QCborStreamReader: rewrite read{String,ByteArray}()Thiago Macieira2018-05-301-39/+14
| | | | | | | | | This rewrites _readString_helper() in terms of _readByteArray_helper() (the helper version doesn't do type-checking) and rewrites _readByteArray_helper() in terms of readStringChunk(). Change-Id: Iab119b62106d40fb8499fffd1510aa404d9f3611 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QCborStreamReader: remove the documentation on the validation APIThiago Macieira2018-05-291-7/+0
| | | | | | | It's not present in this version. Change-Id: I6a540578e810472bb455fffd1532ac4d49d4b994 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Long live QCborStreamReader!Thiago Macieira2018-05-271-13/+1574
| | | | | | | | | | This is the counterpart of the previous commit. [ChangeLog][QtCore] Added QCborStreamReader and QCborStreamWriter, classes for low-level reading and writing of CBOR streams. Change-Id: Ia0aac2f09e9245339951ffff13c72e4bffdf4a56 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Long live QCborStreamWriter!Thiago Macieira2018-05-271-0/+1250
CBOR is the Concise Binary Object Representation, a very compact form of binary data encoding that is compatible with JSON. It was created by the IETF Constrained RESTful Environments (CoRE) WG[1] and has since been used in many new RFCs by that group, especially COSE[2], and is meant to be used alongside CoAP[3]. This API is a very simple, thin wrapper around TinyCBOR[4]. See RFC 7049 <http://tools.ietf.org/html/rfc7049>. [1] https://datatracker.ietf.org/wg/core/charter/ [2] https://tools.ietf.org/html/rfc8152 [3] https://tools.ietf.org/html/rfc7252 [4] https://github.com/intel/tinycbor Change-Id: Ia0aac2f09e9245339951ffff13c651cfeab77d3b Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>