Unity Scopes API
|
Class that downloads http XML files asynchronously. More...
#include <unity/scopes/qt/XmlAsyncReader.h>
Public Member Functions | |
template<typename BASE , typename TYPE > | |
ResultsFuture< BASE > | async_get (std::string const &uri, std::string const &object_name, ParserFunc< BASE > const &parse=get_results< BASE, TYPE >) const |
Downloads a HTTP XML remote file asynchronously and returns a future to a list of results This method downloads in a separated thread a http document identified by the given URI. It returns a future of list of results based on a given object name. If, for example, the document contains a list of objects identified by the tag "ITEM" it parses the document and returns a list of those objects. More... | |
template<typename T > | |
ResultsFuture< T > | async_get (std::string const &uri, std::string const &object_name, ParserFunc< T > const &parse=get_results< T, T >) const |
Downloads a XML HTTP remote file asynchronously and returns a future to a list of results This method downloads in a separated thread a http document identified by the given URI. It returns a future of list of results based on a given object name. If, for example, the document contains a list of objects identified by the tag "ITEM" it parses the document and returns a list of those objects. The user must provide a function to create the parser for the downloaded data and a parse function that retrieves the data. More... | |
template<typename BASE , typename TYPE > | |
ResultsFuture< BASE > | async_get (std::string const &host, QXmlStreamReaderParams const ¶ms, std::string const &object_name, ParserFunc< BASE > const &parse=get_results< BASE, TYPE >) const |
Downloads a HTTP XML remote file asynchronously and returns a future to a list of results This method downloads in a separated thread a http document identified by the given URI. It returns a future of list of results based on a given object name. If, for example, the document contains a list of objects identified by the tag "ITEM" it parses the document and returns a list of those objects. More... | |
template<typename T > | |
ResultsFuture< T > | async_get (std::string const &host, QXmlStreamReaderParams const ¶ms, std::string const &object_name, ParserFunc< T > const &parse=get_results< T, T >) const |
Downloads a HTTP XML remote file asynchronously and returns a future to a list of results This method downloads in a separated thread a http document identified by the given URI. It returns a future of list of results based on a given object name. If, for example, the document contains a list of objects identified by the tag "ITEM" it parses the document and returns a list of those objects. More... | |
QXmlStreamReaderFuture | async_get_parser (std::string const &uri) const |
Downloads a HTTP remote file asynchronously and returns a future to a valid XML parser containing the data. More... | |
QXmlStreamReaderFuture | async_get_parser (std::string const &host, QXmlStreamReaderParams const ¶ms) const |
Downloads a HTTP remote file asynchronously and returns a future to a valid XML parser containing the data. More... | |
Static Protected Member Functions | |
static QXmlStreamReaderSptr | create_parser_with_data (std::string const &data, std::string &error) |
Creates a QXmlStreamReader filled with the given data. More... | |
Class that downloads http XML files asynchronously.
Executes a remote HTTP query asynchronously to return different futures about XML results or a XML parser. The class implements and defines a function that returns a XML parser filled with the data downloaded. The class also offers a default function to obtain all objects of a given name in the results. The user may define his own parsing function to parse data at he desires.
XmlAsyncReader::ResultsFuture< BASE > unity::scopes::qt::XmlAsyncReader::async_get | ( | std::string const & | uri, |
std::string const & | object_name, | ||
ParserFunc< BASE > const & | parse = get_results<BASE, TYPE> |
||
) | const |
Downloads a HTTP XML remote file asynchronously and returns a future to a list of results This method downloads in a separated thread a http document identified by the given URI. It returns a future of list of results based on a given object name. If, for example, the document contains a list of objects identified by the tag "ITEM" it parses the document and returns a list of those objects.
The user may provide his own function to parse the downloaded data.
The method has 2 template parameters: the type of results returned and the type of objects when instantiating. The type of instantiation has to be a derived class of the return type. This is offered for convenience to return more generic types and get advantage of polymorphism.
The method checks at compile time that the instantiation type is effectively a derived class of the type returned.
uri | URI to download |
object_name | name of the kind of object we are looking for in the http document |
parse | Function that parses the data downloaded |
XmlAsyncReader::ResultsFuture< T > unity::scopes::qt::XmlAsyncReader::async_get | ( | std::string const & | uri, |
std::string const & | object_name, | ||
ParserFunc< T > const & | parse = get_results<T, T> |
||
) | const |
Downloads a XML HTTP remote file asynchronously and returns a future to a list of results This method downloads in a separated thread a http document identified by the given URI. It returns a future of list of results based on a given object name. If, for example, the document contains a list of objects identified by the tag "ITEM" it parses the document and returns a list of those objects. The user must provide a function to create the parser for the downloaded data and a parse function that retrieves the data.
The method has 1 template parameter: the type of objects returned and the parser type.
uri | URI to download |
object_name | name of the kind of object we are looking for in the http document |
parse | Function that parses the data downloaded |
XmlAsyncReader::ResultsFuture< BASE > unity::scopes::qt::XmlAsyncReader::async_get | ( | std::string const & | host, |
QXmlStreamReaderParams const & | params, | ||
std::string const & | object_name, | ||
ParserFunc< BASE > const & | parse = get_results<BASE, TYPE> |
||
) | const |
Downloads a HTTP XML remote file asynchronously and returns a future to a list of results This method downloads in a separated thread a http document identified by the given URI. It returns a future of list of results based on a given object name. If, for example, the document contains a list of objects identified by the tag "ITEM" it parses the document and returns a list of those objects.
The user may provide his own function to parse the downloaded data.
The method has 2 template parameters: the type of results returned and the type of objects when intantiating. The type of instantiation has to be a derived class of the return type. This is offered for convenience to return more generic types and get advantage of polymorphism.
The method checks at compile time that the instantiation type is effectively a derived class of the type returned.
host | the remote host name |
params | The parameters that will build the final query, defined by a list of pairs of key and value |
object_name | name of the kind of object we are looking for in the http document |
parse | Function that parses the data downloaded |
XmlAsyncReader::ResultsFuture< T > unity::scopes::qt::XmlAsyncReader::async_get | ( | std::string const & | host, |
QXmlStreamReaderParams const & | params, | ||
std::string const & | object_name, | ||
ParserFunc< T > const & | parse = get_results<T, T> |
||
) | const |
Downloads a HTTP XML remote file asynchronously and returns a future to a list of results This method downloads in a separated thread a http document identified by the given URI. It returns a future of list of results based on a given object name. If, for example, the document contains a list of objects identified by the tag "ITEM" it parses the document and returns a list of those objects.
The user may provide his own function to parse the downloaded data.
The method has 1 template parameters: the type of results returned.
The method checks at compile time that the instantiation type is effectively a derived class of the type returned.
host | the remote host name |
params | The parameters that wlll build the final query, defined by a list of pairs of key and value |
object_name | name of the kind of object we are looking for in the http document |
parse | Function that parses the data downloaded |
QXmlStreamReaderFuture unity::scopes::qt::XmlAsyncReader::async_get_parser | ( | std::string const & | uri | ) | const |
Downloads a HTTP remote file asynchronously and returns a future to a valid XML parser containing the data.
This method downloads a remote http document, fills a valid QXmlStreamReader parser with the downloaded data and returns a future to the parser.
uri | URI to download |
QXmlStreamReaderFuture unity::scopes::qt::XmlAsyncReader::async_get_parser | ( | std::string const & | host, |
QXmlStreamReaderParams const & | params | ||
) | const |
Downloads a HTTP remote file asynchronously and returns a future to a valid XML parser containing the data.
This method downloads a remote http document, fills a valid QXmlStreamReader parser with the downloaded data and returns a future to the parser.
host | host name |
params | The parameters that will build the final query, defined by a list of pairs of key and value |
|
staticprotected |
Creates a QXmlStreamReader filled with the given data.
data | The data that contains the XML document |
error | Returned by the method, contains any possible error string obtained during the creation of the parser. |