QtRestClient  3.0.0
A library for generic JSON-based REST-APIs, with a mechanism to map JSON to Qt objects
Namespaces | Classes | Typedefs | Functions
QtRestClient Namespace Reference

The Namespace containing all classes of the QtRestClient module. More...

Namespaces

 Auth
 The namespace for the QNetworkAuth extensions.
 

Classes

class  AwaitedException
 An exception that is throw on errors when awaiting a RestReply. More...
 
class  GenericAwaitedException
 An exception that is throw on errors when awaiting a GenericRestReply. More...
 
class  GenericRestReply
 A class to handle generic replies for generic requests. More...
 
class  GenericRestReply< Paging< DataClassType >, ErrorClassType >
 A class to handle generic replies for generic requests. More...
 
class  GenericRestReply< void, ErrorClassType >
 A class to handle generic replies for generic requests. More...
 
class  GenericRestReplyAwaitable
 A helper class to be used with QtCoroutines to await a generic rest reply. More...
 
class  GenericRestReplyAwaitable< void, ErrorClassType >
 A helper class to be used with QtCoroutines to await a generic rest reply. More...
 
class  GenericRestReplyBase
 The base class for GenericRestReply specializations. More...
 
class  ICborPaging
 Interface to parse generic CBOR paging objects and operate on them. More...
 
class  IJsonPaging
 Interface to parse generic JSON paging objects and operate on them. More...
 
class  IPaging
 Interface to parse generic paging objects and operate on them. More...
 
class  IPagingFactory
 A factory interface to create IPaging instances from raw data. More...
 
class  IPagingModelFetcher
 Interface for a component that fetches entries for the PagingModel. More...
 
class  Paging
 A class to access generic paging objects. More...
 
class  PagingModel
 A Qt item model that fills itself from a Paging object obtained via the network. More...
 
class  RequestBuilder
 A helper class to build QUrl and QNetworkRequest objects. More...
 
class  RestClass
 A class to perform requests to an API. More...
 
class  RestClassFetcher
 A default implementation for a IPagingModelFetcher, using a RestClass to send the requests. More...
 
class  RestClient
 A class to define access to an API, with general settings. More...
 
class  RestReply
 A class to handle replies for JSON requests. More...
 
class  RestReplyAwaitable
 A helper class to be used with QtCoroutines to await a rest reply. More...
 
class  Simple
 A base class to create a simply type version for a normal one. Check The QObject* or Q_GADGET version. More...
 
class  Simple< T *, std::enable_if_t< std::is_base_of_v< QObject, T > > >
 A base class to create a simply type version for a normal one. QObject* version. More...
 
class  Simple< T, std::enable_if_t< std::is_void_v< typename T::QtGadgetHelper > > >
 A base class to create a simply type version for a normal one. Q_GADGET version. More...
 

Typedefs

using HeaderHash = QHash< QByteArray, QByteArray >
 A typedef for a collection of HTTP request headers. More...
 
using ExceptionBase = QException
 The base class for exceptions of the module.
 

Functions

Q_RESTCLIENT_EXPORT bool addGlobalApi (const QString &name, RestClient *client)
 Makes the given API available under the given name. More...
 
Q_RESTCLIENT_EXPORT void removeGlobalApi (const QString &name, bool deleteClient=true)
 Removes a previously added API from the global list. More...
 
Q_RESTCLIENT_EXPORT RestClientapiClient (const QString &name)
 Returns the client for given API name. More...
 
Q_RESTCLIENT_EXPORT RestClassapiRootClass (const QString &name)
 Returns the clients root class for the given API name. More...
 
Q_RESTCLIENT_EXPORT RestClasscreateApiClass (const QString &name, const QString &path, QObject *parent=nullptr)
 Creates a new API class based on the client for the given API name. More...
 

Detailed Description

The Namespace containing all classes of the QtRestClient module.


Class Documentation

◆ QtRestClient::Simple

class QtRestClient::Simple

template<typename T, typename = void>
class QtRestClient::Simple< T, typename >

A base class to create a simply type version for a normal one. Check The QObject* or Q_GADGET version.

Definition at line 18 of file simple.h.

Typedef Documentation

◆ HeaderHash

A typedef for a collection of HTTP request headers.

See also
RestClient::globalHeaders, RequestBuilder::addHeaders, QNetworkRequest::setRawHeader

Definition at line 32 of file qtrestclient_global.h.

Function Documentation

◆ addGlobalApi()

bool QtRestClient::addGlobalApi ( const QString name,
RestClient client 
)

Makes the given API available under the given name.

Parameters
nameThe name to identify the API with. Use to obtain a reference to the API later on
clientThe RestClient to be registered
Returns
true if added, false if the name is already taken
Attention
QtRestClient takes ownership of the client, do not delete it after adding it
See also
RestClient, QtRestClient::apiClient, QtRestClient::removeGlobalApi

Definition at line 436 of file restclient.cpp.

◆ apiClient()

RestClient * QtRestClient::apiClient ( const QString name)

Returns the client for given API name.

Parameters
nameThe name of the root class to be returned
Returns
The RestClient for the given API name, or nullptr if no such API exists
See also
QtRestClient::addGlobalApi

Definition at line 479 of file restclient.cpp.

◆ apiRootClass()

RestClass * QtRestClient::apiRootClass ( const QString name)

Returns the clients root class for the given API name.

Parameters
nameThe name of the root class to be returned
Returns
The root RestClass for the given API name, or nullptr if no such API exists
See also
RestClient::rootClass, QtRestClient::createApiClass, QtRestClient::addGlobalApi

Definition at line 491 of file restclient.cpp.

◆ createApiClass()

RestClass * QtRestClient::createApiClass ( const QString name,
const QString path,
QObject parent = nullptr 
)

Creates a new API class based on the client for the given API name.

Parameters
nameThe name of the root class to be returned
pathThe path to be used for the RestClass
parentThe parent object for the created class
Returns
A newly created RestClass for the given API name, or nullptr if no such API exists
See also
RestClient::createClass, QtRestClient::apiRootClass, QtRestClient::addGlobalApi

Definition at line 509 of file restclient.cpp.

◆ removeGlobalApi()

void QtRestClient::removeGlobalApi ( const QString name,
bool  deleteClient = true 
)

Removes a previously added API from the global list.

Parameters
nameThe name of the API to be removed.
deleteClientSpecifies whether the removed client should be deleted

If you don't delete the client, It will be automatically deleted together with the QCoreApplication. If you don't want this, simply retake ownership by yourself:

auto client = QtRestClient::apiClient("name");
client->setParent(this);
See also
QtRestClient::addGlobalApi

Definition at line 462 of file restclient.cpp.

QtRestClient::apiClient
Q_RESTCLIENT_EXPORT RestClient * apiClient(const QString &name)
Returns the client for given API name.
Definition: restclient.cpp:479
QtRestClient::removeGlobalApi
Q_RESTCLIENT_EXPORT void removeGlobalApi(const QString &name, bool deleteClient=true)
Removes a previously added API from the global list.
Definition: restclient.cpp:462