Commit Graph

40 Commits

Author SHA1 Message Date
Alexey Edelev 00a86d9d2c Handle special cases of JSON serializing of the Well-known types
Change the way we handle them. Add the special registry so any
type can register its special JSON (de)serializer independently.

Move the timestamp serializer from the generic JSON serializer
implementation to QtProtobufWellknownTypes library so we remove
the weak backward link from QtProtobuf module to its dependency.

The introduced mechanism is also scalable, and allows adding other
types that have similar special JSON serialization.

Task-number: QTBUG-130555
Task-number: QTBUG-120214
Change-Id: I56ce2e43a00262069281871d5f903f1e94abef83
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
2025-01-17 18:14:52 +01:00
Alexey Edelev 9966fdac34 Generate the missing includes for the nested Qt types
When using the nested Qt types from either QtCore or QtGui packages
protobuf generator doesn't consider these types when generating the
includes.

Fixes: QTBUG-132182
Pick-to: 6.8 6.9
Change-Id: I6f0de0119ff9f8fd8109dd621a0d20f5dca31003
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
2025-01-06 15:18:58 +01:00
Alexey Edelev 4b778a70d0 Avoid generating QList aliases for the protobuf messages
Generating the aliases for protobuf QList types leads to the name
clashing when users want ot introduce messages that have name
consisting of previously defined message name and Repeated suffix,
e.g.:
  message MyMessage {
  }
  message MyMessageRepeated {
  }

We shouldn't prohibit the above scheme in our generators and generate
the respective messages correctly. The only possible solution -
complete removal of the protobuf messages QList aliases.

Generator still generates the aliases guarded by the
QT_USE_PROTOBUF_LIST_ALIASES macro. The macro is enabled by
Qt::Protobuf when building using CMake, but can be disabled at any
time by setting QT_USE_PROTOBUF_LIST_ALIASES property on protobuf
target to avoid name clashing.

[ChangeLog][Protobuf] qtprotobufgen doesn't generate protobuf message
QList aliases. All usages of aliases should be replace by respective
QList types. Aliases are still generated and are guarded by the
QT_USE_PROTOBUF_LIST_ALIASES macro in the generated code. The macro
is enabled by default and can be disabled using
QT_USE_PROTOBUF_LIST_ALIASES target property.

Fixes: QTBUG-129652
Pick-to: 6.8 6.9
Change-Id: I026755b36985eef01a6851156d9c9cfff141d247
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
2024-12-16 09:57:33 +01:00
Dennis Oberst 4a3fc66b89 generator: handle invalid identifier(s) in filename
The generation was broken for proto filenames, which where
invalid identifier, since the filename is used at several places in the
generation process.

This became evident for the protobuftyperegistrations and traditional
filename header guards.

Solve this by transforming the basename into a valid identifier.
Also add a testcase on the highest point of abstraction for the
generators (qtgrpcgen).

Fixes: QTBUG-131417
Pick-to: 6.8
Change-Id: I492907881913f8b43ebf365a9e1fe38062113c3c
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2024-12-06 18:13:44 +01:00
Alexey Edelev 4577291626 Fix the invalid handling of header files suffixes
Avoid removing and appending header files suffixes where this is not
intentional. Change the default internal header file template and
always add the suffix explicitly, where required.

Pick-to: 6.8
Change-Id: I1fff1d3813700d6387964d5411970b21ecb4a2e6
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
2024-09-27 17:24:29 +02:00
Alexey Edelev f3125dd7a3 Add support of the pragma once header guard to the generator
The ifdef based header guard has potential downside for the protobuf
code generating. '.proto' files may have the same name but locate in
different directories. We could encode the package name in a header
guard too, but .proto files may share the same package as well.

The use of 'pragma once' instead of ifdef based header guard solves
this issue. Add the 'HEADER_GUARD' generator and qt6_add_protobuf
options, so users may switch back to the ifdef based guard if they
want. The option accepts one of the two values:
 - pragma
 - filename

Change-Id: Ice0a3b2baa76752a1ee4b3507b7f3163738455ee
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
2024-09-16 11:25:03 +02:00
Alexey Edelev 286073b0e4 Re-arrange and cleanup includes in the generated code
Sort includes according to the common Qt rules:
 - internal header first, Qt header files next, system header file last
 - split includes to sections
 - use ascending order for each include section

Cleanup redundant and unused header files from the generated code.

