46 Parser::base_node_ =
new Node();
47 Parser::base_node_->tag =
"STDR_Parser_Root_Node";
52 if(file_name.find(
".xml") != std::string::npos)
56 else if(file_name.find(
".yaml") != std::string::npos)
76 catch(YAML::ParserException& e)
79 std::string(
"Failed to load file '") +
80 file_name + std::string(
"'") +
81 std::string(
"\nError was '") + std::string(e.what());
100 for(
unsigned int i = 0 ; i < n->
elements.size() ; i++)
102 if(n->
elements[i]->tag ==
"filename")
107 std::string(
"STDR parser : ") + n->
tag + std::string(
" has a \ 108 filename of wrong type specified\n") +
109 std::string(
"\nError was in line ") +
SSTR( n->
file_row ) +
110 std::string(
" of file '") + n->
file_origin + std::string(
"'");
115 for(
unsigned int j = 0 ; j < child->
elements.size() ; j++)
117 child->
elements[j]->increasePriority() ;
148 bool pure_values =
true;
149 for(
unsigned int i = 0 ; i < n->
elements.size() ; i++)
167 int min_priority = n->
elements[0]->priority;
168 unsigned int index = 0;
169 for(
unsigned int i = 1 ; i < n->
elements.size() ; i++)
171 if(n->
elements[i]->priority < min_priority)
173 min_priority = n->
elements[i]->priority;
179 n->
elements.push_back(proper_child);
183 for(
unsigned int i = 0 ; i < n->
elements.size() ; i++)
201 for(
unsigned int i = 0 ; i < n->
elements.size() ; i++)
208 std::string tag = n->
elements[i]->tag;
213 std::vector<int> num = n->
getTag(tag);
218 for(
int i = num.size()-1 ; i > 0 ; i --)
221 for (
unsigned int j = 0 ;
222 j < n->
elements[num[i]]->elements.size() ; j++)
224 n->
elements[num[0]]->elements.push_back(
std::string tag
The node value (if it not a tag node)
Parser(void)
Default constructor.
std::vector< int > getTag(std::string tag)
Searches for a tag in the specific node.
static Node * base_node_
< Base node of the parsed file
The main namespace for STDR GUI XML parser.
static std::set< std::string > non_mergable_tags
static void parse(std::string file_name, Node *n)
Private function that initiates the parsing of an xml file.
std::string value
The node children.
static void parse(std::string file_name)
Parses an xml file.
static void parseMergableSpecifications(void)
Parses the mergable specifications file.
static bool eliminateFilenames(Node *n)
Recursive function - Expands the 'filename' nodes and eliminates them.
static void validate(std::string file_name, Node *n)
Performs a required / allowed - validity check on the xml tree.
static void parse(std::string file_name, Node *n)
Private function that initiates the parsing of an xml file.
static void mergeNodesValues(Node *n)
Merges the leaves of the xml tree, which are the value nodes.
static bool mergeNodes(Node *n)
Recursive function - Merges the nodes that do not exist in non_mergable_tags_.
Implements the main functionalities of the stdr parser tree.
std::string file_origin
Row in the original file.
std::vector< Node * > elements
File it was into.
Provides a parser exception. Publicly inherits from std::runtime_error. Used in robot handler...