IFEM  90A354
Public Member Functions | Protected Member Functions | Private Member Functions | List of all members
XMLInputBase Class Referenceabstract

Base class for XML based input file parsing. More...

#include <XMLInputBase.h>

Inheritance diagram for XMLInputBase:
Inheritance graph
[legend]

Public Member Functions

bool readXML (const char *fileName, bool verbose=true)
 Reads an XML input file. More...
 
bool loadXML (const char *xml)
 Loads data from an XML-formatted text string. More...
 

Protected Member Functions

const tinyxml2::XMLElement * loadFile (tinyxml2::XMLDocument &doc, const char *fileName, bool verbose=false)
 Loads an XML input file into a tinyxml2::XMLDocument object. More...
 
virtual bool parse (const tinyxml2::XMLElement *elem)=0
 Parses a data section from an XML element.
 
virtual const char ** getPrioritizedTags () const
 Returns a list of prioritized XML-tags.
 

Private Member Functions

bool handlePriorityTags (const tinyxml2::XMLElement *base, std::vector< const tinyxml2::XMLElement * > &parsed, bool verbose)
 Handles the parsing order for certain XML-tags. More...
 

Detailed Description

Base class for XML based input file parsing.

This class is inherited by SIMadmin for input parsing handling, and can also be used by applications for pre-parsing of the input file.

Member Function Documentation

◆ handlePriorityTags()

bool XMLInputBase::handlePriorityTags ( const tinyxml2::XMLElement *  base,
std::vector< const tinyxml2::XMLElement * > &  parsed,
bool  verbose 
)
private

Handles the parsing order for certain XML-tags.

Parameters
[in]baseThe base tag containing the elements to be prioritized
[out]parsedVector of XML-elements that was parsed
[in]verboseIf true, print the tags being parsed

Certain tags need to be parsed before others. This method takes care of this. It is called by the readXML() method in order to read the top level tags in the required order. It can also be called by the application-specific SIM class prior to parsing its data blocks. In that case the getPrioritizedTags() method should be reimplemented by the sub-class to take care of the application-specific tags.

References IFEM::cout, getPrioritizedTags(), parse(), and eig::verbose.

Referenced by readXML().

◆ loadFile()

const tinyxml2::XMLElement * XMLInputBase::loadFile ( tinyxml2::XMLDocument &  doc,
const char *  fileName,
bool  verbose = false 
)
protected

Loads an XML input file into a tinyxml2::XMLDocument object.

Parameters
[out]docThe top-level node of the XML-file
[in]fileNameFile to read
[in]verboseIf true, print the file(s) being read
Returns
Pointer to the root element of the XML-file

References IFEM::cout, and eig::verbose.

Referenced by SIMinput::readTopologyOnly(), and readXML().

◆ loadXML()

bool XMLInputBase::loadXML ( const char *  xml)

Loads data from an XML-formatted text string.

This method is a convenience offered for unit testing only.

References parse().

◆ readXML()

bool XMLInputBase::readXML ( const char *  fileName,
bool  verbose = true 
)

Reads an XML input file.

Parameters
[in]fileNameFile to read
[in]verboseIf true, print the tags being parsed

References IFEM::cout, handlePriorityTags(), loadFile(), parse(), and eig::verbose.

Referenced by SIMadmin::read().


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