Pick-to: 6.8
Task-number: QTBUG-123625
Task-number: QTBUG-123626
Change-Id: Ibecdecd4fb61e3b554746d623ed691be5ee6f57d
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-08-19 13:16:01 +02:00
Alexey Edelev d4e8ef8942 Adjust the header guards in the generated code
Use the proper file names when generating the guards for the header
files instead of using the hardcoded suffixes.

Refactor the filename calculations in the generator as the
drive-by change.

Pick-to: 6.8
Task-number: QTBUG-123625
Change-Id: Ie1e6c7ecb5dc611b72bd01228524701157b26d4b
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
2024-08-19 13:15:57 +02:00
Alexey Edelev c90098132c Remove unused includes from generators
Pick-to: 6.8
Change-Id: I227d17e747dddc5c4767fde12d689efa94aa507e
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
2024-07-24 09:35:52 +00:00
Alexey Edelev b16b399c00 Remove the redundant Q_DECLARE_METATYPE for protobuf messages
"Some types are registered automatically and do not need this macro:
  ...
  - Classes that have a Q_GADGET macro
" (c)

Pick-to: 6.8
Task-number: QTBUG-123626
Change-Id: I5c73d61a51341328d37e71290633f484a3cbdfb8
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-07-23 09:35:08 +02:00
Alexey Edelev 565f2bb598 Remove redundant include of <memory> from generated protobuf headers
The include is unused in the generated protobuf code, but is used in
the generated gRPC code. Make it gRPC specific.

Pick-to: 6.8
Change-Id: I25ad6ffe88e46a63d928b09362211d6d590eb625
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
2024-06-27 18:02:11 +02:00
Alexey Edelev b75bc17c33 Add the missing generating of the C++ exports to the qtgrpcgen
Make the generating of C++ exports common for both generators.
The confilicting generation should be resolved by the tools that
running the generators. Qt CMake API handles this situation.

Fixes: QTBUG-121856
Pick-to: 6.7
Change-Id: Ie2452f52d755ade2909107885dac774ff8678daa
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
2024-02-06 17:23:19 +01:00
Alexey Edelev ae2f1ed3d3 Fix the generation of the export macro
Consider the EXPORT_MACRO CMake argument of qt_add_<protobuf|grpc>
calls.

Add the support for the EXPORT_MACRO option extras to the
qt<protobuf|grpc>gen generators. The extras now allow setting:
 - export file name
 - boolean flag that indicates if export file needs to be generated

The EXPORT_MACRO option of the generators now has the following format:
   EXPORT_MACRO=<export_name>[:export_filename[:<true|false>]]

If export_filename is not set, then generators fall back to the previos
behavior and use the export_name as the export filename base, the file
will be generated unconditionally. If export_filename is set and the
follow boolean flag is not set or is set to false, generators skip the
generating of the export file.

[ChangeLog][Protobuf][qtprotobufgen] EXPORT_MACRO option now has the
following format:
    EXPORT_MACRO=<export_name>[:export_filename[:<true|false>]]
New option extras allow setting the generated export filename and
control if it should be generated at the generator run.
[ChangeLog][GRPC][qtgrpcgen] EXPORT_MACRO option now has the
following format:
    EXPORT_MACRO=<export_name>[:export_filename[:<true|false>]]
New option extras allow setting the generated export filename and
control if it should be generated at the generator run.

Pick-to: 6.7
Fixes: QTBUG-121854
Change-Id: Ifff6506ab363d18dc417f222e9929d7eba135d8a
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2024-02-06 06:59:48 +01:00
Alexey Edelev b9519412ae Move all registration functionality to a separate unit
Move functionality related to the registration of the protobuf messages
to a separate header/source files.

Task-number: QTBUG-120931
Change-Id: I6076b41139d43982148e46f5f315808509c4db65
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
2024-01-26 20:51:01 +01:00
Alexey Edelev ad3960ae39 Remove the redundant include of QtQml/qqmlengine.h
The include is not used in the generated code.

Pick-to: 6.6 6.7
Change-Id: I94c9649d7f9130b796b44de578b32ae4acd3655e
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
2024-01-26 20:51:01 +01:00
Tatiana Borisova e17d28e0d0 qRegisterProtobufTypes() should be called for applications implicitly
- Delete manual qRegisterProtobufTypes() call in QML auto-tests
- Add auto-generation line into qtprotobufgen
*_protobuftyperegistrations.cpp file. Now registration is happening via
static variable.

Pick-to: 6.7 6.6
Task-number: QTBUG-117643
Change-Id: Ic9c7e299fd2cd157ff4f2705d34bc4606a83ddbe
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
2024-01-24 11:40:14 +01:00
Alexey Edelev 6c6d7bb687 Add the sign detection for floating point numbers
When serializing/deserializing floating point numbers to/from JSON we
should consider the sign bit. This allows serializing -0.0 in JSON.

TODO: Signed zeros are not supported by cbor. See QTBUG-120077

Pick-to: 6.7
Task-number: QTBUG-119392
Change-Id: I587ab23269845f3de34a27a7335635ac0d4baebb
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-12-18 08:36:15 +01:00
Dennis Oberst 8ebca7f46c QProtobufGenerator: Fix deprecation warning for 'has_optional_keyword()'
... got deprecated in Protobuf v25.0-rc2

Warning states:
‘bool google::protobuf::FieldDescriptor::has_optional_keyword() const’
is deprecated: Syntax is deprecated in favor of editions, please use
FieldDescriptor::has_presence instead. [-Wdeprecated-declarations]

Change-Id: If33d214939ddf3f1018b875d0c47692690394f72
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-11-01 09:59:23 +01:00
Tatiana Borisova dd897eea93 Move C++ definitions to a common header file
Task-number: QTBUG-116045
Change-Id: I000c08318e748109782603a620686e2252fc4511
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
2023-10-26 12:01:39 +02:00
Alexey Edelev 913aef61d8 Implement support of 'optional' fields
'optional' fields is the legacy mechanism from 'proto2' times. In
'proto3' schemes this keyword changes the 'presence' handling of
the fields that are marked as 'optional'. By default protobuf
messages(serializer to be precise) treat all fields as optional.
This means that if field has the default value(0, 0.0f, false, nullptr)
the field will not be serialized at all. This mechanism can be
overwritten using the 'optional' attribute or keyword. If the message
field is marked as 'optional' it gets the following methods in addition
to the regular field one:
 - clear<fieldName>
 - has<fieldName>

These methods allow to clear the value and to check whether the field
was ever set. The optional fields get serialized if they were
explicitly set in the message, even if they have the default value.
This is the key difference that this attribute/keyword makes on
the serialization process.

[ChangeLog][QtProtobuf] All message fieds now have 'has' methods
that indicate if message was initialized and contain value or not.

Task-number: QTBUG-103978
Change-Id: Ia948be85486175bb2d81357352f5c04da12af846
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
2023-09-28 14:07:12 +02:00
Alexey Edelev b089a773e9 Move enums to the nested namespace out of class
Protobuf allows the following construction:
  message A {
      enum AEnum {
        AVal0 = 0;
      }
      B.BEnum val = 1;
  }
  message B {
      enum BEnum {
          BVal0 = 0;
      }
      A.AEnum val = 1;
  }

This requires forward declaration of nested enums, that is not possible
in C++. To solve this problem we may do the same trick that we do
for nested messages already.
This patch moves the nested enum type out of class to the
_QtProtobufNested namespace. The solution require the enum name
specification when using enums from this moment, since the owning
messages only contain type aliases now. So from example above to access
the AVal0 you need to use the full qualifier:
  A::AEnum::AVal0

The new generated code structure registrates Qml types using the built-in
macros, that unlocks direct linking of backing library without the need
of Qml plugin usage.

[ChangeLog][Protobuf] Nested enums moved out of message classes to the
nested namespace, same as the nested messages.

[ChangeLog][Protobuf][Qml] The geneated protobuf Qml modules do not
require the use of Qml plugins.

Fixes: QTBUG-115800
Change-Id: Ia67fcbecf492c3fd41350eada4d62fc9e5ea4dab
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-08-18 19:01:25 +02:00
Alexey Edelev b94ba71cf7 Do not return error if the .proto file contain no type declarations
The missing message or enum declarations shouldn't lead to an error
when running protobuf generator. This only means that the .proto file
needs no processing.

Pick-to: 6.5 6.6
Change-Id: I80c81ebd04024c1e08883b8a0b9cf572b0c3aa1d
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
2023-08-12 19:45:37 +02:00
Alexey Edelev 4a4cf48a0d Replace has_optional_keyword for old libprotoc versions
Use the old syntax-based check if libprotoc version is less than
3.12.

Amends dd04edf72f

Pick-to: 6.6
Task-number: QTBUG-115693
Change-Id: Ia411f70337a14843ff320b7c75ab140f5021f2f6
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
2023-08-03 10:43:11 +02:00
Alexey Edelev bbb19e18e2 Allow using 'optional' fields
Enable 'optional' fields support in Qt generators. This only allows
using 'optional' fields, but doesn't generate the respective logic
that changes the way of fields serialization. All optional fields
are treated as normal fields in this generator version. This step
allows users to move forward with existing protobuf schemes that
contain optional fields.

Pick-to: 6.6
Task-number: QTBUG-114833
Task-number: QTBUG-114962
Change-Id: I8990325f5fe06470742dc7d607141533bd229c24
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
2023-07-27 12:34:15 +02:00
Konrad Kujawa 2297f2da52 Remove call to protobuf FileDescriptor::syntax()
In the new version of protobuf FileDescriptor::syntax() should not
be used. Instead, protobuf API should be working with both,
proto2 and proto3 syntax.

Task-number: QTBUG-114833
Task-number: QTBUG-114962
Pick-to: 6.6
Change-Id: I86542cfcc0cc247f1e75e6d711e269ff3537f8a4
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-07-25 12:04:51 +02:00
Alexey Edelev e9f6546483 Create both plugin and backing library in qt_add_protobuf
This approach allows reusing the existing backing target if it's
library and makes step towards plugin-less Qml module.

Pick-to: 6.6
Task-number: QTBUG-115117
Change-Id: I02243d700683ac9e01c1471c3ccccaae71841165
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-07-25 10:18:07 +02:00
Alexey Edelev 37d28cc226 Rework the Qml plugin export macro
Since the plugin is not exposed by any header file it doesn't make
sense to overcomplicate its export. Use internal cpp macro to export
required plugin. Also this fixes potential issue when export macro
is not provided by user to qtprotobufgen, so the export is not
generated and plugin symbols are simply unaccessible.

Pick-to: 6.6
Change-Id: Ie54cd94eb5ac9e6bb895c02456a6d6d6669a1daf
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-07-25 10:17:51 +02:00
Alexey Edelev 4d963586fb Re-enable google.protobuf.Timestamp support in well-know types
Enable google.protobuf.Timestamp in well-know types. Add extra
methods that allow convert the generated class from/to QDateTime.

Task-number: QTBUG-114972
Task-number: QTBUG-112430
Change-Id: I00a6878cdd0461f9f0938dd5fa284743df0d8dc8
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-07-03 18:30:46 +02:00
Konrad Kujawa 1a610ab9c7 Remove protobuf logging.h include
This include was removed in the new version of the protobuf,
and it was unused anyway.

Pick-to: 6.6
Change-Id: I5c68f960c031d7f366ab3dc1b690dc9050369975
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-06-23 12:31:59 +02:00
Konrad Kujawa 0d0d14e551 Fix include of std::set
With new version of gRPC, compiler complains about missing include of
the std::set. Move include from .cpp to .h files.

Pick-to: 6.6
Change-Id: Ibfef277598cb9e620ab1b693a42564706302c9cc
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-06-23 12:31:54 +02:00
Tatiana Borisova 1b6b1aab83 Registration of Qt Protobuf types is moved into auto-generated code
- updated qtprotobufgen test respectively

Task-number: QTBUG-104513
Pick-to: 6.6
Change-Id: I6b7c4a963602e6885c9f7412485c6c49c057081b
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-06-23 09:49:47 +00:00
Tatiana Borisova 0b270e4602 Add qt_add_qml_module to qt_add_protobuf function for QML generation
In case of generating Qt protobuf source code with QML argument,
QML plugin will be created and included into Application build tree.

New QML_URI option is introduced. If there is no package name,
qtprotobufgen must request the QML_URI setting.

Also, it is possible to link several *.proto files to the same plugin
via common URI.

Add nopackage auto-test. Update protobufgen auto-test.
Remove the usage of RESOURCE_PREFIX, replaced by qt_policy.

Task-number: QTBUG-104513
Change-Id: If5c5496245144fa2b499730ab9fdf7d0ee7b2c25
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
2023-06-01 12:44:22 +02:00
Tatiana Borisova 0e6a605867 Add enum registration logic and enums-test in QML
QtProtobufgen registers global and local enums in QML context now.
Registration is in qml extension plugin part.

Task-number: QTBUG-104513
Change-Id: Iecbc08d4b915113e7d5753b1f1d24d3c34088ba2
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-05-17 17:07:02 +02:00
Tatiana Borisova 21e208ec96 QtProtobuf: add QML support
Enable QML flag for qtgrpcgen/qtprotobufgen plugins.
Generated output is updated: QProtobufMessage classes are Q_GADGETs,
such classes can be registered in QML code via QML_VALUE_TYPE macros only.
Also QProtobufMessages are not inherited from QObject class, it means
there is no full qmetaobject system support (no signals!).

