ChimeraTK-ControlSystemAdapter-OPCUAAdapter  04.00.01
ChimeraTK::xml_file_handler Class Reference

This class support any file interaction with a xml file. More...

#include <xml_file_handler.h>

Public Member Functions

 xml_file_handler (const std::string &filePath)
 The constructor of the class creates a doc pointer depending on the file path. More...
 
bool createDoc (const std::string &filePath)
 This methode set a document pointer to the file it ist given by the file path. More...
 
bool isDocSetted ()
 This Methode check if a document is currently setted. More...
 
xmlXPathObjectPtr getNodeSet (const std::string &xPathString)
 This methode return a pointer of a xPath element depending of the given xPathString. More...
 
 ~xml_file_handler ()
 Destructor of the class, frees the document and clean the parser. More...
 

Static Public Member Functions

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. More...
 
static std::vector< std::string > parseVariablePath (const std::string &variablePath, const std::string &seperator="/")
 This methode splitt a given string bey the given seperators. More...
 
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. More...
 
static std::string getContentFromNode (xmlNode *node)
 This methode returns the value between a xml tag. More...
 

Detailed Description

This class support any file interaction with a xml file.

To use all config/mapping xml-files in a confortable way this class provides some useful methodes to read specal nodes, get attributes and so one

Author
Chris Iatrou
Julian Rahm
Date
22.11.2016

Definition at line 44 of file xml_file_handler.h.

Constructor & Destructor Documentation

◆ xml_file_handler()

ChimeraTK::xml_file_handler::xml_file_handler ( const std::string &  filePath)

The constructor of the class creates a doc pointer depending on the file path.

Parameters
filePathPath to a xml file which you want to read

Definition at line 37 of file xml_file_handler.cpp.

◆ ~xml_file_handler()

ChimeraTK::xml_file_handler::~xml_file_handler ( )

Destructor of the class, frees the document and clean the parser.

Definition at line 144 of file xml_file_handler.cpp.

Member Function Documentation

◆ createDoc()

bool ChimeraTK::xml_file_handler::createDoc ( const std::string &  filePath)

This methode set a document pointer to the file it ist given by the file path.

Parameters
filePathPath to a xml file which you want to read
Returns
Returns true if a document is setted, if not it returns false

Definition at line 94 of file xml_file_handler.cpp.

◆ getAttributeValueFromNode()

std::string ChimeraTK::xml_file_handler::getAttributeValueFromNode ( xmlNode *  node,
const std::string &  attributeName 
)
static

This methode returns a value of the given attribute from the given node you want to know.

Parameters
nodeNode with the attribute of interest
attributeNameName of the wanted attribute
Returns
Returns a string of the attribute

Definition at line 122 of file xml_file_handler.cpp.

+ Here is the caller graph for this function:

◆ getContentFromNode()

std::string ChimeraTK::xml_file_handler::getContentFromNode ( xmlNode *  node)
static

This methode returns the value between a xml tag.

For example <tagelement>content</tagelement> the returned value ist "content".

Parameters
nodeNode with the content of interest
Returns
Returns a string of the inner content

Definition at line 131 of file xml_file_handler.cpp.

+ Here is the caller graph for this function:

◆ getNodesByName()

std::vector< xmlNodePtr > ChimeraTK::xml_file_handler::getNodesByName ( xmlNodePtr  startNode,
const std::string &  nodeName 
)
static

This methode return a list of all nodes with the given name nodeName starting by the given startNode.

Parameters
startNodeStart node, all child nodes will be searched by the given nodeName
nodeNameIs the name of the xml tag, we use to search for
Returns
Returns a list of all pointer from founded child nodes with nodeName

Definition at line 44 of file xml_file_handler.cpp.

+ Here is the caller graph for this function:

◆ getNodeSet()

xmlXPathObjectPtr ChimeraTK::xml_file_handler::getNodeSet ( const std::string &  xPathString)

This methode return a pointer of a xPath element depending of the given xPathString.

Parameters
xPathStringA xPath string we seaching for
Returns
Returns a element pointer if some was found, in other cases it will return NULL

Definition at line 56 of file xml_file_handler.cpp.

+ Here is the caller graph for this function:

◆ isDocSetted()

bool ChimeraTK::xml_file_handler::isDocSetted ( )

This Methode check if a document is currently setted.

Returns
True or false depending if a document is set or not

Definition at line 87 of file xml_file_handler.cpp.

+ Here is the caller graph for this function:

◆ parseVariablePath()

std::vector< std::string > ChimeraTK::xml_file_handler::parseVariablePath ( const std::string &  variablePath,
const std::string &  seperator = "/" 
)
static

This methode splitt a given string bey the given seperators.

You can use the seperator as string of seperators like "_/&" all characters will be used as single seperator

Parameters
variablePathString which you want to seperate by the seperator
seperatorString of, if you want different, seperators, whicht this methode use to split the string
Returns
Returns a vector of every single splitet word

Definition at line 110 of file xml_file_handler.cpp.

+ Here is the caller graph for this function:

The documentation for this class was generated from the following files: