libwolfram20

◆ parse()

void WAResult::parse ( rapidxml::xml_node<> *  query)
private

Parsing the input query.

Precondition
It must be called only once
Parameters
[in]queryXML Node of query
51 {
52 this->_error = nullptr;
53
54 if (strcmp(query->first_attribute("success")->value(), "false") == 0) {
55 this->_is_error = true;
56 return;
57 }
58
59 if (strcmp(query->first_attribute("error")->value(), "true") == 0) {
60 this->_is_error = true;
61 rapidxml::xml_node<>* error = query->first_node("error");
62 if (error != nullptr) this->_error = new WAError(error);
63 return;
64 }
65
66 this->_version = std::string( query->first_attribute("version")->value() );
67 this->_dataTypes = std::string( query->first_attribute("datatypes")->value() );
68 this->_timings = (Timings){ .parse = (float)atof(query->first_attribute("timing")->value()),
69 .generate = (float)atof(query->first_attribute("parsetiming")->value()) };
70 this->_timedout = WAResult::splitTimedout(query->first_attribute("timedout")->value());
71 if (this->getTimedoutNumber() > 0) this->_try_again = std::string( query->first_attribute("recalculate")->value() );
72
73 rapidxml::xml_node<>* node = query->first_node("pod");
74 for(size_t i = 0; i < atoi(query->first_attribute("numpods")->value()); i++) {
75 this->_pods.push_back(WAPod(node));
76 node = node->next_sibling("pod");
77 }
78
79 return;
80}
Wolfram API error element.
Definition: WAError.h:20
Wolfram API element.
Definition: WAPod.h:26
static std::vector< std::string > splitTimedout(const std::string &s)
It stores the pods that are timedout into a vector.
Definition: WAResult.cpp:89
unsigned int getTimedoutNumber()
It returns the number of elements that were timedout.
Definition: WAResult.cpp:121
std::vector< WAPod > _pods
All the results of the query.
Definition: WAResult.h:62
std::string _dataTypes
Categories and types of data represented in the results.
Definition: WAResult.h:55
std::string _version
The version specification of the API on the server that produced this result.
Definition: WAResult.h:56
bool _is_error
The input could be successfully understood or a serious processing error occurred.
Definition: WAResult.h:52
std::vector< std::string > _timedout
Number of pods that are missing because they timed out.
Definition: WAResult.h:59
std::string _try_again
If _timedout > 0 this will contain an URL to perform the next search.
Definition: WAResult.h:60
Timings _timings
Time in seconds required to parse the input and generate the output.
Definition: WAResult.h:57
WAError * _error
Information about the given error.
Definition: WAResult.h:53
Query timings.
Definition: WAResult.h:27
float parse
Time in seconds required to parse the input.
Definition: WAResult.h:28