#include <ogdf/fileformats/DinoXmlParser.h>
Public Member Functions | |
| DinoXmlParser (const char *fileName) | |
| ~DinoXmlParser () | |
| void | addNewHashElement (const String &key, int info) |
| void | createParseTree () |
| const XmlTagObject & | getRootTag () const |
| bool | traversePath (const XmlTagObject &startTag, const Array< int > &infoIndexPath, const XmlTagObject *&targetTag) const |
| bool | findSonXmlTagObject (const XmlTagObject &father, int sonInfoIndex, const XmlTagObject *&son) const |
| bool | findBrotherXmlTagObject (const XmlTagObject ¤tTag, int brotherInfoIndex, const XmlTagObject *&brother) const |
| bool | findXmlAttributeObject (const XmlTagObject ¤tTag, int attributeInfoIndex, const XmlAttributeObject *&attribute) const |
| int | getInputFileLineCounter () const |
| void | printHashTable (ostream &os) |
Private Member Functions | |
| void | destroyParseTree (XmlTagObject *root) |
| XmlTagObject * | parse () |
| void | appendAttributeObject (XmlTagObject *tagObject, XmlAttributeObject *attributeObject) |
| void | appendSonTagObject (XmlTagObject *currentTagObject, XmlTagObject *sonTagObject) |
| HashedString * | hashString (const String &str) |
| void | printXmlTagObjectTree (ostream &os, const XmlTagObject &rootObject, int indent=0) const |
| void | printSpaces (ostream &os, int nOfSpaces) const |
Private Attributes | |
| XmlTagObject * | m_pRootTag |
| DinoXmlScanner * | m_pScanner |
| Hashing< String, int > | m_hashTable |
| int | m_hashTableInfoIndex |
| int | m_recursionDepth |
| Stack< String > | m_tagObserver |
Friends | |
| ostream & | operator<< (ostream &, const DinoXmlParser &) |
This class parses the XML input file and builds up a parse tree with linked elements XMLTagObject and XMLAttributeObject. The class DinoXmlScanner is used to get the token for the parse process.
Definition at line 307 of file DinoXmlParser.h.
| ogdf::DinoXmlParser::DinoXmlParser | ( | const char * | fileName | ) |
Constructor. Inside the constructor the scanner is generated.
| ogdf::DinoXmlParser::~DinoXmlParser | ( | ) |
Destructor; destroys the parse tree.
| void ogdf::DinoXmlParser::addNewHashElement | ( | const String & | key, | |
| int | info | |||
| ) | [inline] |
Creates a new hash element and inserts it into the hash table.
Definition at line 350 of file DinoXmlParser.h.
| void ogdf::DinoXmlParser::appendAttributeObject | ( | XmlTagObject * | tagObject, | |
| XmlAttributeObject * | attributeObject | |||
| ) | [private] |
Append attributeObject to list of attributes of tagObject.
| void ogdf::DinoXmlParser::appendSonTagObject | ( | XmlTagObject * | currentTagObject, | |
| XmlTagObject * | sonTagObject | |||
| ) | [private] |
Appends sonTagObject to the list of sons of currentTagObject.
| void ogdf::DinoXmlParser::createParseTree | ( | ) |
Creates the parse tree and anchors it in m_pRootTag. TODO: Should return a value to indicate if success.
| void ogdf::DinoXmlParser::destroyParseTree | ( | XmlTagObject * | root | ) | [private] |
Destroys the parse tree appended to root.
| bool ogdf::DinoXmlParser::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 NULL.
| bool ogdf::DinoXmlParser::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 NULL.
| bool ogdf::DinoXmlParser::findXmlAttributeObject | ( | const XmlTagObject & | currentTag, | |
| int | attributeInfoIndex, | |||
| const XmlAttributeObject *& | attribute | |||
| ) | const |
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 NULL.
| int ogdf::DinoXmlParser::getInputFileLineCounter | ( | ) | const [inline] |
Returns line number of the most recently read line of the input file.
Definition at line 410 of file DinoXmlParser.h.
| const XmlTagObject& ogdf::DinoXmlParser::getRootTag | ( | ) | const [inline] |
Allows (non modifying) access to the parse tree.
Definition at line 362 of file DinoXmlParser.h.
| HashedString* ogdf::DinoXmlParser::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.
| XmlTagObject* ogdf::DinoXmlParser::parse | ( | ) | [private] |
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.
| void ogdf::DinoXmlParser::printHashTable | ( | ostream & | os | ) |
Prints the content of the hash table to os.
| void ogdf::DinoXmlParser::printSpaces | ( | ostream & | os, | |
| int | nOfSpaces | |||
| ) | const [private] |
Little helper that prints nOfSpaces space characters.
| void ogdf::DinoXmlParser::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.
| bool ogdf::DinoXmlParser::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. 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.
| ostream& operator<< | ( | ostream & | , | |
| const DinoXmlParser & | ||||
| ) | [friend] |
Output operator for DinoXmlParser.
Hashing<String,int> ogdf::DinoXmlParser::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 324 of file DinoXmlParser.h.
int ogdf::DinoXmlParser::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 330 of file DinoXmlParser.h.
XmlTagObject* ogdf::DinoXmlParser::m_pRootTag [private] |
Pointer to the root element of the parse tree.
Definition at line 314 of file DinoXmlParser.h.
DinoXmlScanner* ogdf::DinoXmlParser::m_pScanner [private] |
Pointer to the scanner.
Definition at line 317 of file DinoXmlParser.h.
int ogdf::DinoXmlParser::m_recursionDepth [private] |
Recursion depth of parse().
Definition at line 333 of file DinoXmlParser.h.
Stack<String> ogdf::DinoXmlParser::m_tagObserver [private] |
stack for checking correctness of correspondent closing tags
Definition at line 335 of file DinoXmlParser.h.