stdr_parser_node.cpp
Go to the documentation of this file.
00001 /******************************************************************************
00002    STDR Simulator - Simple Two DImensional Robot Simulator
00003    Copyright (C) 2013 STDR Simulator
00004    This program is free software; you can redistribute it and/or modify
00005    it under the terms of the GNU General Public License as published by
00006    the Free Software Foundation; either version 3 of the License, or
00007    (at your option) any later version.
00008    This program is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011    GNU General Public License for more details.
00012    You should have received a copy of the GNU General Public License
00013    along with this program; if not, write to the Free Software Foundation,
00014    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
00015    
00016    Authors : 
00017    * Manos Tsardoulias, etsardou@gmail.com
00018    * Aris Thallas, aris.thallas@gmail.com
00019    * Chris Zalidis, zalidis@gmail.com 
00020 ******************************************************************************/
00021 
00022 #include "stdr_parser/stdr_parser_node.h"
00023 
00024 namespace stdr_parser
00025 {
00030   Node::Node(void)
00031   {
00032     priority = 0;
00033   }
00034   
00035   Node::~Node(void)
00036   {
00037         this->unallocateChildren();
00038   }
00039 
00044   bool Node::checkForFilename(std::string base)
00045   {
00046     if(elements.size() == 1)
00047     {
00048       if(elements[0]->tag == base)
00049       {
00050         return true;
00051       }
00052     }
00053     return false;
00054   }
00055   
00061   std::vector<int> Node::getTag(std::string tag)
00062   {
00063     std::vector<int> ret;
00064     for(unsigned int i = 0 ; i < elements.size() ; i++)
00065     {
00066       if(elements[i]->tag == tag)
00067       {
00068         ret.push_back(i);
00069       }
00070     }
00071     return ret;
00072   }
00073   
00078   void Node::increasePriority(void)
00079   {
00080     priority ++;
00081     for(unsigned int i = 0 ; i < elements.size() ; i++)
00082     {
00083       elements[i]->increasePriority();
00084     }
00085   }
00086   
00093   void Node::printParsedXml(Node *n,std::string indent)
00094   {
00095     if(n->value != "")
00096     {  
00097       ROS_ERROR("%s- '%s' (%d) - %d %s",indent.c_str(),n->value.c_str(),
00098         n->priority, n->file_row, extractFilename(n->file_origin).c_str());
00099     }
00100     else
00101     {
00102       ROS_ERROR("%s[%s] (%d) - %d %s",indent.c_str(),n->tag.c_str(),
00103         n->priority, n->file_row, extractFilename(n->file_origin).c_str());
00104     }  
00105     for(unsigned int i = 0 ; i < n->elements.size() ; i++)
00106     {
00107       printParsedXml(n->elements[i],indent+std::string("| "));
00108     }
00109   }
00110   
00115   void Node::unallocateChildren(void)
00116   {
00117     for(unsigned int i = 0 ; i < elements.size() ; i++)
00118     {
00119 
00120       delete elements[i];
00121     }
00122   }
00123 }


stdr_parser
Author(s): Manos Tsardoulias, Chris Zalidis, Aris Thallas
autogenerated on Tue Feb 7 2017 03:46:27