Task-number: QTBUG-104513
Change-Id: I18c8f93782884efb8d923843df716ff8284ed8fb
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-05-04 12:35:22 +03:00
Tatiana Borisova cd58cbee45 qtprotobufgen/qtgrpcgen: Fix code-style infractions
Task-number: QTBUG-110491
Change-Id: I208dba1d2a3bcfeaaabc861c5a335351c55a715a
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-03-17 15:00:24 +01:00
Samuli Piippo 2f0e03626f QtProtobuf: add include for std::unordered_set
Amend 6637773cbd with missing include.

Change-Id: Idbd6c1a1c3844025107a9f00bda772538d97bfb5
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
2023-02-27 11:18:42 +02:00
Tatiana Borisova 6637773cbd QtProtobuf: Provide support for Qt types in a separate library
Task-number: QTBUG-103985
Change-Id: I2086f5cf46e1424b62b2044d0bcab315a5d447d9
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-02-24 10:34:58 +01:00
Alexey Edelev 2e3fdd5c05 Add support for the 'oneof' type
This patch adds support for 'oneof', a union-like type in protobuf,
that need not contain a value, with the following features:
 - Setting a oneof field will automatically clear all other
   members of the oneof.
 - If the parser encounters multiple members of the same oneof
   on the wire, only the last member seen is used in the
   parsed message.
 - A oneof cannot be repeated.
 - A oneof cannot contain repeated or map fields.
 - If you set a oneof field to the default value (even the default,
   such as 0 for an int32 oneof field), the "case" of that oneof
   field will be set, and the value will be serialized on the
   wire.

Unlike the reference C++ implementation, the Qt implementation of
'oneof' fields adds the 'has<PropertyName>' functions for every
'oneof' member. The protobuf generator generates a Q_PROPERTY for each
member of the 'oneof'; these properties are collectively implemented
as a single class member.

'oneof' fields are represented by the
QtProtobufPrivate::QProtobufOptional class. The class holds the 'oneof'
field number and the value that it contains as QVariant.
A QExplicitSharedDataPointer is used as reference counter, and to copy
and to free the memory of protobuf messages that are stored inside the
nested QVariant as pointers.

The class could also be used to hold 'optional' fields in follow up
commits, but has small overhead since it holds field number, that
is not used by optional fields.

The generated classes also allows reading field number that is
currently stored in the 'oneof' field.
The QtProtobuf::InvalidFieldNumber constant indicates that oneof fields
is uninitialized.

The serialization and deserialization tests use the expected values
from the results of the reference C++ serialization(protobuf version
3.19).

Task-number: QTBUG-103981
Change-Id: Ie4053cb164bba6bc5f14f8cedb34bad62a638c43
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-02-23 12:48:57 +01:00
Mårten Nordheim 7b1d7832a2 Add support for the google.protobuf.Any type
This also means adding another library; the Protobuf Well-Known types
library. No other types added from the collection at the moment.

The Any type is like QVariant or std::any in the sense that it can hold
any type. A small string is embedded along with the Any type upon
serializing. This corresponds to some URL, that can be used for
dynamically looking up definitions of types if wanted
(we don't support this), plus the object name.
We use the embedded object name to verify, upon attempting to
deserialize, that the objects are the same. The function is called
as<T>.
Some users may want a as_unchecked<T>, in the future, where we don't do
this, since different messages may be binary compatible but miss some
fields. And this is fine.
Further, the class also contains the raw bytes of its contained message.
We, quite simply, need to deserialize it to some type when requested.

Implementation consists of a helper-class which uses the "real class" we
generate when serializing or deserializing. At some point they could
potentially be collapsed together to avoid extra overhead. But then
the metadata fields need to be dynamically created or manually
maintained.
When asked to serialize/deserialize the class simply proxies calls to
the "real class" underneath

Fixes: QTBUG-103982
Change-Id: Ie9e833cd30aa58afbd5bdd1a9e9c83bdece6f685
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-02-14 16:00:23 +01:00
Tatiana Borisova 326ebfaadb QtGrpc: Update code generator to generate gRPC structures
Split the .proto files generator into QtProtobuf and QtGrpc parts.

Pick-to: 6.5
Task-number: QTBUG-105496
Change-Id: Ib43abe4c1fb849ecf68952b82af9d3988e88e02a
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-01-11 12:04:11 +01:00