unity.scopes.qt.XmlAsyncReader

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 &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. More...
 
template<typename T >
ResultsFuture< T > 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. 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 &params) 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...
 

Detailed Description

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.

Member Function Documentation

template<typename BASE , typename TYPE >
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.

Parameters
uriURI to download
object_namename of the kind of object we are looking for in the http document
parseFunction that parses the data downloaded
Returns
Future of list of results
template<typename T >
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.

Parameters
uriURI to download
object_namename of the kind of object we are looking for in the http document
parseFunction that parses the data downloaded
Returns
Future of list of results
template<typename BASE , typename TYPE >
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.

Parameters
hostthe remote host name
paramsThe parameters that will build the final query, defined by a list of pairs of key and value
object_namename of the kind of object we are looking for in the http document
parseFunction that parses the data downloaded
Returns
Future of list of results
template<typename T >
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.

Parameters
hostthe remote host name
paramsThe parameters that wlll build the final query, defined by a list of pairs of key and value
object_namename of the kind of object we are looking for in the http document
parseFunction that parses the data downloaded
Returns
Future of list of results
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.

Parameters
uriURI to download
Returns
Future of valid parser filled with the data downloaded
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.

Parameters
hosthost name
paramsThe parameters that will build the final query, defined by a list of pairs of key and value
Returns
Future of valid parser filled with the data downloaded
static QXmlStreamReaderSptr unity::scopes::qt::XmlAsyncReader::create_parser_with_data ( std::string const &  data,
std::string &  error 
)
staticprotected

Creates a QXmlStreamReader filled with the given data.

Parameters
dataThe data that contains the XML document
errorReturned by the method, contains any possible error string obtained during the creation of the parser.
Returns
shared pointer to the QXmlStreamReader created