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 = (10 - 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;
92 for(
int paramId = 0; paramId < parameters.size(); paramId++)
108 if(parameter.
Type.find(
"array") != std::string::npos)
110 std::cout << spaces <<
"Parameter #" << paramId <<
": array" << std::endl;
111 if(parameterName !=
"")
113 std::cout <<
" (" << parameterName <<
")";
116 std::vector<GbxResponseParameter> arrayParam = parameter.
GetArray();
117 for(
int subParamId = 0; subParamId < arrayParam.size(); subParamId++)
123 else if(parameter.
Type.find(
"struct") != std::string::npos)
125 std::cout << spaces <<
"Parameter #" << paramId <<
": struct" << std::endl;
126 if(parameterName !=
"")
128 std::cout <<
" (" << parameterName <<
")";
131 std::map<std::string, GbxResponseParameter> structParam = parameter.
GetStruct();
133 for(std::map<std::string, GbxResponseParameter>::iterator subParam = structParam.begin(); subParam != structParam.end(); ++subParam)
135 PrintParameter(subParam->second, subParamId, spaces, subParam->first);
141 std::cout << spaces <<
"Parameter #" << paramId <<
": " << parameter.
GetString() <<
" (" << parameter.
Type <<
")";
142 if(parameterName !=
"")
144 std::cout <<
" (" << parameterName <<
")";
146 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:106
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
static void PrintParameters(std::vector< GbxResponseParameter > parameters)
Prints a vector with GbxResponseParameter objects (for DEBUG purposes).
Definition: Logging.h:90
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