This class offers functions to extract information from an XML file. It uses the xPath functions of the library libXML. More...
#include <XMLParser.h>
Public Member Functions | |
XMLParser (const std::string &fileName, bool validateFile) | |
constructor | |
virtual | ~XMLParser () |
destructor | |
virtual void | createFile () |
this method starts the creation of an xml file. It is the first method you have to call in order to create the xml file | |
virtual void | startDocument () |
this method writes the xml directive into the file, starting the xml document | |
virtual void | endDocument () |
this method ends the xml document, freeing the xml writer interface | |
virtual void | startElement (const std::string element) |
this method starts a new element tag | |
virtual void | writeElement (const std::string element, const std::string elementValue) |
this method writes an element and its value into the current file | |
virtual void | endElement () |
this method ends a new element tag | |
virtual void | writeString (const std::string text) |
this method writes a string into the xml document | |
virtual void | writeNewline () |
this method starts a new line in the xml document | |
virtual void | writeAttribute (const std::string attributeName, const std::string attributeValue) |
this method adds an attribute to the current element that is being edited | |
virtual std::vector < ElementXML * > * | extractElementsFromXPath (const std::string &xpathExpr) |
Extracts information from an XML file by searching for an xPath expression. | |
virtual std::vector < ElementXML * > * | extractElements (const std::string &elementName) |
extracts information from an XML file by searching for a XML element name | |
virtual AttributeXML * | extractAttribute (const std::string &elementName, const std::string &attributeName) |
Extracts information from an XML file by searching for a XML attribute in an XML element. | |
Private Member Functions | |
void | fillElement (xmlNodePtr node, ElementXML *pElement) |
fills instance of the class ElementXML with nodes from an XML file | |
void | trimCarrierReturn (std::string &s) |
removes carrier return from string | |
xmlChar * | ConvertInput (const char *in, const char *encoding) |
converts a char array to a xmlChar array | |
Private Attributes | |
xmlTextWriterPtr | writer_ |
interface to write into the xml file | |
std::string | fileName_ |
path of the file |
This class offers functions to extract information from an XML file. It uses the xPath functions of the library libXML.
Definition at line 85 of file XMLParser.h.
fesa::XMLParser::XMLParser | ( | const std::string & | fileName, | |
bool | validateFile | |||
) |
constructor
fileName | path of the file that represents the xml element | |
validateFile | if true, file is validated |
Definition at line 30 of file XMLParser.cpp.
References FesaErrorOpenXMLFile.
fesa::XMLParser::~XMLParser | ( | ) | [virtual] |
xmlChar * fesa::XMLParser::ConvertInput | ( | const char * | in, | |
const char * | encoding | |||
) | [private] |
converts a char array to a xmlChar array
in | The char array | |
encoding | the coding format |
Definition at line 355 of file XMLParser.cpp.
References FesaErrorXMLParserConvertingInput, and FesaErrorXMLParserEncodingNotFound.
Referenced by writeNewline(), and writeString().
void fesa::XMLParser::createFile | ( | ) | [virtual] |
this method starts the creation of an xml file. It is the first method you have to call in order to create the xml file
Definition at line 53 of file XMLParser.cpp.
References FesaErrorCreatingXMLFile, fileName_, and writer_.
Referenced by fesa::StoreManager::store(), and fesa::NotificationIDManager::storeNotificationIDCollection().
void fesa::XMLParser::endDocument | ( | ) | [virtual] |
this method ends the xml document, freeing the xml writer interface
Definition at line 71 of file XMLParser.cpp.
References FesaErrorWritingToXMLFile, fileName_, and writer_.
Referenced by fesa::StoreManager::store(), and fesa::NotificationIDManager::storeNotificationIDCollection().
void fesa::XMLParser::endElement | ( | ) | [virtual] |
this method ends a new element tag
element | the tag of the element to end |
Definition at line 102 of file XMLParser.cpp.
References FesaErrorWritingToXMLFile, fileName_, and writer_.
Referenced by fesa::StoreManager::store(), fesa::StoreManager::storeFields(), and fesa::NotificationIDManager::storeNotificationIDCollection().
AttributeXML * fesa::XMLParser::extractAttribute | ( | const std::string & | elementName, | |
const std::string & | attributeName | |||
) | [virtual] |
Extracts information from an XML file by searching for a XML attribute in an XML element.
elementName | element that contains the attribute | |
attributeName | attribute to look for |
Definition at line 281 of file XMLParser.cpp.
References FesaErrorOpenXMLFile, fileName_, fesa::AttributeXML::name_, and fesa::AttributeXML::value_.
Referenced by fesa::ThreadPriorityConfigurationFromFile::getPrioCMW(), fesa::ThreadPriorityConfigurationFromFile::getPrioEventSource(), fesa::ThreadPriorityConfigurationFromFile::getPrioNotificationConsumer(), fesa::ThreadPriorityConfigurationFromFile::getPrioPersistence(), fesa::ThreadPriorityConfigurationFromFile::getPrioRTScheduler(), fesa::StoreManager::retrieveGlobalDeviceElement(), and fesa::InitializeDataStoreManager::retrieveGlobalDeviceElement().
std::vector< ElementXML * > * fesa::XMLParser::extractElements | ( | const std::string & | elementName | ) | [virtual] |
extracts information from an XML file by searching for a XML element name
Definition at line 273 of file XMLParser.cpp.
References extractElementsFromXPath().
Referenced by fesa::NotificationIDManager::loadNotificationIDCollection(), fesa::StoreManager::retrieveDeviceElements(), fesa::StoreManager::retrieveDomainStoreElements(), and fesa::StoreManager::retrieveGlobalDeviceElement().
std::vector< ElementXML * > * fesa::XMLParser::extractElementsFromXPath | ( | const std::string & | xpathExpr | ) | [virtual] |
Extracts information from an XML file by searching for an xPath expression.
xpathExpr | xpath expression to retrieve the elements |
Definition at line 207 of file XMLParser.cpp.
References FesaErrorOpenXMLFile, fileName_, and fillElement().
Referenced by extractElements(), fesa::ThreadPriorityConfigurationFromFile::getMaximumPrio(), fesa::InitializeDataStoreManager::getRollingManagerDepth(), fesa::EventsMappingLoader::loadEventsMapping(), fesa::InitializeDataStoreManager::retrieveDeviceElements(), fesa::InitializeDataStoreManager::retrieveDomainStoreElements(), and fesa::InitializeDataStoreManager::retrieveGlobalDeviceElement().
void fesa::XMLParser::fillElement | ( | xmlNodePtr | node, | |
ElementXML * | pElement | |||
) | [private] |
fills instance of the class ElementXML with nodes from an XML file
node | that contains the xml info | |
[out] | pElement | into which the info will be put |
Definition at line 155 of file XMLParser.cpp.
References fesa::ElementXML::attributeList_, fesa::ElementXML::childList_, fesa::AttributeXML::name_, fesa::ElementXML::name_, trimCarrierReturn(), fesa::AttributeXML::value_, and fesa::ElementXML::value_.
Referenced by extractElementsFromXPath().
void fesa::XMLParser::startDocument | ( | ) | [virtual] |
this method writes the xml directive into the file, starting the xml document
Definition at line 62 of file XMLParser.cpp.
References FesaErrorWritingToXMLFile, fileName_, MY_ENCODING, and writer_.
Referenced by fesa::StoreManager::store(), and fesa::NotificationIDManager::storeNotificationIDCollection().
void fesa::XMLParser::startElement | ( | const std::string | element | ) | [virtual] |
this method starts a new element tag
element | the tag of the element to start |
Definition at line 83 of file XMLParser.cpp.
References FesaErrorWritingToXMLFile, fileName_, and writer_.
Referenced by fesa::StoreManager::store(), fesa::StoreManager::storeFields(), and fesa::NotificationIDManager::storeNotificationIDCollection().
void fesa::XMLParser::trimCarrierReturn | ( | std::string & | s | ) | [private] |
removes carrier return from string
s | the string to remove the carrier from |
Definition at line 346 of file XMLParser.cpp.
Referenced by fillElement().
void fesa::XMLParser::writeAttribute | ( | const std::string | attributeName, | |
const std::string | attributeValue | |||
) | [virtual] |
this method adds an attribute to the current element that is being edited
attributeName | name of the attribute | |
attributeValue | value of the attribute |
Definition at line 145 of file XMLParser.cpp.
References FesaErrorWritingToXMLFile, fileName_, and writer_.
Referenced by fesa::StoreManager::store(), and fesa::StoreManager::storeFields().
void fesa::XMLParser::writeElement | ( | const std::string | element, | |
const std::string | elementValue | |||
) | [virtual] |
this method writes an element and its value into the current file
element | to write | |
elementValue | value of the element |
Definition at line 92 of file XMLParser.cpp.
References FesaErrorWritingToXMLFile, fileName_, and writer_.
Referenced by fesa::NotificationIDManager::storeNotificationIDCollection().
void fesa::XMLParser::writeNewline | ( | ) | [virtual] |
this method starts a new line in the xml document
Definition at line 128 of file XMLParser.cpp.
References ConvertInput(), FesaErrorWritingToXMLFile, fileName_, and writer_.
Referenced by fesa::StoreManager::store(), fesa::StoreManager::storeFields(), and fesa::NotificationIDManager::storeNotificationIDCollection().
void fesa::XMLParser::writeString | ( | const std::string | text | ) | [virtual] |
this method writes a string into the xml document
text | to write in the xml document |
Definition at line 112 of file XMLParser.cpp.
References ConvertInput(), FesaErrorWritingToXMLFile, fileName_, and writer_.
std::string fesa::XMLParser::fileName_ [private] |
path of the file
Definition at line 206 of file XMLParser.h.
Referenced by createFile(), endDocument(), endElement(), extractAttribute(), extractElementsFromXPath(), startDocument(), startElement(), writeAttribute(), writeElement(), writeNewline(), and writeString().
xmlTextWriterPtr fesa::XMLParser::writer_ [private] |
interface to write into the xml file
Definition at line 201 of file XMLParser.h.
Referenced by createFile(), endDocument(), endElement(), startDocument(), startElement(), writeAttribute(), writeElement(), writeNewline(), writeString(), and ~XMLParser().