QtRestClient
3.0.0
A library for generic JSON-based REST-APIs, with a mechanism to map JSON to Qt objects
|
A class to access generic paging objects. More...
#include <paging_fwd.h>
Public Member Functions | |
Paging () | |
Default Constructor. | |
Paging (const Paging< T > &other) | |
Copy Constructor. | |
Paging (Paging< T > &&other) noexcept | |
Move Constructor. | |
Paging< T > & | operator= (const Paging< T > &other) |
Copy assignment operator. | |
Paging< T > & | operator= (Paging< T > &&other) noexcept |
Move assignment operator. | |
Paging (IPaging *iPaging, const QList< T > &data, RestClient *client) | |
Constructs a paging from the interface, the data and a client. | |
bool | isValid () const |
Returns true, if the current paging object is a valid one. | |
IPaging * | iPaging () const |
Returns the internally used IPaging instance. | |
QList< T > | items () const |
Returns the items of this paging object, i.e. it's data. | |
qint64 | total () const |
Returns the total number of objects there are. | |
qint64 | offset () const |
Returns the offset this paging begins at. | |
bool | hasNext () const |
Returns true, if there is a next paging object. | |
template<typename EO = QObject*> | |
GenericRestReply< Paging< T >, EO > * | next () const |
Performs a request for the next paging object. | |
QUrl | nextUrl () const |
Returns the link to the next paging object. | |
bool | hasPrevious () const |
Returns true, if there is a previous paging object. | |
template<typename EO = QObject*> | |
GenericRestReply< Paging< T >, EO > * | previous () const |
Performs a request for the previous paging object. | |
QUrl | previousUrl () const |
Returns the link to the previous paging object. | |
void | iterate (const std::function< bool(T, qint64)> &iterator, qint64 to=-1, qint64 from=0) const |
Iterates over all paging objects. More... | |
void | iterate (QObject *scope, const std::function< bool(T, qint64)> &iterator, qint64 to=-1, qint64 from=0) const |
Iterates over all paging objects. More... | |
template<typename EO = QObject*> | |
void | iterate (const std::function< bool(T, qint64)> &iterator, const std::function< void(QString, int, RestReply::Error)> &errorHandler, const std::function< QString(EO, int)> &failureTransformer={}, qint64 to=-1, qint64 from=0) const |
Iterates over all paging objects, with error handling. More... | |
template<typename EO = QObject*> | |
void | iterate (QObject *scope, const std::function< bool(T, qint64)> &iterator, const std::function< void(QString, int, RestReply::Error)> &errorHandler, const std::function< QString(EO, int)> &failureTransformer={}, qint64 to=-1, qint64 from=0) const |
Iterates over all paging objects, with error handling. More... | |
template<typename EO = QObject*> | |
void | iterate (const std::function< bool(T, qint64)> &iterator, const std::function< void(int, EO)> &failureHandler, const std::function< void(QString, int, RestReply::Error)> &errorHandler={}, const std::function< void(QtJsonSerializer::Exception &)> &exceptionHandler={}, qint64 to=-1, qint64 from=0) const |
Iterates over all paging objects, with error handling. More... | |
template<typename EO = QObject*> | |
void | iterate (QObject *scope, const std::function< bool(T, qint64)> &iterator, const std::function< void(int, EO)> &failureHandler, const std::function< void(QString, int, RestReply::Error)> &errorHandler={}, const std::function< void(QtJsonSerializer::Exception &)> &exceptionHandler={}, qint64 to=-1, qint64 from=0) const |
Iterates over all paging objects, with error handling. More... | |
QVariantMap | properties () const |
Returns a hash containing all properties of the original JSON. | |
void | deleteAllItems () const |
Deletes all items this paging object is holding (QObjects only) | |
A class to access generic paging objects.
T | The type the paging object is wrapping |
The paging class is a container class that allows you to access generic paging mechanisms.
Typically, APIs use paging as a method to reduce the size of replies. Instead of returning a complete list of elements, only a small chunck (i.e. 10 Elements) is returned, wrapped into a paging object. The object itself containes links, indexes and more to make it possible to iterate over them, by sending multiple consecutive requests.
While most of these paging objects are very similar, they can have different structures. The Paging class, in combination with the IPaging interface, allows you to access any paging mechanism in an easy manner.
Definition at line 30 of file paging_fwd.h.
QtRestClient::Paging< T >::iterate | ( | const std::function< bool(T, qint64)> & | iterator, |
const std::function< void(int, EO)> & | failureHandler, | ||
const std::function< void(QString, int, RestReply::Error)> & | errorHandler = {} , |
||
const std::function< void(QtJsonSerializer::Exception &)> & | exceptionHandler = {} , |
||
qint64 | to = -1 , |
||
qint64 | from = 0 |
||
) | const |
Iterates over all paging objects, with error handling.
EO | The type of the negative result |
failureHandler | Will be passed to GenericRestReply::onFailed for all replies |
errorHandler | Will be passed to GenericRestReply::onError for all replies |
exceptionHandler | Will be passed to GenericRestReply::onSerializeException for all replies |
iterator | The iterator to be be called for every element iterated over |
to | The upper limit of how far the iteration should go (-1 means no limit) |
from | The lower limit from where the iteration should start |
The paging object will iterate over all it's elements and then automatically call next(), and perform an iteration on the result of that reply as well. This continues until no next element is available anymore or the iterator returns false
to cancel early.
By setting to
, you can specify a limit. As soon as the iteration reaches the element with an index that equals the limit, the iteration is canceled. The element at the to
index will not** be passed to the iterator.
By setting from
, you can specify an offset. The iteration will skip all elements, until the index reaches the offset. The element with the from
index is the first to be passed to the iterator. Please note, that from
must not be smaller then Paging::offset. If thats the case, this function will assert.
to
and from
will have no effect.The iterators parameters are:
true
if the iteration should continue, false
to cancel it prematurely QtRestClient::Paging< T >::iterate | ( | const std::function< bool(T, qint64)> & | iterator, |
const std::function< void(QString, int, RestReply::Error)> & | errorHandler, | ||
const std::function< QString(EO, int)> & | failureTransformer = {} , |
||
qint64 | to = -1 , |
||
qint64 | from = 0 |
||
) | const |
Iterates over all paging objects, with error handling.
EO | The type of the negative result |
errorHandler | Will be passed to GenericRestReply::onAllErrors for all replies |
failureTransformer | Will be passed to GenericRestReply::onAllErrors for all replies |
iterator | The iterator to be be called for every element iterated over |
to | The upper limit of how far the iteration should go (-1 means no limit) |
from | The lower limit from where the iteration should start |
The paging object will iterate over all it's elements and then automatically call next(), and perform an iteration on the result of that reply as well. This continues until no next element is available anymore or the iterator returns false
to cancel early.
By setting to
, you can specify a limit. As soon as the iteration reaches the element with an index that equals the limit, the iteration is canceled. The element at the to
index will not** be passed to the iterator.
By setting from
, you can specify an offset. The iteration will skip all elements, until the index reaches the offset. The element with the from
index is the first to be passed to the iterator. Please note, that from
must not be smaller then Paging::offset. If thats the case, this function will assert.
to
and from
will have no effect.The iterators parameters are:
true
if the iteration should continue, false
to cancel it prematurely QtRestClient::Paging< T >::iterate | ( | const std::function< bool(T, qint64)> & | iterator, |
qint64 | to = -1 , |
||
qint64 | from = 0 |
||
) | const |
Iterates over all paging objects.
iterator | The iterator to be be called for every element iterated over |
to | The upper limit of how far the iteration should go (-1 means no limit) |
from | The lower limit from where the iteration should start |
The paging object will iterate over all it's elements and then automatically call next(), and perform an iteration on the result of that reply as well. This continues until no next element is available anymore or the iterator returns false
to cancel early.
By setting to
, you can specify a limit. As soon as the iteration reaches the element with an index that equals the limit, the iteration is canceled. The element at the to
index will not** be passed to the iterator.
By setting from
, you can specify an offset. The iteration will skip all elements, until the index reaches the offset. The element with the from
index is the first to be passed to the iterator. Please note, that from
must not be smaller then Paging::offset. If thats the case, this function will assert.
to
and from
will have no effect.The iterators parameters are:
true
if the iteration should continue, false
to cancel it prematurely QtRestClient::Paging< T >::iterate | ( | QObject * | scope, |
const std::function< bool(T, qint64)> & | iterator, | ||
const std::function< void(int, EO)> & | failureHandler, | ||
const std::function< void(QString, int, RestReply::Error)> & | errorHandler = {} , |
||
const std::function< void(QtJsonSerializer::Exception &)> & | exceptionHandler = {} , |
||
qint64 | to = -1 , |
||
qint64 | from = 0 |
||
) | const |
Iterates over all paging objects, with error handling.
scope | A scope to limit the callback to |
EO | The type of the negative result |
failureHandler | Will be passed to GenericRestReply::onFailed for all replies |
errorHandler | Will be passed to GenericRestReply::onError for all replies |
exceptionHandler | Will be passed to GenericRestReply::onSerializeException for all replies |
iterator | The iterator to be be called for every element iterated over |
to | The upper limit of how far the iteration should go (-1 means no limit) |
from | The lower limit from where the iteration should start |
The paging object will iterate over all it's elements and then automatically call next(), and perform an iteration on the result of that reply as well. This continues until no next element is available anymore or the iterator returns false
to cancel early.
By setting to
, you can specify a limit. As soon as the iteration reaches the element with an index that equals the limit, the iteration is canceled. The element at the to
index will not** be passed to the iterator.
By setting from
, you can specify an offset. The iteration will skip all elements, until the index reaches the offset. The element with the from
index is the first to be passed to the iterator. Please note, that from
must not be smaller then Paging::offset. If thats the case, this function will assert.
to
and from
will have no effect.The iterators parameters are:
true
if the iteration should continue, false
to cancel it prematurely QtRestClient::Paging< T >::iterate | ( | QObject * | scope, |
const std::function< bool(T, qint64)> & | iterator, | ||
const std::function< void(QString, int, RestReply::Error)> & | errorHandler, | ||
const std::function< QString(EO, int)> & | failureTransformer = {} , |
||
qint64 | to = -1 , |
||
qint64 | from = 0 |
||
) | const |
Iterates over all paging objects, with error handling.
scope | A scope to limit the callback to |
EO | The type of the negative result |
errorHandler | Will be passed to GenericRestReply::onAllErrors for all replies |
failureTransformer | Will be passed to GenericRestReply::onAllErrors for all replies |
iterator | The iterator to be be called for every element iterated over |
to | The upper limit of how far the iteration should go (-1 means no limit) |
from | The lower limit from where the iteration should start |
The paging object will iterate over all it's elements and then automatically call next(), and perform an iteration on the result of that reply as well. This continues until no next element is available anymore or the iterator returns false
to cancel early.
By setting to
, you can specify a limit. As soon as the iteration reaches the element with an index that equals the limit, the iteration is canceled. The element at the to
index will not** be passed to the iterator.
By setting from
, you can specify an offset. The iteration will skip all elements, until the index reaches the offset. The element with the from
index is the first to be passed to the iterator. Please note, that from
must not be smaller then Paging::offset. If thats the case, this function will assert.
to
and from
will have no effect.The iterators parameters are:
true
if the iteration should continue, false
to cancel it prematurely QtRestClient::Paging< T >::iterate | ( | QObject * | scope, |
const std::function< bool(T, qint64)> & | iterator, | ||
qint64 | to = -1 , |
||
qint64 | from = 0 |
||
) | const |
Iterates over all paging objects.
scope | A scope to limit the callback to |
iterator | The iterator to be be called for every element iterated over |
to | The upper limit of how far the iteration should go (-1 means no limit) |
from | The lower limit from where the iteration should start |
The paging object will iterate over all it's elements and then automatically call next(), and perform an iteration on the result of that reply as well. This continues until no next element is available anymore or the iterator returns false
to cancel early.
By setting to
, you can specify a limit. As soon as the iteration reaches the element with an index that equals the limit, the iteration is canceled. The element at the to
index will not** be passed to the iterator.
By setting from
, you can specify an offset. The iteration will skip all elements, until the index reaches the offset. The element with the from
index is the first to be passed to the iterator. Please note, that from
must not be smaller then Paging::offset. If thats the case, this function will assert.
to
and from
will have no effect.The iterators parameters are:
true
if the iteration should continue, false
to cancel it prematurely