QtRestClient
3.0.0
A library for generic JSON-based REST-APIs, with a mechanism to map JSON to Qt objects
|
Interface to parse generic paging objects and operate on them. More...
#include <ipaging.h>
Public Member Functions | |
virtual std::variant< QCborArray, QJsonArray > | items () const =0 |
Returns the items of this paging object, i.e. it's data. | |
virtual qint64 | total () const |
Returns the total number of objects there are. More... | |
virtual qint64 | offset () const |
Returns the offset this paging begins at. More... | |
virtual bool | hasNext () const =0 |
Returns true, if there is a next paging object. | |
virtual QUrl | next () const =0 |
Returns the link to the next paging object. | |
virtual bool | hasPrevious () const |
Returns true, if there is a previous paging object. | |
virtual QUrl | previous () const |
Returns the link to the previous paging object. | |
virtual QVariantMap | properties () const =0 |
Returns a hash containing all properties of the original JSON. | |
virtual std::variant< QCborValue, QJsonValue > | originalData () const =0 |
Returns the original JSON element parsed. | |
Interface to parse generic paging objects and operate on them.
Implement this interface, as well as a custom IPagingFactory, if you need to parse a non standard paging object. You should implement all of the methods correctly. However, you can still use the paging if you can't provide all of them. Simply return default values in that case. However, if you want to use the iterate functionality of the paging, you will have to implement all of them.
The standard implementation expects CBOR or JSON data of the following format and will return either a ICborPaging or a IJsonPaging object:
Additional fields will be ignored, but are still a valid paging objects. Missing fields or incompatibale types are not allowed, but wont create an error here. Validation is done by IPagingFactory::createPaging
|
virtual |
Returns the offset this paging begins at.
-1
if not availableTypically, pagings have indexes. However, since next() alone is sufficient to use a paging, not all may support it. Indexes means, that any item in a paging has a logical index, to identify it idependently of the paging object it is in. It's the real item index on the server. To do so, the offset of the first item in the paging must be known.
If your paging does support indexes, you must implement the offset() method to return the offset of the first element in the paging.
|
virtual |
Returns the total number of objects there are.
std::numeric_limits<qint64>::max()
if not availableIf you implement total, please note that total means total independently of the paging, and not the number of elements in the paging. It's the maximum number of items that exist for this request on the server.