diff options
author | Dennis Oberst <dennis.oberst@qt.io> | 2024-03-26 14:08:51 +0100 |
---|---|---|
committer | Dennis Oberst <dennis.oberst@qt.io> | 2024-04-04 16:47:35 +0000 |
commit | 6de3e945c49ebdc1fd4916d62a675ce4e410c2f4 (patch) | |
tree | b64fcce71fa90caadd5653f9d8b909e35c064d63 | |
parent | 20a26c1e48aa5f044afccb46d31d13013637d7e6 (diff) |
QGrpcOperation: modernize api with [[nodiscard]]
This improves tooling for return values that shouldn't be ignored.
As a drive-by mark some of those functions as noexcept.
Task-number: QTBUG-123625
Change-Id: I92a7aed22208b1e5f073089306da2e04fb143f9b
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
(cherry picked from commit fb0136487affbfff6f5388ec2064b51ad99b7e67)
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
-rw-r--r-- | src/grpc/qgrpcoperation.cpp | 12 | ||||
-rw-r--r-- | src/grpc/qgrpcoperation.h | 14 |
2 files changed, 13 insertions, 13 deletions
diff --git a/src/grpc/qgrpcoperation.cpp b/src/grpc/qgrpcoperation.cpp index ff695bc..89e2d9d 100644 --- a/src/grpc/qgrpcoperation.cpp +++ b/src/grpc/qgrpcoperation.cpp @@ -104,7 +104,7 @@ QGrpcOperation::~QGrpcOperation() = default; \internal Getter of the data received from the channel. */ -QByteArray QGrpcOperation::data() const +QByteArray QGrpcOperation::data() const noexcept { return d_func()->data; } @@ -113,7 +113,7 @@ QByteArray QGrpcOperation::data() const Getter of the metadata received from the channel. For the HTTP2 channels it usually contains the HTTP headers received from the server. */ -QGrpcMetadata QGrpcOperation::metadata() const +QGrpcMetadata QGrpcOperation::metadata() const noexcept { return d_func()->channelOperation->serverMetadata(); } @@ -121,7 +121,7 @@ QGrpcMetadata QGrpcOperation::metadata() const /*! Getter of the method that this operation was intialized with. */ -QLatin1StringView QGrpcOperation::method() const +QLatin1StringView QGrpcOperation::method() const noexcept { return d_func()->channelOperation->method(); } @@ -130,7 +130,7 @@ QLatin1StringView QGrpcOperation::method() const \internal Returns a pointer to the assigned channel-side QGrpcChannelOperation. */ -const QGrpcChannelOperation *QGrpcOperation::channelOperation() const +const QGrpcChannelOperation *QGrpcOperation::channelOperation() const noexcept { return d_func()->channelOperation.get(); } @@ -139,7 +139,7 @@ const QGrpcChannelOperation *QGrpcOperation::channelOperation() const \internal Getter of the serializer that QGrpcOperation was constructed with. */ -std::shared_ptr<const QAbstractProtobufSerializer> QGrpcOperation::serializer() const +std::shared_ptr<const QAbstractProtobufSerializer> QGrpcOperation::serializer() const noexcept { return d_func()->channelOperation->serializer(); } @@ -162,7 +162,7 @@ void QGrpcOperation::cancel() Returns true when QGrpcOperation finished its workflow, meaning it was finished, canceled, or error occurred, otherwise returns false. */ -bool QGrpcOperation::isFinished() const +bool QGrpcOperation::isFinished() const noexcept { return d_func()->isFinished.loadRelaxed(); } diff --git a/src/grpc/qgrpcoperation.h b/src/grpc/qgrpcoperation.h index 922eeff..2e9f6ad 100644 --- a/src/grpc/qgrpcoperation.h +++ b/src/grpc/qgrpcoperation.h @@ -34,11 +34,11 @@ public: return value; } - QGrpcMetadata metadata() const; - QLatin1StringView method() const; + [[nodiscard]] QGrpcMetadata metadata() const noexcept; + [[nodiscard]] QLatin1StringView method() const noexcept; void cancel(); - bool isFinished() const; + [[nodiscard]] bool isFinished() const noexcept; Q_SIGNALS: void finished(); @@ -47,14 +47,14 @@ Q_SIGNALS: protected: explicit QGrpcOperation(std::shared_ptr<QGrpcChannelOperation> channelOperation); - const QGrpcChannelOperation *channelOperation() const; - std::shared_ptr<const QAbstractProtobufSerializer> serializer() const; + [[nodiscard]] const QGrpcChannelOperation *channelOperation() const noexcept; + [[nodiscard]] std::shared_ptr<const QAbstractProtobufSerializer> serializer() const noexcept; private: Q_DISABLE_COPY_MOVE(QGrpcOperation) - QByteArray data() const; - QGrpcStatus deserializationError() const; + [[nodiscard]] QByteArray data() const noexcept; + [[nodiscard]] QGrpcStatus deserializationError() const; Q_DECLARE_PRIVATE(QGrpcOperation) }; |