[Jderobot-admin] jderobot-r1245 - in trunk/src/stable/libs: . xmlParser
frivas en jderobot.org
frivas en jderobot.org
Mar Nov 11 21:20:57 CET 2014
Author: frivas
Date: 2014-11-11 21:20:57 +0100 (Tue, 11 Nov 2014)
New Revision: 1245
Added:
trunk/src/stable/libs/xmlParser/
trunk/src/stable/libs/xmlParser/CMakeLists.txt
trunk/src/stable/libs/xmlParser/xmlReaderParser.cpp
trunk/src/stable/libs/xmlParser/xmlReaderParser.h
trunk/src/stable/libs/xmlParser/xmlWriterParser.cpp
trunk/src/stable/libs/xmlParser/xmlWriterParser.h
Log:
[#285] included xmlParser library to jderobot
Added: trunk/src/stable/libs/xmlParser/CMakeLists.txt
===================================================================
--- trunk/src/stable/libs/xmlParser/CMakeLists.txt (rev 0)
+++ trunk/src/stable/libs/xmlParser/CMakeLists.txt 2014-11-11 20:20:57 UTC (rev 1245)
@@ -0,0 +1,15 @@
+include_directories(${SLICE_DIR}) # Aquí se alojan las cabeceras de las interfaces ICE en C++
+include_directories(${INTERFACES_CPP_DIR}) # Aquí se alojan las cabeceras de las interfaces ICE en C++
+include_directories(${LIBS_DIR}) # Aquí se alojan las cabeceras de las interfaces ICE en C++
+
+
+include_directories( ${LIBS_DIR}/)
+
+add_library (xmlParser STATIC xmlReaderParser.cpp xmlReaderParser.h xmlWriterParser.cpp xmlWriterParser.h)
+TARGET_LINK_LIBRARIES(xmlParser ${Boost_LIBRARIES})
+
+add_library (xmlParsershare SHARED xmlReaderParser.cpp xmlReaderParser.h xmlWriterParser.cpp xmlWriterParser.h)
+TARGET_LINK_LIBRARIES(xmlParsershare ${Boost_LIBRARIES})
+
+
+set_target_properties(xmlParsershare PROPERTIES OUTPUT_NAME xmlParser)
Added: trunk/src/stable/libs/xmlParser/xmlReaderParser.cpp
===================================================================
--- trunk/src/stable/libs/xmlParser/xmlReaderParser.cpp (rev 0)
+++ trunk/src/stable/libs/xmlParser/xmlReaderParser.cpp 2014-11-11 20:20:57 UTC (rev 1245)
@@ -0,0 +1,267 @@
+/*
+ * Copyright (C) 1997-2014 JDE Developers Team
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see http://www.gnu.org/licenses/.
+ *
+ * Author : Jose María Cañas <jmplaza en gsyc.es>
+ Francisco Miguel Rivas Montero <franciscomiguel.rivas en urjc.es>
+
+ */
+
+#include "xmlReaderParser.h"
+
+namespace Tracker3DPT {
+
+xmlReaderParser::xmlReaderParser(std::string path) {
+
+ this->parser.set_substitute_entities();
+ this->parser.parse_file(path);
+ /*if (this->parser.get_validate()){
+ std::cout << path << " document has a valid xml format." << std::endl;
+ }
+ else{
+ std::cout << "ERROR: " << path << " document has not a valid xml format." << std::endl;
+
+ }*/
+
+
+}
+
+xmlReaderParser::~xmlReaderParser() {
+
+}
+
+
+bool xmlReaderParser::parse(std::string key, int& value) {
+ xmlpp::NodeSet n=parser.get_document()->get_root_node()->find(key);
+ if (!n.empty()){
+ const xmlpp::TextNode* nodeTextValue = dynamic_cast<const xmlpp::TextNode*>(*(n[0]->get_children().begin()));
+ std::istringstream sTemp(nodeTextValue->get_content());
+ sTemp >> value;
+ return true;
+ }
+ return false;
+}
+
+
+bool xmlReaderParser::parse(std::string key, double& value) {
+ xmlpp::NodeSet n=parser.get_document()->get_root_node()->find(key);
+ if (!n.empty()){
+ const xmlpp::TextNode* nodeTextValue = dynamic_cast<const xmlpp::TextNode*>(*(n[0]->get_children().begin()));
+ std::istringstream sTemp(nodeTextValue->get_content());
+ sTemp >> value;
+ return true;
+ }
+ return false;
+}
+
+
+bool xmlReaderParser::parse(std::string key, float& value){
+ xmlpp::NodeSet n=parser.get_document()->get_root_node()->find(key);
+ if (!n.empty()){
+ const xmlpp::TextNode* nodeTextValue = dynamic_cast<const xmlpp::TextNode*>(*(n[0]->get_children().begin()));
+ std::istringstream sTemp(nodeTextValue->get_content());
+ sTemp >> value;
+ return true;
+ }
+ return false;
+}
+
+
+
+bool xmlReaderParser::parse(std::string key, bool& value) {
+ xmlpp::NodeSet n=parser.get_document()->get_root_node()->find(key);
+ if (!n.empty()){
+ const xmlpp::TextNode* nodeTextValue = dynamic_cast<const xmlpp::TextNode*>(*(n[0]->get_children().begin()));
+ std::istringstream sTemp(nodeTextValue->get_content());
+ sTemp >> std::boolalpha >> value;
+ return true;
+ }
+ return false;
+}
+
+bool xmlReaderParser::parse(std::string key, cv::Point3f& value){
+ xmlpp::NodeSet nx=parser.get_document()->get_root_node()->find(key+"/x");
+ if (!nx.empty()){
+ const xmlpp::TextNode* nodeTextValue = dynamic_cast<const xmlpp::TextNode*>(*(nx[0]->get_children().begin()));
+ std::istringstream sTemp(nodeTextValue->get_content());
+ sTemp >> value.x;
+ }
+ else{
+ return false;
+ }
+ xmlpp::NodeSet ny=parser.get_document()->get_root_node()->find(key+"/y");
+ if (!ny.empty()){
+ const xmlpp::TextNode* nodeTextValue = dynamic_cast<const xmlpp::TextNode*>(*(ny[0]->get_children().begin()));
+ std::istringstream sTemp(nodeTextValue->get_content());
+ sTemp >> value.y;
+ }
+ else{
+ return false;
+ }
+ xmlpp::NodeSet nz=parser.get_document()->get_root_node()->find(key+"/z");
+ if (!nz.empty()){
+ const xmlpp::TextNode* nodeTextValue = dynamic_cast<const xmlpp::TextNode*>(*(nz[0]->get_children().begin()));
+ std::istringstream sTemp(nodeTextValue->get_content());
+ sTemp >> value.z;
+ return true;
+ }
+ else{
+ return false;
+ }
+ return false;
+}
+/*bool xmlReaderParser::parse(std::string key, Eigen::Vector4d& value){
+ return false;
+}*/
+
+
+bool xmlReaderParser::parse(std::string key, bool active, Eigen::Vector4d& pos , Eigen::Vector4d& size, Eigen::Vector4d& dir, int index){
+ //active
+ xmlpp::NodeSet nActive=parser.get_document()->get_root_node()->find(key+"/Active");
+ if (!nActive.empty()){
+ const xmlpp::TextNode* nodeTextValue = dynamic_cast<const xmlpp::TextNode*>(*(nActive[index]->get_children().begin()));
+ std::istringstream sTemp(nodeTextValue->get_content());
+ sTemp >> std::boolalpha >> active;
+ }
+ else{
+ return false;
+ }
+
+ //pos
+ xmlpp::NodeSet nPosX0=parser.get_document()->get_root_node()->find(key+"/Pos/x0");
+ if (!nPosX0.empty()){
+ const xmlpp::TextNode* nodeTextValue = dynamic_cast<const xmlpp::TextNode*>(*(nPosX0[index]->get_children().begin()));
+ std::istringstream sTemp(nodeTextValue->get_content());
+ sTemp >> pos[0];
+ }
+ else
+ return false;
+
+ xmlpp::NodeSet nPosX1=parser.get_document()->get_root_node()->find(key+"/Pos/x1");
+ if (!nPosX1.empty()){
+ const xmlpp::TextNode* nodeTextValue = dynamic_cast<const xmlpp::TextNode*>(*(nPosX1[index]->get_children().begin()));
+ std::istringstream sTemp(nodeTextValue->get_content());
+ sTemp >> pos[1];
+ }
+ else
+ return false;
+
+ xmlpp::NodeSet nPosX2=parser.get_document()->get_root_node()->find(key+"/Pos/x2");
+ if (!nPosX2.empty()){
+ const xmlpp::TextNode* nodeTextValue = dynamic_cast<const xmlpp::TextNode*>(*(nPosX2[index]->get_children().begin()));
+ std::istringstream sTemp(nodeTextValue->get_content());
+ sTemp >> pos[2];
+ }
+ else
+ return false;
+
+ xmlpp::NodeSet nPosX3=parser.get_document()->get_root_node()->find(key+"/Pos/x3");
+ if (!nPosX3.empty()){
+ const xmlpp::TextNode* nodeTextValue = dynamic_cast<const xmlpp::TextNode*>(*(nPosX3[index]->get_children().begin()));
+ std::istringstream sTemp(nodeTextValue->get_content());
+ sTemp >> pos[3];
+ }
+ else
+ return false;
+
+ //Size
+ xmlpp::NodeSet nSizeX0=parser.get_document()->get_root_node()->find(key+"/Size/x0");
+ if (!nSizeX0.empty()){
+ const xmlpp::TextNode* nodeTextValue = dynamic_cast<const xmlpp::TextNode*>(*(nSizeX0[index]->get_children().begin()));
+ std::istringstream sTemp(nodeTextValue->get_content());
+ sTemp >>size[0];
+ }
+ else
+ return false;
+
+
+ xmlpp::NodeSet nSizeX1=parser.get_document()->get_root_node()->find(key+"/Size/x1");
+ if (!nSizeX1.empty()){
+ const xmlpp::TextNode* nodeTextValue = dynamic_cast<const xmlpp::TextNode*>(*(nSizeX1[index]->get_children().begin()));
+ std::istringstream sTemp(nodeTextValue->get_content());
+ sTemp >> size[1];
+ }
+ else
+ return false;
+
+ xmlpp::NodeSet nSizeX2=parser.get_document()->get_root_node()->find(key+"/Size/x2");
+ if (!nSizeX2.empty()){
+ const xmlpp::TextNode* nodeTextValue = dynamic_cast<const xmlpp::TextNode*>(*(nSizeX2[index]->get_children().begin()));
+ std::istringstream sTemp(nodeTextValue->get_content());
+ sTemp >> size[2];
+ }
+ else
+ return false;
+
+ xmlpp::NodeSet nSizeX3=parser.get_document()->get_root_node()->find(key+"/Size/x3");
+ if (!nSizeX3.empty()){
+ const xmlpp::TextNode* nodeTextValue = dynamic_cast<const xmlpp::TextNode*>(*(nSizeX3[index]->get_children().begin()));
+ std::istringstream sTemp(nodeTextValue->get_content());
+ sTemp >> size[3];
+ }
+ else
+ return false;
+
+ //Dir
+ xmlpp::NodeSet nDirX0=parser.get_document()->get_root_node()->find(key+"/Dir/x0");
+ if (!nDirX0.empty()){
+ const xmlpp::TextNode* nodeTextValue = dynamic_cast<const xmlpp::TextNode*>(*(nDirX0[index]->get_children().begin()));
+ std::istringstream sTemp(nodeTextValue->get_content());
+ sTemp >>dir[0];
+ }
+ else
+ return false;
+
+ xmlpp::NodeSet nDirX1=parser.get_document()->get_root_node()->find(key+"/Dir/x1");
+ if (!nDirX1.empty()){
+ const xmlpp::TextNode* nodeTextValue = dynamic_cast<const xmlpp::TextNode*>(*(nDirX1[index]->get_children().begin()));
+ std::istringstream sTemp(nodeTextValue->get_content());
+ sTemp >> dir[1];
+ }
+ else
+ return false;
+
+ xmlpp::NodeSet nDirX2=parser.get_document()->get_root_node()->find(key+"/Dir/x2");
+ if (!nDirX2.empty()){
+ const xmlpp::TextNode* nodeTextValue = dynamic_cast<const xmlpp::TextNode*>(*(nDirX2[index]->get_children().begin()));
+ std::istringstream sTemp(nodeTextValue->get_content());
+ sTemp >> dir[2];
+ }
+ else
+ return false;
+
+ xmlpp::NodeSet nDirX3=parser.get_document()->get_root_node()->find(key+"/Dir/x3");
+ if (!nDirX3.empty()){
+ const xmlpp::TextNode* nodeTextValue = dynamic_cast<const xmlpp::TextNode*>(*(nDirX3[index]->get_children().begin()));
+ std::istringstream sTemp(nodeTextValue->get_content());
+ sTemp >> dir[3];
+ }
+ else
+ return false;
+
+ return false;
+}
+
+
+bool xmlReaderParser::getKeyNumbers(std::string key, int& numbers){
+ xmlpp::NodeSet n=parser.get_document()->get_root_node()->find(key);
+ if (!n.empty()){
+ numbers=n.size();
+ return true;
+ }
+ return false;
+}
+
+} /* namespace Tracker3DPT */
Added: trunk/src/stable/libs/xmlParser/xmlReaderParser.h
===================================================================
--- trunk/src/stable/libs/xmlParser/xmlReaderParser.h (rev 0)
+++ trunk/src/stable/libs/xmlParser/xmlReaderParser.h 2014-11-11 20:20:57 UTC (rev 1245)
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 1997-2014 JDE Developers Team
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see http://www.gnu.org/licenses/.
+ *
+ * Author : Jose María Cañas <jmplaza en gsyc.es>
+ Francisco Miguel Rivas Montero <franciscomiguel.rivas en urjc.es>
+
+ */
+
+
+/*! \file XmlParser.h
+ \brief generic typed xml parser based on libxml++
+*/
+
+#ifndef XMLREADERPARSER_H_
+#define XMLREADERPARSER_H_
+
+#include <libxml++/libxml++.h>
+#include <iostream>
+#include <cv.h>
+#include <eigen3/Eigen/Dense>
+
+namespace Tracker3DPT {
+
+class xmlReaderParser {
+public:
+ xmlReaderParser(std::string path);
+ virtual ~xmlReaderParser();
+ bool parse(std::string key, int& value);
+ bool parse(std::string key, double& value);
+ bool parse(std::string key, float& value);
+ bool parse(std::string key, bool& value);
+ bool parse(std::string key, cv::Point3f& value);
+ //bool parse(std::string key, Eigen::Vector4d& value);
+ bool parse(std::string key, bool active, Eigen::Vector4d& pos , Eigen::Vector4d& size, Eigen::Vector4d& dir, int index);
+ bool getKeyNumbers(std::string key, int& numbers);
+
+
+
+
+private:
+ xmlpp::DomParser parser;
+};
+
+} /* namespace Tracker3DPT */
+
+#endif /* XMLREADERPARSER_H_ */
Added: trunk/src/stable/libs/xmlParser/xmlWriterParser.cpp
===================================================================
--- trunk/src/stable/libs/xmlParser/xmlWriterParser.cpp (rev 0)
+++ trunk/src/stable/libs/xmlParser/xmlWriterParser.cpp 2014-11-11 20:20:57 UTC (rev 1245)
@@ -0,0 +1,253 @@
+/*
+ * Copyright (C) 1997-2014 JDE Developers Team
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see http://www.gnu.org/licenses/.
+ *
+ * Author : Jose María Cañas <jmplaza en gsyc.es>
+ Francisco Miguel Rivas Montero <franciscomiguel.rivas en urjc.es>
+
+ */
+
+
+/*! \file xmlWriterParser.h
+ \brief xml parser used to write xml configurations
+*/
+
+#include "xmlWriterParser.h"
+
+namespace Tracker3DPT {
+
+/**
+ * \brief ConfigTracker constructor
+ * This method initializes the xml document
+ *
+ * @param rootNode The root node name for the xml file
+ * @param fileName The filename of the generated xml file
+ */
+xmlWriterParser::xmlWriterParser(std::string rootNode, std::string fileName) {
+ xmlpp::Element* r=this->document.create_root_node(rootNode);
+ r->set_child_text("");
+ this->fileName=fileName;
+}
+
+/**
+ * \brief ConfigTracker destructor
+ */
+xmlWriterParser::~xmlWriterParser() {
+}
+
+/**
+ * \brief Method to save the generated xml to a file
+ */
+void xmlWriterParser::saveToFile(){
+ this->document.write_to_file(this->fileName);
+}
+
+/**
+ * \brief Method to print of screen the generated xml
+ */
+void xmlWriterParser::printXmlFile(){
+ std::string whole = this->document.write_to_string();
+ std::cout << "XML built at runtime: " << std::endl << whole << std::endl;
+}
+
+/**
+ * \brief Method to split string using "/" as delimitator
+ *
+ * @param value The input string
+ * @param array The output string array once splitted
+ */
+void xmlWriterParser::splitString(std::string value, std::vector<std::string>& array){
+ size_t pos = 0;
+ std::string token;
+ while ((pos = value.find("/")) != std::string::npos) {
+ token = value.substr(0, pos);
+ array.push_back(token);
+ value.erase(0, pos + 1);
+ }
+ array.push_back(value);
+}
+
+/**
+ * \brief Method that checks if a key exsits
+ *
+ * @param key The searched key
+ * @return True if the element exists
+ */
+bool xmlWriterParser::elementExists(std::string key){
+ xmlpp::NodeSet n=this->document.get_root_node()->find(key);
+ return (n.size()!=0);
+}
+
+/**
+ * \brief Method that look for a key and if it does not exists this make the correponding way
+ *
+ * @param key The searched key
+ * @return the parent node of the searched key
+ */
+xmlpp::Element* xmlWriterParser::lookForKeyAndMakeway(std::string key){
+ std::vector<std::string> s;
+
+ splitString(key,s);
+ if (s.size()!=1){
+ std::string completeKey(s[0]);
+ std::string parentKey(s[0]);
+ for (int i=0; i!= s.size()-1; i++){
+ if (!elementExists(completeKey)){
+ if (i==0){
+ //we have to create the node under the parent document.
+ xmlpp::Element* n1= document.get_root_node();
+ xmlpp::Element* n2= n1->add_child(parentKey);
+ n2->set_child_text("");
+ }
+ else{
+ xmlpp::NodeSet ns1=document.get_root_node()->find(parentKey);
+ xmlpp::Element* n1 = ns1[0]->add_child(s[i]);
+ n1->set_child_text("");
+ }
+ }
+ if (i!=s.size()-2)
+ completeKey+="/"+s[i+1];
+ if (i!=0)
+ parentKey+="/"+s[i];
+ }
+ xmlpp::NodeSet ns1=document.get_root_node()->find(parentKey);
+ xmlpp::Element* n1 = ns1[0]->add_child(s[s.size()-1]);
+ return n1;
+ }
+ else{
+ xmlpp::Element* n1= document.get_root_node();
+ xmlpp::Element* n2= n1->add_child(s[0]);
+ return n2;
+ }
+}
+
+/**
+ * \brief Overloaded method that includes into the xml document a key (complete path) and its value (string)
+ *
+ * @param key The new key
+ * @param value The value of the new key
+ */
+void xmlWriterParser::addKey(std::string key, std::string value){
+
+ xmlpp::Element* n1=lookForKeyAndMakeway(key);
+ n1->set_child_text(value);
+}
+
+/**
+ * \brief Overloaded method that includes into the xml document a key (complete path) and its value (cv::Point3f)
+ *
+ * @param key The new key
+ * @param value The value of the new key
+ */
+void xmlWriterParser::addKey(std::string key, cv::Point3f value){
+ xmlpp::Element* n1=lookForKeyAndMakeway(key);
+ n1->set_child_text("");
+ xmlpp::Element* nx = n1->add_child("x");
+ xmlpp::Element* ny = n1->add_child("y");
+ xmlpp::Element* nz = n1->add_child("z");
+ std::stringstream isX;
+ isX << value.x;
+ nx->set_child_text(isX.str());
+ std::stringstream isY;
+ isY << value.y;
+ ny->set_child_text(isY.str());
+ std::stringstream isZ;
+ isZ << value.z;
+ nz->set_child_text(isZ.str());
+
+}
+
+/**
+ * \brief Overloaded method that includes into the xml document a key (complete path) and its value (double)
+ *
+ * @param key The new key
+ * @param value The value of the new key
+ */
+void xmlWriterParser::addKey(std::string key, double value){
+ xmlpp::Element* n1=lookForKeyAndMakeway(key);
+ std::stringstream ss;
+ ss << value;
+ n1->set_child_text(ss.str());
+}
+
+/**
+ * \brief Overloaded method that includes into the xml document a key (complete path) and its value (float)
+ *
+ * @param key The new key
+ * @param value The value of the new key
+ */
+void xmlWriterParser::addKey(std::string key, float value){
+ xmlpp::Element* n1=lookForKeyAndMakeway(key);
+ std::stringstream ss;
+ ss << value;
+ n1->set_child_text(ss.str());
+}
+
+/**
+ * \brief Overloaded method that includes into the xml document a key (complete path) and its value (int)
+ *
+ * @param key The new key
+ * @param value The value of the new key
+ */
+void xmlWriterParser::addKey(std::string key, int value){
+ xmlpp::Element* n1=lookForKeyAndMakeway(key);
+ std::stringstream ss;
+ ss << value;
+ n1->set_child_text(ss.str());
+}
+
+/**
+ * \brief Overloaded method that includes into the xml document a key (complete path) and its value (bool)
+ *
+ * @param key The new key
+ * @param value The value of the new key
+ */
+void xmlWriterParser::addKey(std::string key, bool value){
+ xmlpp::Element* n1=lookForKeyAndMakeway(key);
+ if (value)
+ n1->set_child_text("True");
+ else
+ n1->set_child_text("False");
+}
+
+/**
+ * \brief Overloaded method that includes into the xml document a key (complete path) and its value (Eigen::Vector4d)
+ *
+ * @param key The new key
+ * @param value The value of the new key
+ */
+void xmlWriterParser::addKey(std::string key, Eigen::Vector4d value){
+ xmlpp::Element* n1=lookForKeyAndMakeway(key);
+ n1->set_child_text("");
+ xmlpp::Element* nx0 = n1->add_child("x0");
+ xmlpp::Element* nx1 = n1->add_child("x1");
+ xmlpp::Element* nx2 = n1->add_child("x2");
+ xmlpp::Element* nx3 = n1->add_child("x3");
+ std::stringstream ssX0;
+ ssX0 << value[0];
+ nx0->set_child_text(ssX0.str());
+ std::stringstream ssX1;
+ ssX1 << value[1];
+ nx1->set_child_text(ssX1.str());
+ std::stringstream ssX2;
+ ssX2 << value[2];
+ nx2->set_child_text(ssX2.str());
+ std::stringstream ssX3;
+ ssX3 << value[3];
+ nx3->set_child_text(ssX3.str());
+}
+
+
+} /* namespace Tracker3DPT */
Added: trunk/src/stable/libs/xmlParser/xmlWriterParser.h
===================================================================
--- trunk/src/stable/libs/xmlParser/xmlWriterParser.h (rev 0)
+++ trunk/src/stable/libs/xmlParser/xmlWriterParser.h 2014-11-11 20:20:57 UTC (rev 1245)
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 1997-2014 JDE Developers Team
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see http://www.gnu.org/licenses/.
+ *
+ * Author : Jose María Cañas <jmplaza en gsyc.es>
+ Francisco Miguel Rivas Montero <franciscomiguel.rivas en urjc.es>
+
+ */
+
+
+#ifndef XMLWRITERPARSER_H_
+#define XMLWRITERPARSER_H_
+
+#include <libxml++/libxml++.h>
+#include <iostream>
+#include <cv.h>
+#include <eigen3/Eigen/Dense>
+
+
+
+namespace Tracker3DPT {
+
+class xmlWriterParser {
+public:
+ xmlWriterParser(std::string rootNode, std::string fileName);
+ virtual ~xmlWriterParser();
+ void saveToFile();
+ void printXmlFile();
+ void addKey(std::string key, std::string value);
+ void addKey(std::string key, cv::Point3f value);
+ void addKey(std::string key, double value);
+ void addKey(std::string key, float value);
+ void addKey(std::string key, int value);
+ void addKey(std::string key, bool value);
+ void addKey(std::string key, Eigen::Vector4d value);
+
+
+
+
+private:
+ xmlpp::Document document; /**< xml document*/
+ std::string fileName; /**< fileName to save the xml file*/
+
+ void splitString(std::string value, std::vector<std::string>& array);
+ bool elementExists(std::string key);
+ xmlpp::Element* lookForKeyAndMakeway(std::string key);
+
+
+};
+
+} /* namespace Tracker3DPT */
+
+#endif /* XMLWRITERPARSER_H_ */
More information about the Jderobot-admin
mailing list