This class parses the XML input file and builds up a parse tree with linked elements XMLTagObject and XMLAttributeObject.
More...
#include <ogdf/fileformats/XmlParser.h>
|
| | XmlParser (istream &is) |
| | Constructor. More...
|
| |
| | ~XmlParser () |
| | Destructor; destroys the parse tree. More...
|
| |
| void | addNewHashElement (const string &key, int info) |
| | Creates a new hash element and inserts it into the hash table. More...
|
| |
| bool | createParseTree () |
| | Creates the parse tree and anchors it in m_pRootTag. More...
|
| |
| bool | findBrotherXmlTagObject (const XmlTagObject ¤tTag, int brotherInfoIndex, const XmlTagObject *&brother) const |
| | Searches for a specific brother (identified by brotherInfoIndex) of current. More...
|
| |
| bool | findSonXmlTagObject (const XmlTagObject &father, int sonInfoIndex, const XmlTagObject *&son) const |
| | Searches for a specific son (identified by sonInfoIndex) of father. More...
|
| |
| bool | findXmlAttributeObject (const XmlTagObject ¤tTag, int attributeInfoIndex, const XmlAttributeObject *&attribute) const |
| | Searches for a specific attribute (identified by attributeInfoIndex) of current. More...
|
| |
| int | getInputFileLineCounter () const |
| | Returns line number of the most recently read line of the input file. More...
|
| |
| const XmlTagObject & | getRootTag () const |
| | Allows (non modifying) access to the parse tree. More...
|
| |
| void | printHashTable (ostream &os) |
| | Prints the content of the hash table to os. More...
|
| |
| bool | traversePath (const XmlTagObject &startTag, const Array< int > &infoIndexPath, const XmlTagObject *&targetTag) const |
| | Traverses the parseTree starting at startTag using the path description in path, which contains the infoIndices of the tags which have to be traversed. More...
|
| |
This class parses the XML input file and builds up a parse tree with linked elements XMLTagObject and XMLAttributeObject.
The class XmlScanner is used to get the token for the parse process.
Definition at line 269 of file XmlParser.h.
◆ XmlParser()
| ogdf::XmlParser::XmlParser |
( |
istream & |
is | ) |
|
|
explicit |
Constructor.
Inside the constructor the scanner is generated.
◆ ~XmlParser()
| ogdf::XmlParser::~XmlParser |
( |
| ) |
|
Destructor; destroys the parse tree.
◆ addNewHashElement()
| void ogdf::XmlParser::addNewHashElement |
( |
const string & |
key, |
|
|
int |
info |
|
) |
| |
|
inline |
Creates a new hash element and inserts it into the hash table.
Definition at line 311 of file XmlParser.h.
◆ appendAttributeObject()
Append attributeObject to list of attributes of tagObject.
◆ appendSonTagObject()
Appends sonTagObject to the list of sons of currentTagObject.
◆ createParseTree()
| bool ogdf::XmlParser::createParseTree |
( |
| ) |
|
Creates the parse tree and anchors it in m_pRootTag.
returns true to indicate if success; false if parse error.
◆ destroyParseTree()
| void ogdf::XmlParser::destroyParseTree |
( |
XmlTagObject * |
root | ) |
|
|
private |
Destroys the parse tree appended to root.
◆ findBrotherXmlTagObject()
| bool ogdf::XmlParser::findBrotherXmlTagObject |
( |
const XmlTagObject & |
currentTag, |
|
|
int |
brotherInfoIndex, |
|
|
const XmlTagObject *& |
brother |
|
) |
| const |
Searches for a specific brother (identified by brotherInfoIndex) of current.
Returns the brother via the referenced pointer brother. Returns true if brother is found. Returns false otherwise, brother is set to nullptr.
◆ findSonXmlTagObject()
| bool ogdf::XmlParser::findSonXmlTagObject |
( |
const XmlTagObject & |
father, |
|
|
int |
sonInfoIndex, |
|
|
const XmlTagObject *& |
son |
|
) |
| const |
Searches for a specific son (identified by sonInfoIndex) of father.
Returns the son via the referenced pointer son. Returns true if son is found. Returns false otherwise, son is set to nullptr.
◆ findXmlAttributeObject()
Searches for a specific attribute (identified by attributeInfoIndex) of current.
Returns the attribute via the referenced pointer attribute. Returns true if attribute is found. Returns false otherwise, attribute is set to nullptr.
◆ getInputFileLineCounter()
| int ogdf::XmlParser::getInputFileLineCounter |
( |
| ) |
const |
|
inline |
Returns line number of the most recently read line of the input file.
Definition at line 375 of file XmlParser.h.
◆ getRootTag()
Allows (non modifying) access to the parse tree.
Definition at line 323 of file XmlParser.h.
◆ hashString()
| HashedString* ogdf::XmlParser::hashString |
( |
const string & |
str | ) |
|
|
private |
Returns the hash element for the given string.
If the key str is not contained in the table yet, it is inserted together with a new info index and the new hash element is returned. If the key str exists, the associated hash element is returned.
◆ parse()
Parses the token stream provided by the scanner until a complete XmlTagObject is identified which will be returned.
This function is likely to be called recursively due to the recursive structure of XML documents.
◆ printHashTable()
| void ogdf::XmlParser::printHashTable |
( |
ostream & |
os | ) |
|
Prints the content of the hash table to os.
◆ printSpaces()
| void ogdf::XmlParser::printSpaces |
( |
ostream & |
os, |
|
|
int |
nOfSpaces |
|
) |
| const |
|
private |
Little helper that prints nOfSpaces space characters.
◆ printXmlTagObjectTree()
| void ogdf::XmlParser::printXmlTagObjectTree |
( |
ostream & |
os, |
|
|
const XmlTagObject & |
rootObject, |
|
|
int |
indent = 0 |
|
) |
| const |
|
private |
Prints the given XmlTagObject and its children recursively.
The parameter indent is used as indentation value.
◆ reportError()
| void ogdf::XmlParser::reportError |
( |
const char * |
functionName, |
|
|
int |
sourceLine, |
|
|
const char * |
message, |
|
|
int |
inputFileLine = -1 |
|
) |
| |
|
private |
◆ traversePath()
Traverses the parseTree starting at startTag using the path description in path, which contains the infoIndices of the tags which have to be traversed.
If the XmlTagObject associated to the last infoIndex in the path is found, it is returned via targetTag and the return value is true If the XmlTagObject is not found the return value is false.
◆ operator<<
| ostream& operator<< |
( |
ostream & |
, |
|
|
const XmlParser & |
|
|
) |
| |
|
friend |
◆ m_hashTable
| Hashing<string,int> ogdf::XmlParser::m_hashTable |
|
private |
Hash table for storing names of TagObjects and AttributeObjects in an efficient manner.
The key element is string. The info element is int.
Definition at line 285 of file XmlParser.h.
◆ m_hashTableInfoIndex
| int ogdf::XmlParser::m_hashTableInfoIndex |
|
private |
The info element of the hash table is simply an integer number which is incremented for each new element (starting at 0).
The value m_hashTableInfoIndex - 1 is the last used index.
Definition at line 291 of file XmlParser.h.
◆ m_parseError
| bool ogdf::XmlParser::m_parseError |
|
private |
◆ m_pRootTag
Pointer to the root element of the parse tree.
Definition at line 275 of file XmlParser.h.
◆ m_pScanner
◆ m_recursionDepth
| int ogdf::XmlParser::m_recursionDepth |
|
private |
◆ m_tagObserver
| Stack<string> ogdf::XmlParser::m_tagObserver |
|
private |
stack for checking correctness of correspondent closing tags
Definition at line 296 of file XmlParser.h.
The documentation for this class was generated from the following file: