summaryrefslogtreecommitdiffstats
path: root/src/protobuf/qabstractprotobufserializer.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Doc: Remove incorrect \fn commentsTopi Reinio2025-03-041-29/+0
| | | | | | | | | | | | | | | | Remove \fn comments for QAbstractProtobufSerializer::(de)serializeObject(). These functions were dropped in 8ec55cb0cf77553434647f5f66d394cab8526e7b. Remove \fn for non-existent QProtobufRepeaterIterator constructor. Remove unnecessary \fn commands from QAbstractProtobufSerializer, let QDoc auto-tie the documentation instead. Pick-to: 6.9 6.8 Task-number: QTBUG-134250 Change-Id: If49049a33a307a522b3275b114e879442432e4c4 Reviewed-by: Dennis Oberst <dennis.oberst@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Scope QAbstractProtobufSerializer::Error enumAlexey Edelev2024-09-051-5/+5
| | | | | | | | | | | | All new enums should be scoped. Drive-by change: Remove the redundant suffixes of the enum elements. It's obvious from the scope that those are errors. Pick-to: 6.8 Task-number: QTBUG-123626 Change-Id: Ided4ab4a1ddb2d14713f876ffe4fe339af39ae6b Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Make error handling in QAbstractProtobufSerializer genericAlexey Edelev2024-08-281-11/+18
| | | | | | | | | | | | | | | | | | | | | | | Rename the deserializationError(String) interfaces to lastError(String). The new interface encourages to write the errors not only during deserialization but also serialization. TODO: Add serialization error handling to the existing QAbstractProtobufSerializer implementations. See QTBUG-128331. [ChangeLog][Protobuf] QAbstractProtobufSerializer::DeserializationError is renamed to QAbstractProtobufSerializer::Error and now contains list of both possible serialization and deserialization errors. [ChangeLog][Protobuf][QAbstractProtobufSerializer] deserializationError and deserializationErrorString renamed to lastError and lastErrorString respecively. Interfaces return the error from the last operation, either serialization or deserialization. Pick-to: 6.8 Task-number: QTBUG-123626 Change-Id: I705eb69e07393aa6601cc79712845200873235a0 Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
* Move all semi-public API from QProtobufMessageAlexey Edelev2024-08-241-1/+3
| | | | | | | | | | | Property-reading related API can be a separate functions that are used by our serializer implementations. Move all such methods from QProtobufMessage to a private header. Pick-to: 6.8 Task-number: QTBUG-123626 Change-Id: Iffe4e32932d163bbd5008f00842c038387b3bd0f Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QAbstractProtobufSerializer: add missing docsDennis Oberst2024-07-191-0/+12
| | | | | | | | | ... for the deserializationError{String} interface-methods. Task-number: QTBUG-125406 Change-Id: I3b9124908c657733507d2a96a36b3935e0ac969c Reviewed-by: Jaishree Vyas <jaishree.vyas@qt.io> Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* Rid of the (de)serializeEnumList interfaceAlexey Edelev2024-06-271-26/+0
| | | | | | | | | | | | | The methods applied the conversion from QList<EnumType> to QList<QtProtobuf::int64>. This can be done on the QMetaType level using the covert function. Add the conversion from/to QList<QtProtobuf::int64> for the QList<EnumType> and the conversion from/to QStringList, which should be used in JSON serialization. Pick-to: 6.8 Task-number: QTBUG-123626 Change-Id: Id0300536a8eda3503540089ba7bc29c1cd249752 Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
* Rid of QAbstractProtobufSerializer::(de)serializeMapPair interfacesAlexey Edelev2024-06-271-22/+0
| | | | | | | | | | | Use QProtobufPropertyOrderingBuilder to supply serializers with the required information about map fields. Pick-to: 6.8 Task-number: QTBUG-123626 Change-Id: I625b9003b87d010a8b563782f50dedc332f20293 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
* QAbstractProtobufSerializer: fix memory leak during deserializationDennis Oberst2024-06-101-2/+4
| | | | | | | | | | | Add the missing call to QMetaType::destruct() to ensure that message destructors are invoked before constructing new instances. This prevents memory leaks by properly freeing previously allocated elements. Pick-to: 6.8 6.7 Change-Id: I5d249032eb4b316feecb59cf6285d5973418538d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* Remove QAbstractProtobufSerializer::(de)serializeEnum interfaceAlexey Edelev2024-05-291-26/+0
| | | | | | | | Move the enum detection into the serilaizer implementations. Task-number: QTBUG-123626 Change-Id: I45e5d7b058b08a7489f0f61c5c66ffdbeae8a4ba Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
* Remove (de)serializeListObject interfaceAlexey Edelev2024-05-271-23/+0
| | | | | | | | | | Remove the QAbstractProtobufSerializer::(de)serializeListObject methods, QAbstractProtobufSerializer::(de)serializeObject should be sufficient. Task-number: QTBUG-123626 Change-Id: I83b6c5ec29ac35e710dc1bb2cccd3e751960e441 Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
* Rename QProtobufPropertyOrderingInfo to QProtobufFieldInfoAlexey Edelev2024-05-231-5/+5
| | | | | | | | | The struct represents the protobuf field information, so rename it accordingly. Task-number: QTBUG-123626 Change-Id: I79605a349f35e73c9fc808c76073d5c1c83c9731 Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
* Remove the redundant forward declaration of getOrderingByMetaTypeAlexey Edelev2024-05-231-4/+0
| | | | | | | | The declaration is unused. Change-Id: Icdd7fb8661e4d57c961f6c7cd666a3c2c780b672 Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io> Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
* Remove the redundant property ordering forwarding from all interfacesAlexey Edelev2024-03-081-25/+20
| | | | | | | | | | | | | | | | | | | | | | QProtobufMessage::propertyOrdering now allows accessing the message property ordering. So we can remove extra arguments from all interfaces where the pointer or the reference to the related QProtobufMessage is used as argument too. [ChangeLog][Protobuf][QAbstractProtobufSerializer] The following interfaces do not accept the QProtobufPropertyOrdering as an argument anymore: - serializeObject - deserializeObject - serializeListObject - deserializeListObject - serializeMessage - deserializeMessage Task-number: QTBUG-120931 Change-Id: I55cb8d3ceddd56751d542869e26aa0de73c22ebb Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
* Remove QProtobufBaseSerializerAlexey Edelev2024-02-051-0/+128
| | | | | | | | | | | It looks like this was design mistake to introduce this class. Protobuf messages require the sequence we use in QProtobufBaseSerializer is common for any serializers, so the overloaded serializers should follow it. Task-number: QTBUG-120931 Change-Id: I9e0a75d9cb72bfc9138cfba9fb26e36b9b0a6edb Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
* Move QProtobufPropertyOrdering to a separate unitAlexey Edelev2024-01-301-0/+1
| | | | | | | | | Move QProtobufPropertyOrdering to a separate source/header files. Task-number: QTBUG-120931 Change-Id: I2e44ab5ed1af73821ccd63711585ce3ca9893785 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
* Remove the Q_DECLARE_PROTOBUF_SERIALIZERS macroAlexey Edelev2024-01-241-45/+25
| | | | | | | | | | | | | | | | | | | | | | | | Now when we store the pointer to the property ordering in each QProtobufMessage instance, we may remove generating of redundant (de)serialize functions from messages. This adds the generic QProtobufMessage::serialize and QProtobufMessage::deserialize methods. Also we don't need the template serialize/deserilze methods in QAbstractProtobufSerializer since ordering information can be retrieved from the protobuf message base class. [ChangeLog][Protobuf][QProtobufMessage] Added the serialize and deserialize methods. [ChangeLog][Protobuf][QAbstractProtobufSerializer] The serialize and deserialize methods are now non-template. [ChangeLog][Protobuf] The Q_DECLARE_PROTOBUF_SERIALIZERS macro is removed from the API and is not generated anymore. Task-number: QTBUG-120931 Change-Id: I8ba8e6bb83728e58f781f42520629e1a9be4f026 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
* Reimplement (de)serializeRawMessage functions using the propertyOrdering methodAlexey Edelev2024-01-191-8/+6
| | | | | | | | | | We don't need to look for the property ordering anymore, we may get it directly. Task-number: QTBUG-120931 Change-Id: Id6f377eae0d6b3596ee4bfa6486f960f12b1c103 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Fix links to qtprotobufgenAlexey Edelev2024-01-161-1/+2
| | | | | | | | | Fix links to qtprotobufgen in QProtobufSerializer and QAbstractProtobufSerializer docs. Pick-to: 6.5 6.6 6.7 Change-Id: Ib17438308f3e5a27e4093a3c52bd3b20c6a442b5 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
* Doc: Improve class summariesKai Köhne2024-01-011-3/+3
| | | | | | | | | | Linkify keywords. Properly capitalize CMake and JSON. Use canonical qt_add_protobuf instead of the versioned qt6_add_protobuf. Pick-to: 6.6 6.7 Change-Id: Ibda8ec3afd141c6903fe36610fdc6288067e6d30 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* Implement JSON (de)serialization of map typesAlexey Edelev2023-12-161-0/+2
| | | | | | | | | | Implement QProtobufJsonSerializer::serializeMapPair and QProtobufJsonSerializer::deserializeMapPair functions. Pick-to: 6.7 Task-number: QTBUG-119390 Change-Id: I697cffe707ba1e4763ed8d08d836b3498a6247ab Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
* Documentation for ProtobufJaishree Vyas2023-03-101-1/+1
| | | | | | | | | | | Added Qt Protobuf overview, API description Fixed tiny mistakes in existing protobuf docs Updated grpc main page structure Task-number: QTBUG-110896 Pick-to: 6.5 6.5.0 Change-Id: I61a16c5ca5adb9a5f494562a12dcf6c71a31111c Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* Add protobuf message registry and raw QProtobufMessage serializationAlexey Edelev2022-12-071-0/+21
| | | | | | | | | | | | | | | This allows to create messages using the full protobuf message name, if the message was registered. Using this mapping between QMetaType and QProtobufOrdering it's now possible to serialize and deserialize pointers to QProtobufMessage without casting QProtobufMessage to the protobuf message type. This is partially required for conformance testing and Any type handling. Change-Id: I58fd2d821b76ce3f59f121b65ad28c2b28a189e7 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Update the 'since' tag in protobuf documentationAlexey Edelev2022-11-291-1/+1
| | | | | | | Update version to 6.5, since protobuf was not released at 6.4 times. Change-Id: I1714ca467fb897e9f079cc06cdd94d26b66fe6cb Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Protobuf: introduce base class QProtobufMessageMårten Nordheim2022-11-291-19/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | And inherit from it instead of QObject in messages. Messages are inherently value-types. They don't have any logic associated with them, they simply store some value(s). Value-types should be copyable and movable but QObject _is not_ because this would break connections and parenting. By making the objects Q_GADGETs we can still retain Q_PROPERTY, and by having a pointer to the object's staticMetaObject we can implement property/setProperty functionality in QProtobufMessage with minimal effort. As a side-effect of this we no longer emit, or even have, signals when values on a message changes. But, as mentioned previously, messages don't have any logic associated to them so they would never update without users either calling an associated setter function or by deserializing a new message into an already-existing object. As another side-effect: propertyCount has decreased because we no longer have QObject's 'name' property. Fixes: QTBUG-100986 Change-Id: I0366a180bf5aadd4afb075527b80cc0a3e923ab6 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* Long Live QProtobufMårten Nordheim2022-11-081-0/+109
The code handles serialization and deserialization by itself with no extra dependencies. It also contains a system for registering converters specific to Protobuf serialization as well as having the ability to extend it to handle JSON encoding[0] in the future, using QJson. This patch is a companion to the patch introducing the qtprotobufgen tool. The code was originally written by Alexey Edelev, along with various contributors, on GitHub. Originally under MIT license, but major contributors have agreed to relicense the code under LGPL/GPL/commercial for inclusion in Qt. Their copyright notice is retained and the original source code, still licensed as MIT, can be found in its original repository[1]. [0]: https://developers.google.com/protocol-buffers/docs/proto3#json [1]: https://github.com/semlanik/qtprotobuf Done-with: Alexey Edelev <alexey.edelev@qt.io> Change-Id: I8b2e7074a19f39bd52ab263e215d2e99ffaf1162 Reviewed-by: Alex Blasche <alexander.blasche@qt.io> Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>