DuxReiNummariae 1.0.0-alpha.23
Simple and powerful budgeting application
 
Loading...
Searching...
No Matches
drn::networking::QtReplyResponse Class Referencefinal

Represents a network request's reply response using Qt's QNetworkReply. This is designed to encapsulate a QNetworkReply object, which is used for handling network responses in Qt applications. More...

#include <QtRequestSender.hpp>

Inheritance diagram for drn::networking::QtReplyResponse:
Collaboration diagram for drn::networking::QtReplyResponse:

Public Member Functions

 QtReplyResponse (foundation::UniqueQtPtr<::QNetworkReply > reply, const foundation::QtPtr< QObject > &parent)
 Full initialisation constructor for a specified QNetworkReply and parent object. This constructor initializes the object by taking ownership of a QNetworkReply object and setting a parent for the object. It also sets up a connection to handle the 'finished' signal from QNetworkReply, calling the responseReady() slot.
 
QVariant attribute (const QNetworkRequest::Attribute code) const noexcept override
 Retrieves the specified attribute from the network request. This is used to obtain various attributes associated with a network request, such as HTTP status codes, redirection targets, etc. It is essential for handling different aspects of the response beyond the raw data.
 
QNetworkReply::NetworkError error () const noexcept override
 Provides the current error state of the network reply. This is used to retrieve the error status of a network operation. This information is crucial for handling any issues in network communication, allowing the application to react accordingly.
 
QString errorString () const noexcept override
 Provides a human-readable description of any network error that has occurred during a request-response cycle. Useful for logging or displaying error messages to users.
 
QByteArray readAll () override
 Reads and retrieves all remaining data from the reply. It extracts all data that has been buffered into the reply object from a network operation. Typical usage involves calling this method after a network request has completed to obtain the full response payload for further processing. Use this method to read the entirety of the data content in one go.
 
QUrl url () const noexcept override
 Gives the URL to which the network request was made.
 
- Public Member Functions inherited from drn::networking::ReplyResponse
 ReplyResponse (const foundation::QtPtr< QObject > &parent)
 Fully initialises the object with a specified parent.
 

Additional Inherited Members

- Signals inherited from drn::networking::ReplyResponse
void ready ()
 Triggered when a response from a network request is ready for processing. This signal is meant to be connected to a slot or lambda function that handles the response once a network request completes. It indicates that the reply object contains data that is ready to be processed, or is in an error state.
 

Detailed Description

Represents a network request's reply response using Qt's QNetworkReply. This is designed to encapsulate a QNetworkReply object, which is used for handling network responses in Qt applications.

Constructor & Destructor Documentation

◆ QtReplyResponse()

drn::networking::QtReplyResponse::QtReplyResponse ( foundation::UniqueQtPtr<::QNetworkReply > reply,
const foundation::QtPtr< QObject > & parent )

Full initialisation constructor for a specified QNetworkReply and parent object. This constructor initializes the object by taking ownership of a QNetworkReply object and setting a parent for the object. It also sets up a connection to handle the 'finished' signal from QNetworkReply, calling the responseReady() slot.

Parameters
replyThe QNetworkReply to be observed and owned by this instance.
parentThe parent used to manage the memory and lifecycle of this instance, and ensuring it follows the Qt object hierarchy.

Member Function Documentation

◆ attribute()

QVariant drn::networking::QtReplyResponse::attribute ( const QNetworkRequest::Attribute code) const
nodiscardoverridevirtualnoexcept

Retrieves the specified attribute from the network request. This is used to obtain various attributes associated with a network request, such as HTTP status codes, redirection targets, etc. It is essential for handling different aspects of the response beyond the raw data.

Parameters
codeThe attribute code to retrieve.
Returns
The value of the requested attribute wrapped in a QVariant. If the attribute is not present, the returned QVariant will be invalid.

Implements drn::networking::ReplyResponse.

◆ error()

QNetworkReply::NetworkError drn::networking::QtReplyResponse::error ( ) const
nodiscardoverridevirtualnoexcept

Provides the current error state of the network reply. This is used to retrieve the error status of a network operation. This information is crucial for handling any issues in network communication, allowing the application to react accordingly.

Returns
It gives a value indicating the specific error that occurred during the request, if any.

Implements drn::networking::ReplyResponse.

◆ errorString()

QString drn::networking::QtReplyResponse::errorString ( ) const
nodiscardoverridevirtualnoexcept

Provides a human-readable description of any network error that has occurred during a request-response cycle. Useful for logging or displaying error messages to users.

Returns
A description of the network error as a string. If no error occurred, the string will be empty.

Implements drn::networking::ReplyResponse.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readAll()

QByteArray drn::networking::QtReplyResponse::readAll ( )
nodiscardoverridevirtual

Reads and retrieves all remaining data from the reply. It extracts all data that has been buffered into the reply object from a network operation. Typical usage involves calling this method after a network request has completed to obtain the full response payload for further processing. Use this method to read the entirety of the data content in one go.

Returns
All the data read from the reply.

Implements drn::networking::ReplyResponse.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ url()

QUrl drn::networking::QtReplyResponse::url ( ) const
nodiscardoverridevirtualnoexcept

Gives the URL to which the network request was made.

Returns
The URL used for the network request.

Implements drn::networking::ReplyResponse.

Here is the call graph for this function:
Here is the caller graph for this function: