libwolfram20

◆ parse()

void WAPod::parse ( rapidxml::xml_node<> *  pod)
private

Parsing a input 'pod' xml node.

Precondition
You must call this function only once (called my the constructor)
Parameters
[in]podXML Node of pod
131 {
132 this->_error = nullptr;
133 if (strcmp(pod->first_attribute("error")->value(), "true") == 0) {
134 this->_error = new WAError(pod->first_node("error"));
135 return;
136 }
137
138 // Read arguments Pods node
139 this->_title = std::string( pod->first_attribute("title")->value() );
140 this->_id = std::string( pod->first_attribute("id")->value() );
141 this->_scanner = std::string( pod->first_attribute("scanner")->value() );
142 this->_position = atoi(pod->first_attribute("title")->value());
143
144 // Reading a Subpods node
145 xml_node<>* nodeSubpod = pod->first_node("subpod");
146 for(unsigned int i = 0; i < atoi(pod->first_attribute("numsubpods")->value()); i++) {
147 this->SubPods.push_back(WASubpod(nodeSubpod));
148 nodeSubpod = nodeSubpod->next_sibling("subpod");
149 }
150
151 // Reading a States node
152 xml_node<>* nodeStates = pod->first_node("states");
153 if (nodeStates != nullptr) {
154 unsigned int len = atoi(nodeStates->first_attribute("count")->value());
155 nodeStates = nodeStates->first_node("state");
156 for(unsigned int i = 0; i < len; i++) {
157 this->States.push_back(WAPodState(nodeStates));
158 nodeStates = nodeStates->next_sibling("state");
159 }
160 }
161}
Wolfram API error element.
Definition: WAError.h:20
Contains a particular pod state for a single pod or subpod.
Definition: WAPodState.h:21
std::vector< WAPodState > States
All the valid States returned by the query.
Definition: WAPod.h:51
std::string _id
A unique identifier for a pod, used for selecting specific pods to include or exclude.
Definition: WAPod.h:47
int _position
A number indicating the intended position of the pod in a visual display.
Definition: WAPod.h:48
WAError * _error
Information about the given error; nullptr if no error.
Definition: WAPod.h:44
std::vector< WASubpod > SubPods
All the valid Pods returned by the query.
Definition: WAPod.h:50
std::string _scanner
The name of the scanner that produced this pod. A general guide to the type of data it holds.
Definition: WAPod.h:46
std::string _title
The pod title, used to identify the pod and its contents.
Definition: WAPod.h:45
Wolfram API element.
Definition: WASubpod.h:26