RestLink 2.2.0
Powerfull Rest Client for Qt
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
RestLink::ResponseBase Class Reference

An abstract base class for handling response data streams. More...

#include <responsebase.h>

Inherits QIODevice.

Inherited by RestLink::Response.

Public Member Functions

 ResponseBase (QObject *parent=nullptr)
 
virtual ~ResponseBase ()
 
bool isSequential () const override
 
bool open (OpenMode mode) override
 
void close () override
 
qint64 pos () const override
 
qint64 size () const override
 
bool seek (qint64 pos) override
 
bool atEnd () const override
 
bool reset () override
 
qint64 bytesAvailable () const override
 
qint64 bytesToWrite () const override
 
bool canReadLine () const override
 
bool waitForReadyRead (int msecs) override
 
bool waitForBytesWritten (int msecs) override
 
virtual QJsonObject readJsonObject (QJsonParseError *error=nullptr)
 Reads the response body as a JSON object.
 
virtual QJsonArray readJsonArray (QJsonParseError *error=nullptr)
 Reads the response body as a JSON array.
 
virtual QJsonValue readJson (QJsonParseError *error=nullptr)
 Reads the response body as a JSON value.
 
virtual QString readString ()
 Reads the response body as a QString.
 
virtual QByteArray readBody ()
 Reads the raw response body as a QByteArray.
 
QIODevice * responseDevice () const
 

Protected Member Functions

qint64 readData (char *data, qint64 maxlen) override
 
qint64 readLineData (char *data, qint64 maxlen) override
 
qint64 skipData (qint64 maxSize) override
 
qint64 writeData (const char *data, qint64 len) override
 
void setResponseDevice (QIODevice *device)
 

Detailed Description

An abstract base class for handling response data streams.

This class extends QIODevice to provide convenient methods for reading different types of content (JSON objects, arrays, raw bytes, strings) from a response device. It is intended to serve as a flexible interface for response handling in the RestLink framework.

It supports streaming and can wrap any QIODevice to perform actual data access.

Constructor & Destructor Documentation

◆ ResponseBase()

RestLink::ResponseBase::ResponseBase ( QObject *  parent = nullptr)
explicit

◆ ~ResponseBase()

RestLink::ResponseBase::~ResponseBase ( )
virtual

Member Function Documentation

◆ isSequential()

bool RestLink::ResponseBase::isSequential ( ) const
override

◆ open()

bool RestLink::ResponseBase::open ( OpenMode  mode)
override

◆ close()

void RestLink::ResponseBase::close ( )
override

◆ pos()

qint64 RestLink::ResponseBase::pos ( ) const
override

◆ size()

qint64 RestLink::ResponseBase::size ( ) const
override

◆ seek()

bool RestLink::ResponseBase::seek ( qint64  pos)
override

◆ atEnd()

bool RestLink::ResponseBase::atEnd ( ) const
override

◆ reset()

bool RestLink::ResponseBase::reset ( )
override

◆ bytesAvailable()

qint64 RestLink::ResponseBase::bytesAvailable ( ) const
override

◆ bytesToWrite()

qint64 RestLink::ResponseBase::bytesToWrite ( ) const
override

◆ canReadLine()

bool RestLink::ResponseBase::canReadLine ( ) const
override

◆ waitForReadyRead()

bool RestLink::ResponseBase::waitForReadyRead ( int  msecs)
override

◆ waitForBytesWritten()

bool RestLink::ResponseBase::waitForBytesWritten ( int  msecs)
override

◆ readJsonObject()

QJsonObject RestLink::ResponseBase::readJsonObject ( QJsonParseError *  error = nullptr)
virtual

Reads the response body as a JSON object.

Parameters
errorAn optional pointer to a QJsonParseError to capture any parsing errors.
Returns
The response body as a QJsonObject.

Reimplemented in RestLink::ServerResponse.

◆ readJsonArray()

QJsonArray RestLink::ResponseBase::readJsonArray ( QJsonParseError *  error = nullptr)
virtual

Reads the response body as a JSON array.

Parameters
errorAn optional pointer to a QJsonParseError to capture any parsing errors.
Returns
The response body as a QJsonArray.

Reimplemented in RestLink::ServerResponse.

◆ readJson()

QJsonValue RestLink::ResponseBase::readJson ( QJsonParseError *  error = nullptr)
virtual

Reads the response body as a JSON value.

Parameters
errorAn optional pointer to a QJsonParseError to capture any parsing errors.
Returns
The response body as a QJsonValue.

Reimplemented in RestLink::ServerResponse.

◆ readString()

QString RestLink::ResponseBase::readString ( )
virtual

Reads the response body as a QString.

Returns
The response body as a QString.

Reimplemented in RestLink::ServerResponse.

◆ readBody()

QByteArray RestLink::ResponseBase::readBody ( )
virtual

Reads the raw response body as a QByteArray.

Returns
The response body as a QByteArray.

Reimplemented in RestLink::NetworkResponse, and RestLink::ServerResponse.

◆ responseDevice()

QIODevice * RestLink::ResponseBase::responseDevice ( ) const

◆ readData()

qint64 RestLink::ResponseBase::readData ( char *  data,
qint64  maxlen 
)
overrideprotected

◆ readLineData()

qint64 RestLink::ResponseBase::readLineData ( char *  data,
qint64  maxlen 
)
overrideprotected

◆ skipData()

qint64 RestLink::ResponseBase::skipData ( qint64  maxSize)
overrideprotected

◆ writeData()

qint64 RestLink::ResponseBase::writeData ( const char *  data,
qint64  len 
)
overrideprotected

◆ setResponseDevice()

void RestLink::ResponseBase::setResponseDevice ( QIODevice *  device)
protected