SuperTuxKart
Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
Online::XMLRequest Class Reference

A http request expecting a xml return value. More...

#include <xml_request.hpp>

Inheritance diagram for Online::XMLRequest:
Inheritance graph
[legend]

Public Member Functions

 XMLRequest (int priority=1)
 Creates a HTTP(S) request that will automatically parse the answer into a XML structure. More...
 
virtual ~XMLRequest ()
 Cleans up the XML tree. More...
 
const XMLNodegetXMLData () const
 Get the downloaded XML tree. More...
 
const irr::core::stringw & getInfo () const
 Returns the additional information (or error message) contained in a finished request. More...
 
bool isSuccess () const
 Returns whether the request was successfully executed on the server. More...
 
- Public Member Functions inherited from Online::HTTPRequest
 HTTPRequest (int priority=1)
 Creates a HTTP(S) request that will have a raw string as result. More...
 
 HTTPRequest (const std::string &filename, int priority=1)
 This constructor configures this request to save the data in a flie. More...
 
 HTTPRequest (const char *const filename, int priority=1)
 Char * needs a separate constructor, otherwise it will be considered to be the no-filename constructor (char* -> bool).
 
virtual bool isAllowedToAdd () const OVERRIDE
 Checks the request if it has enough (correct) information to be executed (and thus allowed to add to the queue).
 
void setApiURL (const std::string &url, const std::string &action)
 A handy shortcut that appends the given path to the URL of the mutiplayer server. More...
 
void setAddonsURL (const std::string &path)
 A handy shortcut that appends the given path to the URL of the addons server. More...
 
bool hadDownloadError () const
 Returns true if there was an error downloading the file. More...
 
void setDownloadAssetsRequest (bool val)
 
const char * getDownloadErrorMessage () const
 Returns the curl error message if an error has occurred. More...
 
const std::string & getData () const
 Returns the downloaded string. More...
 
void addParameter (const std::string &name, const std::string &value)
 Sets a parameter to 'value' (std::string). More...
 
void addParameter (const std::string &name, const irr::core::stringw &value)
 Sets a parameter to 'value' (stringw). More...
 
template<typename T >
void addParameter (const std::string &name, const T &value)
 Sets a parameter to 'value' (arbitrary types). More...
 
float getProgress () const
 Returns the current progress. More...
 
void setProgress (float f)
 Sets the current progress. More...
 
const std::string & getURL () const
 
void setURL (const std::string &url)
 Sets the URL for this request. More...
 
const std::string & getFileName () const
 
double getTotalSize () const
 
void setTotalSize (double d)
 
- Public Member Functions inherited from Online::Request
 Request (int priority, int type)
 Creates a request that can be handled by the RequestManager. More...
 
void execute ()
 Executes the request. More...
 
void executeNow ()
 Executes the request now, i.e. More...
 
void queue ()
 Inserts this request into the RequestManager's queue for executing.
 
virtual void callback ()
 Executed when a request has finished. More...
 
int getType () const
 Returns the type of the request. More...
 
int getPriority () const
 Returns the priority of this request. More...
 
void cancel ()
 Signals that this request should be canceled. More...
 
bool isCancelled () const
 Returns if this request is to be canceled. More...
 
bool isAbortable () const
 Returns if this request can be aborted. More...
 
void setAbortable (bool b)
 Sets if this request is abortable or not. More...
 
void setBusy ()
 Sets the request state to busy. More...
 
void setExecuted ()
 Sets the request to be completed. More...
 
void setDone ()
 Should only be called by the manager.
 
bool isDone () const
 Returns if this request is done. More...
 
bool isPreparing () const
 Returns if this request is being prepared. More...
 
bool isBusy () const
 Returns if this request is busy. More...
 
bool hasBeenExecuted () const
 Checks if the request has completed or done (i.e. More...
 

Protected Member Functions

virtual void afterOperation () OVERRIDE
 On a successful download converts the string into an XML tree.
 
- Protected Member Functions inherited from Online::HTTPRequest
virtual void prepareOperation () OVERRIDE
 Sets up the curl data structures.
 
virtual void operation () OVERRIDE
 The actual curl download happens here.
 
void init ()
 Initialises all member variables.
 

Protected Attributes

irr::core::stringw m_info
 Additional info contained the downloaded data (or an error message if a problem occurred). More...
 
bool m_success
 True if the request was successful executed on the server. More...
 
- Protected Attributes inherited from Online::HTTPRequest
std::string m_filename
 Contains a filename if the data should be saved into a file instead of being kept in in memory. More...
 
bool m_disable_sending_log
 
bool m_download_assets_request = false
 
- Protected Attributes inherited from Online::Request
Synchronised< bool > m_cancel
 Cancel this request if it is active. More...
 
Synchronised< bool > m_is_abortable
 If this request can be aborted (at the end of STK). More...
 
Synchronised< Statem_state
 Set to though if the reply of the request is in and callbacks are executed.
 

Private Attributes

XMLNodem_xml_data
 On a successful download contains the converted XML tree. More...
 

Additional Inherited Members

- Public Types inherited from Online::Request
enum  RequestType { RT_QUIT = 1 }
 
- Static Protected Member Functions inherited from Online::HTTPRequest
static int progressDownload (void *clientp, double dltotal, double dlnow, double ultotal, double ulnow)
 Callback function from curl: inform about progress. More...
 
static size_t writeCallback (void *contents, size_t size, size_t nmemb, void *userp)
 Callback from curl. More...
 

Detailed Description

A http request expecting a xml return value.

Constructor & Destructor Documentation

◆ XMLRequest()

Online::XMLRequest::XMLRequest ( int  priority = 1)

Creates a HTTP(S) request that will automatically parse the answer into a XML structure.

Parameters
priorityby what priority should the RequestManager take care of this request.

◆ ~XMLRequest()

Online::XMLRequest::~XMLRequest ( )
virtual

Cleans up the XML tree.

Member Function Documentation

◆ getInfo()

const irr::core::stringw& Online::XMLRequest::getInfo ( ) const
inline

Returns the additional information (or error message) contained in a finished request.

Precondition
request had to be executed.
Returns
get the info from the request reply

◆ getXMLData()

const XMLNode* Online::XMLRequest::getXMLData ( ) const
inline

Get the downloaded XML tree.

Precondition
request has to be executed.
Returns
get the complete result from the request reply.

◆ isSuccess()

bool Online::XMLRequest::isSuccess ( ) const
inline

Returns whether the request was successfully executed on the server.

Precondition
request had to be executed.
Returns
whether or not the request was a success.

Member Data Documentation

◆ m_info

irr::core::stringw Online::XMLRequest::m_info
protected

Additional info contained the downloaded data (or an error message if a problem occurred).

◆ m_success

bool Online::XMLRequest::m_success
protected

True if the request was successful executed on the server.

◆ m_xml_data

XMLNode* Online::XMLRequest::m_xml_data
private

On a successful download contains the converted XML tree.


The documentation for this class was generated from the following files: