6 #include "../GbxRemote/GbxStructs.h"
7 #include "../GbxRemote/ServerResponse/GbxServerResponse.h"
23 std::stringstream numberString;
24 numberString << error.
number;
25 const char* errorNumber = numberString.str().c_str();
26 int errorNumberLength = strlen(errorNumber);
27 int spaces = (9 - errorNumberLength);
31 double halfSpaces = ((double)spaces / 2);
33 std::stringstream output;
34 output <<
"[\033[0;31m";
35 for(
int i = 0; i < ceil(halfSpaces); i++)
40 for(
int i = 0; i < floor(halfSpaces); i++)
45 output <<
"\033[0;0m] ERROR: " + error.
message;
47 std::cout << output.str() << std::endl;
51 std::cout <<
"[\033[0;31m" << errorNumber <<
"\033[0;0m] ERROR: " << error.
message << std::endl;
74 std::cout <<
"[ \033[0;32mOK.\033[0;0m" << std::endl;
82 std::cout <<
"[ \033[0;31mFAILED!\033[0;0m" << std::endl;
95 if(parameter.
Type.find(
"array") != std::string::npos)
97 std::cout << spaces <<
"Parameter #" << paramId <<
": array" << std::endl;
99 std::vector<GbxResponseParameter> arrayParam = parameter.
GetArray();
100 for(
int subParamId = 0; subParamId < arrayParam.size(); subParamId++)
106 else if(parameter.
Type.find(
"struct") != std::string::npos)
108 std::cout << spaces <<
"Parameter #" << paramId <<
": struct" << std::endl;
110 std::map<std::string, GbxResponseParameter> structParam = parameter.
GetStruct();
112 for(std::map<std::string, GbxResponseParameter>::iterator subParam = structParam.begin(); subParam != structParam.end(); ++subParam)
114 PrintParameter(subParam->second, subParamId, spaces, subParam->first);
120 std::cout << spaces <<
"Parameter #" << paramId <<
": " << parameter.
GetString() <<
" (" << parameter.
Type <<
")";
121 if(parameterName !=
"")
123 std::cout <<
" (" << parameterName <<
")";
125 std::cout << std::endl;
std::vector< GbxResponseParameter > GetArray()
Gets the value as vector of parameters.
Definition: GbxServerResponse.h:28
Utility to print information to the console.
Definition: Logging.h:13
std::string GetString()
Gets the value as string.
Definition: GbxServerResponse.h:54
static void PrintParameter(GbxResponseParameter parameter, int paramId, std::string spaces=" ", std::string parameterName="")
Prints a GbxResponseParameter (for DEBUG purposes).
Definition: Logging.h:93
int number
Number of the error (default: 0, no error).
Definition: GbxStructs.h:29
std::string message
Error message.
Definition: GbxStructs.h:30
static void PrintError(GbxError error)
Prints error to console.
Definition: Logging.h:21
std::string Type
XML-RPC data type.
Definition: GbxServerResponse.h:20
static void PrintOKFlush()
Prints OK. in [ ]-spaces in console.
Definition: Logging.h:72
Stores error details from the communication with the server.
Definition: GbxStructs.h:27
std::map< std::string, GbxResponseParameter > GetStruct()
Gets the value as map of parameters.
Definition: GbxServerResponse.h:41
static void PrintFailedFlush()
Prints Failed! in [ ]-spaces in console.
Definition: Logging.h:80
Parameter deducted from server response.
Definition: GbxServerResponse.h:17
static void PrintError(int number, std::string message)
Prints error to console.
Definition: Logging.h:61