stdr_parser_node.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  STDR Simulator - Simple Two DImensional Robot Simulator
3  Copyright (C) 2013 STDR Simulator
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 3 of the License, or
7  (at your option) any later version.
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12  You should have received a copy of the GNU General Public License
13  along with this program; if not, write to the Free Software Foundation,
14  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15 
16  Authors :
17  * Manos Tsardoulias, etsardou@gmail.com
18  * Aris Thallas, aris.thallas@gmail.com
19  * Chris Zalidis, zalidis@gmail.com
20 ******************************************************************************/
21 
23 
24 namespace stdr_parser
25 {
30  Node::Node(void)
31  {
32  priority = 0;
33  }
34 
36  {
37  this->unallocateChildren();
38  }
39 
44  bool Node::checkForFilename(std::string base)
45  {
46  if(elements.size() == 1)
47  {
48  if(elements[0]->tag == base)
49  {
50  return true;
51  }
52  }
53  return false;
54  }
55 
61  std::vector<int> Node::getTag(std::string tag)
62  {
63  std::vector<int> ret;
64  for(unsigned int i = 0 ; i < elements.size() ; i++)
65  {
66  if(elements[i]->tag == tag)
67  {
68  ret.push_back(i);
69  }
70  }
71  return ret;
72  }
73 
79  {
80  priority ++;
81  for(unsigned int i = 0 ; i < elements.size() ; i++)
82  {
83  elements[i]->increasePriority();
84  }
85  }
86 
93  void Node::printParsedXml(Node *n,std::string indent)
94  {
95  if(n->value != "")
96  {
97  ROS_ERROR("%s- '%s' (%d) - %d %s",indent.c_str(),n->value.c_str(),
98  n->priority, n->file_row, extractFilename(n->file_origin).c_str());
99  }
100  else
101  {
102  ROS_ERROR("%s[%s] (%d) - %d %s",indent.c_str(),n->tag.c_str(),
103  n->priority, n->file_row, extractFilename(n->file_origin).c_str());
104  }
105  for(unsigned int i = 0 ; i < n->elements.size() ; i++)
106  {
107  printParsedXml(n->elements[i],indent+std::string("| "));
108  }
109  }
110 
116  {
117  for(unsigned int i = 0 ; i < elements.size() ; i++)
118  {
119 
120  delete elements[i];
121  }
122  }
123 }
std::string tag
The node value (if it not a tag node)
void increasePriority(void)
Increases the priority of the node.
std::vector< int > getTag(std::string tag)
Searches for a tag in the specific node.
The main namespace for STDR GUI XML parser.
std::string extractFilename(std::string s)
Extracts the filename from an absolute path.
std::string value
The node children.
Node(void)
Default constructor.
bool checkForFilename(std::string base)
Checks a node if a specific filename exists.
void printParsedXml(Node *n, std::string indent)
Debug recursive function - Prints the xml tree.
void unallocateChildren(void)
Unalloates the memory of the node&#39;s children.
int priority
The node tag (if it not a value node)
Implements the main functionalities of the stdr parser tree.
std::string file_origin
Row in the original file.
#define ROS_ERROR(...)
std::vector< Node * > elements
File it was into.
~Node(void)
Destructor who also destroys all its children.


stdr_parser
Author(s): Manos Tsardoulias, Chris Zalidis, Aris Thallas
autogenerated on Mon Jun 10 2019 15:14:54