Mania++
 All Classes Functions Variables Pages
GbxServerResponse.h
1 #ifndef GBXSERVERRESPONSE_H_
2 #define GBXSERVERRESPONSE_H_
3 
4 #include <stdlib.h>
5 #include <string>
6 #include <vector>
7 #include <sstream>
8 #include <iostream>
9 #include <map>
10 #include "../../../lib/pugixml/src/pugixml.hpp"
11 #include "../GbxStructs.h"
12 
13 //* GbxResponseParameter
18 {
19 public:
20  std::string Type;
21  std::vector<GbxResponseParameter> Array;
22  std::map<std::string, GbxResponseParameter> Struct;
23  std::string Text;
28  std::vector<GbxResponseParameter> GetArray()
29  {
30  if(Type.find("array") != std::string::npos)
31  {
32  return Array;
33  }
34 
35  return std::vector<GbxResponseParameter>();
36  }
37 
41  std::map<std::string, GbxResponseParameter> GetStruct()
42  {
43  if(Type.find("struct") != std::string::npos)
44  {
45  return Struct;
46  }
47 
48  return std::map<std::string, GbxResponseParameter>();
49  }
50 
54  std::string GetString()
55  {
56  if(Type.find("array") == std::string::npos &&
57  Type.find("struct") == std::string::npos)
58  {
59  return Text;
60  }
61 
62  return NULL;
63  }
64 };
65 
66 //* GbxServerResponse
71 {
72 public:
77 
83  void SetRaw(std::string response);
84 
88  std::string GetRaw();
89 
93  std::vector<GbxResponseParameter> GetParameters();
94 
95 protected:
96  std::string data;
97  std::vector<GbxResponseParameter> parameters = std::vector<GbxResponseParameter>();
102  GbxResponseParameter extractParam(pugi::xml_node param);
103 };
104 
105 #endif // GBXSERVERRESPONSE_H_
std::vector< GbxResponseParameter > GetArray()
Gets the value as vector of parameters.
Definition: GbxServerResponse.h:28
std::vector< GbxResponseParameter > GetParameters()
Returns the extracted parameters.
Definition: GbxServerResponse.cpp:21
std::string Text
Parameters as text.
Definition: GbxServerResponse.h:23
std::string GetString()
Gets the value as string.
Definition: GbxServerResponse.h:54
void SetRaw(std::string response)
Sets the raw message value.
Definition: GbxServerResponse.cpp:11
GbxServerResponse()
Empty constructor.
Definition: GbxServerResponse.cpp:6
std::map< std::string, GbxResponseParameter > Struct
Parameters as struct.
Definition: GbxServerResponse.h:22
std::vector< GbxResponseParameter > parameters
List of parameters.
Definition: GbxServerResponse.h:97
std::string Type
XML-RPC data type.
Definition: GbxServerResponse.h:20
std::string GetRaw()
Returns raw response (XML).
Definition: GbxServerResponse.cpp:16
GbxResponseParameter extractParam(pugi::xml_node param)
Extracts parameters from the raw data (XML).
Definition: GbxServerResponse.cpp:26
Response from server, de-XML-fies the response.
Definition: GbxServerResponse.h:70
std::string data
Raw response data.
Definition: GbxServerResponse.h:96
std::map< std::string, GbxResponseParameter > GetStruct()
Gets the value as map of parameters.
Definition: GbxServerResponse.h:41
std::vector< GbxResponseParameter > Array
Parameters as array.
Definition: GbxServerResponse.h:21
Parameter deducted from server response.
Definition: GbxServerResponse.h:17