summaryrefslogtreecommitdiffstats
path: root/src/corelib/serialization/qcborarray.h
Commit message (Collapse)AuthorAgeFilesLines
* Fully support operator[] on QCborValue and QCborValueRefEdward Welbourne2018-11-011-0/+1
| | | | | | | | | | | Added operator[] to QCborValueRef and mutating operator[] both there and in QCborValue. If the value (referenced) is not a container, it is replaced with a map and a reference into the result is returned. If the value is an array and the key is a string, negative, or more than 0xffff, the array is first converted to a map. Change-Id: Ibbc9e480fb25eb3d05547c8a1b99e762b2a68b68 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Merge remote-tracking branch 'origin/5.12' into devQt Forward Merge Bot2018-10-091-2/+7
|\ | | | | | | Change-Id: I5cbfd39cf728036bbdfdeec8e8739568e0a3025b
| * Support QCborMap::operator[] taking a string literalEdward Welbourne2018-10-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use a template on the size of the char[], as suggested by Ville Voutilainen. This resolves ambiguity about whether such look-ups should be done via QString or QCborValue (not that it would have made any difference). When we come to add mutating indexing of QCborValue, chained dereferences like map[i][j][k] need to stay in operator[] const throughout, to avoid detaching intermediates to create references into them due to using the mutating operator[] on the earlier dereference's return. So const-qualify the QCborValue operator[] const variants at the same time, to match those of QCborValue itself. Change-Id: Ib1652ae9440fe3767a653afa2856b74040210e07 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| * Change QCborArray to pad with invalid on inserting past endEdward Welbourne2018-10-081-1/+6
| | | | | | | | | | | | | | | | | | Likewise have mutating operator[] insert an invalid entry at its target index, if beyond the end of the array. This makes it possible to fill an array from high index to low, for example. Change-Id: If71699c20e2623142214ce2c11c4d6e4a120c989 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Implement QDataStream operator for main CBOR classesJędrzej Nowacki2018-10-031-0/+6
|/ | | | | | Change-Id: Ib3b68b1963625432c68d02be3bf2ec3c4baf1104 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* CBOR: Add missing clear() methods to the two container classesThiago Macieira2018-09-091-0/+1
| | | | | | Change-Id: Id59bdd8f1a804b809e22fffd153fd5174b58014d Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* JSON: Add qHash functions for JSON and CBOR typesUlf Hermann2018-08-271-0/+2
| | | | | | | This way we can easily use them as keys in QHash and QSet. Change-Id: Ie744c3b5ad1176ba2ab035c7e650af483757a0c9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QCborValue: Disable support for spaceship operatorThiago Macieira2018-07-291-1/+1
| | | | | | | | | __has_include(<compare>) is not the correct way to detect this feature, since that's a library header and may be provided by an implementation (libc++) before the compiler supports the syntax. Change-Id: I80aae0d068974d83b6c0fffd1544c8e558e2446b Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QCborArray: add const_iterator overloads for insert/erase/extractThiago Macieira2018-07-141-0/+4
| | | | | | | | | They return regular iterators, since the container has been modified. Change-Id: Id59bdd8f1a804b809e22fffd153f92d4460f9b76 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* CBOR: Use "noexcept" directlyThiago Macieira2018-07-141-9/+9
| | | | | | | | | | | 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>
* QCborArray & Map: implement move semanticsThiago Macieira2018-07-051-0/+3
| | | | | | | | | | | There isn't a lot of efficiency gain, since QCborValue was already refcounted. This saves two atomic operations and an out-of-line call. In the case of QCborValueRef (which includes QCborMap), because we reset the container pointer in inline code, the call to QCborValue::dispose() is also suppressed. Change-Id: Icc2c231dc2c44abdb087fffd1533eaba7a9c70fa Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* QCborValue: implement move semantics for QCbor{Array,Map} constructorsThiago Macieira2018-07-041-0/+5
| | | | | | | | Happens a lot because of the implicit conversions. So I made it inline. Change-Id: Icc2c231dc2c44abdb087fffd1533f311b95460b8 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QCborArray & Map: implement efficient take() / extract()Thiago Macieira2018-07-041-1/+2
| | | | | | | | | | | | Questions: 1) should QCborMap::extract return value_type (a pair) instead of just the value? 2) should the both return the iterator to the next element too, like erase()? Change-Id: I052407b777ec43f78378fffd15302a9c14468db3 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* CBOR: Add QDebug operators for the Qt CBOR value-like typesThiago Macieira2018-07-041-0/+4
| | | | | | | | | | 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>
* QCborValue: add support for QVariant and JSON conversionsThiago Macieira2018-06-081-0/+6
| | | | | | | Plus QStringList. Change-Id: I39332e0a867442d58082fffd1508dfb9b540af23 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Long live DOM API for CBOR!Thiago Macieira2018-06-081-0/+272
This is very similar to QJsonDocument, but there's no QCborDocument. QCborValue is that. [ChangeLog][QtCore] Added QCborValue, QCborArray and QCborMap, classes that permit DOM-like access to CBOR data. The API is similar to QJsonValue, QJsonArray and QJsonObject, respectively. Change-Id: I9741f017961b410c910dfffd14ffca50dd8ef3ba Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>