mirror of https://github.com/qt/qtgrpc.git
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 Pick-to: 6.7 Change-Id: I92a7aed22208b1e5f073089306da2e04fb143f9b Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
This commit is contained in:
parent
4b4785d609
commit
fb0136487a
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -136,7 +136,7 @@ void QGrpcOperation::read(QProtobufMessage *message) 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();
|
||||
}
|
||||
|
|
@ -144,7 +144,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();
|
||||
}
|
||||
|
|
@ -153,7 +153,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();
|
||||
}
|
||||
|
|
@ -162,7 +162,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();
|
||||
}
|
||||
|
|
@ -185,7 +185,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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,11 +36,11 @@ public:
|
|||
|
||||
void read(QProtobufMessage *message) const;
|
||||
|
||||
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();
|
||||
|
|
@ -49,14 +49,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)
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue