fesa::XMLParser Class Reference

This class offers functions to extract information from an XML file. It uses the xPath functions of the library libXML. More...

#include <XMLParser.h>

List of all members.

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 AttributeXMLextractAttribute (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

Detailed Description

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.


Constructor & Destructor Documentation

fesa::XMLParser::XMLParser ( const std::string &  fileName,
bool  validateFile 
)

constructor

Parameters:
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]

destructor

Definition at line 43 of file XMLParser.cpp.

References writer_.


Member Function Documentation

xmlChar * fesa::XMLParser::ConvertInput ( const char *  in,
const char *  encoding 
) [private]

converts a char array to a xmlChar array

Parameters:
in The char array
encoding the coding format
Returns:
the xmlChararray

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

Parameters:
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]
std::vector< ElementXML * > * fesa::XMLParser::extractElements ( const std::string &  elementName  )  [virtual]
std::vector< ElementXML * > * fesa::XMLParser::extractElementsFromXPath ( const std::string &  xpathExpr  )  [virtual]

Extracts information from an XML file by searching for an xPath expression.

Parameters:
xpathExpr xpath expression to retrieve the elements
Returns:
The child elements of the xPath expression. If error, null vector.

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

Parameters:
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

Parameters:
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

Parameters:
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

Parameters:
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

Parameters:
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

Parameters:
text to write in the xml document

Definition at line 112 of file XMLParser.cpp.

References ConvertInput(), FesaErrorWritingToXMLFile, fileName_, and writer_.


Member Data Documentation

std::string fesa::XMLParser::fileName_ [private]
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().


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

Generated on 18 Jan 2013 for Fesa by  doxygen 1.6.1