ChimeraTK-ControlSystemAdapter-OPCUAAdapter 04.00.05
Loading...
Searching...
No Matches
xml_file_handler.h
Go to the documentation of this file.
1/*
2 * This file is part of ChimeraTKs ControlSystem-OPC-UA-Adapter.
3 *
4 * ChimeraTKs ControlSystem-OPC-UA-Adapter is free software: you can
5 * redistribute it and/or modify it under the terms of the Lesser GNU
6 * General Public License as published by the Free Software Foundation,
7 * either version 3 of the License, or (at your option) any later version.
8 *
9 * ChimeraTKs ControlSystem-OPC-UA-Adapter is distributed in the hope
10 * that it will be useful, but WITHOUT ANY WARRANTY; without even the
11 * implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * See the Lesser GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with Foobar. If not, see https://www.gnu.org/licenses/lgpl.html
16 *
17 * Copyright (c) 2016 Chris Iatrou <Chris_Paul.Iatrou@tu-dresden.de>
18 * Copyright (c) 2016 Julian Rahm <Julian.Rahm@tu-dresden.de>
19 */
20
21#pragma once
22
23#include <libxml2/libxml/tree.h>
24#include <libxml2/libxml/xpath.h>
25#include <libxml2/libxml/xpathInternals.h>
26
27#include <boost/tokenizer.hpp>
28
29#include <iostream>
30#include <vector>
31
32namespace ChimeraTK {
45 public:
50 xml_file_handler(const std::string& filePath);
51
58 bool createDoc(const std::string& filePath);
59
64 bool isDocSetted();
65
72 xmlXPathObjectPtr getNodeSet(const std::string& xPathString);
73
81 static std::vector<xmlNodePtr> getNodesByName(xmlNodePtr startNode, const std::string& nodeName);
90 static std::vector<std::string> parseVariablePath(
91 const std::string& variablePath, const std::string& seperator = "/");
92
100 static std::string getAttributeValueFromNode(xmlNode* node, const std::string& attributeName);
101
109 static std::string getContentFromNode(xmlNode* node);
110
115
116 private:
117 xmlDocPtr doc{};
118 xmlNodePtr cur{};
119 };
120} // namespace ChimeraTK
This class support any file interaction with a xml file.
static std::vector< xmlNodePtr > getNodesByName(xmlNodePtr startNode, const std::string &nodeName)
This methode return a list of all nodes with the given name nodeName starting by the given startNode.
bool createDoc(const std::string &filePath)
This methode set a document pointer to the file it ist given by the file path.
xmlXPathObjectPtr getNodeSet(const std::string &xPathString)
This methode return a pointer of a xPath element depending of the given xPathString.
~xml_file_handler()
Destructor of the class, frees the document and clean the parser.
static std::string getContentFromNode(xmlNode *node)
This methode returns the value between a xml tag.
static std::vector< std::string > parseVariablePath(const std::string &variablePath, const std::string &seperator="/")
This methode splitt a given string bey the given seperators.
static std::string getAttributeValueFromNode(xmlNode *node, const std::string &attributeName)
This methode returns a value of the given attribute from the given node you want to know.
bool isDocSetted()
This Methode check if a document is currently setted.