SuperTuxKart
xml_request.hpp
1 // SuperTuxKart - a fun racing game with go-kart
2 // Copyright (C) 2011-2015 Joerg Henrichs
3 // 2013 Glenn De Jonghe
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 3
8 // of the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 
19 #ifndef HEADER_XML_REQUEST_HPP
20 #define HEADER_XML_REQUEST_HPP
21 
22 #include "online/http_request.hpp"
23 #include "utils/cpp2011.hpp"
24 #include "utils/synchronised.hpp"
25 
26 #include <assert.h>
27 #include <string>
28 
29 class XMLNode;
30 
31 namespace Online
32 {
35  class XMLRequest : public HTTPRequest
36  {
37  private:
40 
41  protected:
42 
45  irr::core::stringw m_info;
46 
48  bool m_success;
49 
50  virtual void afterOperation() OVERRIDE;
51 
52  public :
53  XMLRequest(int priority = 1);
54  virtual ~XMLRequest();
55 
56  // ------------------------------------------------------------------------
61  const XMLNode * getXMLData() const
62  {
63  assert(hasBeenExecuted());
64  return m_xml_data;
65  } // getXMLData
66 
67  // ------------------------------------------------------------------------
73  const irr::core::stringw & getInfo() const
74  {
75  assert(hasBeenExecuted());
76  return m_info;
77  } // getInfo
78 
79  // --------------------------------------------------------------------
83  bool isSuccess() const
84  {
85  assert(hasBeenExecuted());
86  return m_success;
87  } // isSuccess
88  }; // class XMLRequest
89 } //namespace Online
90 #endif // HEADER_XML_REQUEST_HPP
A http request.
Definition: http_request.hpp:46
bool hasBeenExecuted() const
Checks if the request has completed or done (i.e.
Definition: request.hpp:197
A http request expecting a xml return value.
Definition: xml_request.hpp:36
XMLNode * m_xml_data
On a successful download contains the converted XML tree.
Definition: xml_request.hpp:39
bool isSuccess() const
Returns whether the request was successfully executed on the server.
Definition: xml_request.hpp:83
const XMLNode * getXMLData() const
Get the downloaded XML tree.
Definition: xml_request.hpp:61
irr::core::stringw m_info
Additional info contained the downloaded data (or an error message if a problem occurred).
Definition: xml_request.hpp:45
virtual void afterOperation() OVERRIDE
On a successful download converts the string into an XML tree.
Definition: xml_request.cpp:53
bool m_success
True if the request was successful executed on the server.
Definition: xml_request.hpp:48
const irr::core::stringw & getInfo() const
Returns the additional information (or error message) contained in a finished request.
Definition: xml_request.hpp:73
utility class used to parse XML files
Definition: xml_node.hpp:48