95bool check_syntax(tinyxml2::XMLElement* element, std::vector<std::string>& control_list, std::vector<std::string>& rejected, std::string& error)
97 const char* type =
nullptr;
98 const char*
interface = nullptr;
99 const char* provider =
nullptr;
101 std::string elementTag(element->Name());
103 std::string parameter_string;
106 bool returnValue =
true;
108 std::string typetag =
"";
109 std::string interfacetag =
"";
110 std::string providertag =
"";
112 bool hasChildren = !element->NoChildren();
113 bool hasSiblings = (element->NextSiblingElement() !=
nullptr);
115 if (elementTag ==
"Control")
117 element->QueryStringAttribute(
"type", &type);
123 if (!
search(control_list, typetag))
125 error =
"Control tag '" + typetag +
"' not available in the valid list";
126 rejected.push_back(parameter_string);
132 error =
"Control tag missing 'type' attribute: " + parameter_string;
133 rejected.push_back(parameter_string);
138 returnValue &=
check_syntax(element->FirstChildElement(), control_list, rejected, error);
141 returnValue &=
check_syntax(element->NextSiblingElement(), control_list, rejected, error);
143 else if (elementTag ==
"Runner")
145 element->QueryStringAttribute(
"interface", &interface);
146 element->QueryStringAttribute(
"provider", &provider);
150 error =
"Runner tag missing 'interface' attribute: " + parameter_string;
151 rejected.push_back(parameter_string);
157 error =
"Runner tag missing 'provider' attribute: " + parameter_string;
158 rejected.push_back(parameter_string);
163 returnValue &=
check_syntax(element->NextSiblingElement(), control_list, rejected, error);
167 error =
"XML element is not valid :" + parameter_string;
168 rejected.push_back(parameter_string);
tinyxml2::XMLElement * extract_plan(tinyxml2::XMLDocument &document)
Extract the <Plan> element from the XML document.
Definition xml_helper.hpp:36
bool check_syntax(tinyxml2::XMLElement *element, std::vector< std::string > &control_list, std::vector< std::string > &rejected, std::string &error)
check the plan to make sure all control and runner XML elements are valid with minimal required attri...
Definition xml_helper.hpp:95
bool search(std::vector< std::string > list, std::string value)
search a string in a vector of strings
Definition xml_helper.hpp:22
bool convert_to_string(tinyxml2::XMLElement *element, std::string ¶meters)
convert XMLElement to std::string
Definition xml_helper.hpp:54