summaryrefslogtreecommitdiffstats
path: root/src/corelib/serialization/qcborstreamwriter.cpp
Commit message (Collapse)AuthorAgeFilesLines
* QCborStreamWriter: correct the QCbor{Array,Map} size limitationsThiago Macieira2023-11-241-2/+4
| | | | | | | | Increased due to qsizetype. Pick-to: 6.5 6.6 Change-Id: I85b3fc2dd45c4693be13fffd179662c8b898fb79 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Rename Convert Example to Serialization ConverterEdward Welbourne2023-10-301-1/+1
| | | | | | | | | | | | The old name didn't say what sort of thing it was converting; and our guidelines for examples discourage using the word Example in the title. Also reword the description of the tool in the command-line parser and an assertion. Pick-to: 6.6 6.5 Task-number: QTBUG-111228 Change-Id: I6f52f5227362b4b807c8aabfd2103287af42bca0 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Rename the JSON Save Game Example to Saving a Game to FileEdward Welbourne2023-10-201-1/+1
| | | | | | | | | | | Partly because it also saves to CBOR, but also because our guidelines say to avoid using "Example" in the title. Pick-to: 6.6 6.5 Task-number: QTBUG-111228 Change-Id: Id858475a6b0474228cfe8044e188cc763f56e3a8 Reviewed-by: Topi Reiniö <topi.reinio@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QCborStreamWriter: use (new) QUtf8::convertFromLatin1() to speed up ↵Marc Mutz2023-10-191-2/+6
| | | | | | | | | | | | append(QL1SV) Use the new function to convert into a QVLA instead of first converting to a QString and then to a QByteArray. One conversion and one buffer instead of two each. Pick-to: 6.6 Change-Id: Ieaa24c8ef325797b5a89e8da0ca4310667c00fa7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Docs: update links to renamed exampleVolker Hilsheimer2023-04-111-1/+2
| | | | | | | | | Amends 5c2245cd66894cc27d6d4afcf13499db6434ee2e. Pick-to: 6.5 Change-Id: I3956c0f5114bb5107c41a16c46d25c4aa82f3c53 Reviewed-by: Andreas Eliasson <andreas.eliasson@qt.io> Reviewed-by: Safiyyah Moosa <safiyyah.moosa@qt.io>
* QtCore: Fix some macro clashesFriedemann Kleint2023-01-311-0/+4
| | | | | | | | | | | | | | The macro decode() in qurlquery.cpp clashes with the static helper function decode() in qurlrecode.cpp. The macro encode() in qurlquery.cpp clashes with QStringEncoder::encode(). Macro CBOR_ENCODER_WRITER_CONTROL is defined with various values in 3rdparty/tinycbor and qcborstreamwriter.cpp. Pick-to: 6.5 Task-number: QTBUG-109394 Change-Id: I8fdf696863e5b1e6fb0c5607b2dd5b46427b9104 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Docs: adjust docs after the QLatin1String to QLatin1StringView renameAhmad Samir2023-01-051-4/+4
| | | | | | | | | | | | | Unify wording as "{Latin-1,UTF-16} string viewed by \a str". Drive-by change: Fix a grammatical error, it's "a US-ASCII", not an (because it's pronounced by the letter name "U" which is pronounced like "you", so "a" not "an"). Task-number: QTBUG-108711 Pick-to: 6.5 Change-Id: Iff763f4008341c35317bb3d7a2a228767ff6a648 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Doc: Document Qt Serialization with use casesJaishree Vyas2022-12-081-0/+1
| | | | | | | | | | | Added some background about Serialization with the classes and used cases. Fixes: QTBUG-103951 Pick-to: 6.4 6.3 6.2 Change-Id: I3ff179b814fc5d424f2ac2ffaf3237b90ddd7e2b Reviewed-by: Vladimir Minenko <vladimir.minenko@qt.io> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Kai Köhne <kai.koehne@qt.io>
* Long live Q_UNREACHABLE_RETURN()!Marc Mutz2022-10-151-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a combination of Q_UNREACHABLE() with a return statement. ATM, the return statement is unconditionally included. If we notice that some compilers warn about return after __builtin_unreachable(), then we can map Q_UNREACHABLE_RETURN(...) to Q_UNREACHABLE() without having to touch all the code that uses explicit Q_UNREACHABLE() + return. The fact that Boost has BOOST_UNREACHABLE_RETURN() indicates that there are compilers that complain about a lack of return after Q_UNREACHABLE (we know that MSVC, ICC, and GHS are among them), as well as compilers that complained about a return being present (Coverity). Take this opportunity to properly adapt to Coverity, by leaving out the return statement on this compiler. Apply the macro around the code base, using a clang-tidy transformer rule: const std::string unr = "unr", val = "val", ret = "ret"; auto makeUnreachableReturn = cat("Q_UNREACHABLE_RETURN(", ifBound(val, cat(node(val)), cat("")), ")"); auto ignoringSwitchCases = [](auto stmt) { return anyOf(stmt, switchCase(subStmt(stmt))); }; makeRule( stmt(ignoringSwitchCases(stmt(isExpandedFromMacro("Q_UNREACHABLE")).bind(unr)), nextStmt(returnStmt(optionally(hasReturnValue(expr().bind(val)))).bind(ret))), {changeTo(node(unr), cat(makeUnreachableReturn, ";")), // TODO: why is the ; lost w/o this? changeTo(node(ret), cat(""))}, cat("use ", makeUnreachableReturn)) ); where nextStmt() is copied from some upstream clang-tidy check's private implementation and subStmt() is a private matcher that gives access to SwitchCase's SubStmt. A.k.a. qt-use-unreachable-return. There were some false positives, suppressed them with NOLINTNEXTLINE. They're not really false positiives, it's just that Clang sees the world in one way and if conditonal compilation (#if) differs for other compilers, Clang doesn't know better. This is an artifact of matching two consecutive statements. I haven't figured out how to remove the empty line left by the deletion of the return statement, if it, indeed, was on a separate line, so post-processed the patch to remove all the lines matching ^\+ *$ from the diff: git commit -am meep git reset --hard HEAD^ git diff HEAD..HEAD@{1} | sed '/^\+ *$/d' | recountdiff - | patch -p1 [ChangeLog][QtCore][QtAssert] Added Q_UNREACHABLE_RETURN() macro. Change-Id: I9782939f16091c964f25b7826e1c0dbd13a71305 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add CBOR documentationØystein Heskestad2022-09-011-0/+1
| | | | | | | | | | Add documentation of usage of CBOR in convert and cbordump examples, add a CBOR overview, and add links to them other places in the documentation. Task-number: QTBUG-85912 Change-Id: I518792db63647bf9ddd4507d8d4b7ef056192f82 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-161-38/+2
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* QtCore: Replace remaining uses of QLatin1String with QLatin1StringViewSona Kurazyan2022-03-261-5/+5
| | | | | | | Task-number: QTBUG-98434 Change-Id: Ib7c5fc0aaca6ef33b93c7486e99502c555bf20bc Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Doc: Centralize RFC documentation-links in rfc.qdocLuca Di Sera2021-09-161-5/+4
| | | | | | | | | | | | | | | | | | | | In the effort of repairing broken links as per QTBUG-96127, a series of RFC links referring to `tools.ietf.org/html/*` were modified to point to the new address that the site redirected to. To simplify executing a similar task and to diminish the duplication of manually inserted urls, the already existing `rfc.qdoc` file, containing `\externalpage` commands directing to RFC locations, was enhanced with links to all RFCs that were mentioned in the current documentation, so as to aggregate this common category of links. All links pointing to a `ietf` domain inside QDoc documentation blocks were then changed to use the newly provided external-references. Task-number: QTBUG-96127 Pick-to: 6.2 Change-Id: I2a52eb6aa8c9e346f64ef1a627b039220d9f6c2a Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Replace Q_DECL_UNUSED with [[maybe_unused]]Allan Sandfeld Jensen2020-10-031-2/+2
| | | | | | | Use C++17 attribute directly Change-Id: Id853e7a5117065e4adb549f81303c1820fe198ce Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use C++17 [[maybe_unused]]Allan Sandfeld Jensen2020-09-061-2/+2
| | | | | | | In some places needs to be ordered before const/constexpr though. Change-Id: I57a521ac0ad22b5a018761c4d52befbef69d64c0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Replace Qt CONSTEXPR defines with constexprAllan Sandfeld Jensen2020-08-141-1/+1
| | | | | | | | Both normal and relaxed constexpr are required by our new minimum of C++17. Change-Id: Ic028b88a2e7a6cb7d5925f3133b9d54859a81744 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Use QList instead of QVector in corelib docsJarek Kobus2020-06-291-2/+2
| | | | | | | Task-number: QTBUG-84469 Task-number: QTBUG-85221 Change-Id: Ieb0ba7d82409e3c053a5788a01e92ea495505643 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Port Q_STATIC_ASSERT(_X) to static_assertGiuseppe D'Angelo2020-06-191-1/+1
| | | | | | | | | | | | | | | | | There is no reason for keep using our macro now that we have C++17. The macro itself is left in for the moment being, as well as its detection logic, because it's needed for C code (not everything supports C11 yet). A few more cleanups will arrive in the next few patches. Note that this is a mere search/replace; some places were using double braces to work around the presence of commas in a macro, no attempt has been done to fix those. tst_qglobal had just some minor changes to keep testing the macro. Change-Id: I1c1c397d9f3e63db3338842bf350c9069ea57639 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Remove QLinkedListSona Kurazyan2020-02-191-2/+2
| | | | | | | | | | | | | QLinkedList has been moved to Qt5Compat. Remove and stop mentioning it in docs, examples (the docs & examples for QLinkedList itself will be moved to Qt5Compat) and remove the corresponding tests. Also remove QT_NO_LINKED_LIST, since it's not needed anymore. Task-number: QTBUG-81630 Task-number: QTBUG-80312 Change-Id: I4a8f1105cb60aa87e7fd67e901ec1a27c489aa31 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* cborstreamwriter: Fix developer-build with clangRobert Loehning2019-12-301-2/+2
| | | | | | | Both functions are unused which results in a build error. Change-Id: If7e7a47cd62b91fbfc5bbf5330825bbb341a734b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Split cborstream feature in twoUlf Hermann2019-12-121-0/+868
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>