Open
Graph Drawing
Framework

 v.2010.10
 

Public Member Functions | Private Member Functions | Private Attributes | Friends

ogdf::DinoXmlParser Class Reference

#include <ogdf/fileformats/DinoXmlParser.h>

List of all members.

Public Member Functions

 DinoXmlParser (const char *fileName)
 ~DinoXmlParser ()
void addNewHashElement (const String &key, int info)
void createParseTree ()
const XmlTagObjectgetRootTag () 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 &currentTag, int brotherInfoIndex, const XmlTagObject *&brother) const
bool findXmlAttributeObject (const XmlTagObject &currentTag, int attributeInfoIndex, const XmlAttributeObject *&attribute) const
int getInputFileLineCounter () const
void printHashTable (ostream &os)

Private Member Functions

void destroyParseTree (XmlTagObject *root)
XmlTagObjectparse ()
void appendAttributeObject (XmlTagObject *tagObject, XmlAttributeObject *attributeObject)
void appendSonTagObject (XmlTagObject *currentTagObject, XmlTagObject *sonTagObject)
HashedStringhashString (const String &str)
void printXmlTagObjectTree (ostream &os, const XmlTagObject &rootObject, int indent=0) const
void printSpaces (ostream &os, int nOfSpaces) const

Private Attributes

XmlTagObjectm_pRootTag
DinoXmlScannerm_pScanner
Hashing< String, int > m_hashTable
int m_hashTableInfoIndex
int m_recursionDepth
Stack< Stringm_tagObserver

Friends

ostream & operator<< (ostream &, const DinoXmlParser &)

Detailed Description

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.


Constructor & Destructor Documentation

ogdf::DinoXmlParser::DinoXmlParser ( const char *  fileName  ) 

Constructor. Inside the constructor the scanner is generated.

ogdf::DinoXmlParser::~DinoXmlParser (  ) 

Destructor; destroys the parse tree.


Member Function Documentation

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.


Friends And Related Function Documentation

ostream& operator<< ( ostream &  ,
const DinoXmlParser  
) [friend]

Output operator for DinoXmlParser.


Member Data Documentation

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.

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.

Pointer to the root element of the parse tree.

Definition at line 314 of file DinoXmlParser.h.

Pointer to the scanner.

Definition at line 317 of file DinoXmlParser.h.

Recursion depth of parse().

Definition at line 333 of file DinoXmlParser.h.

stack for checking correctness of correspondent closing tags

Definition at line 335 of file DinoXmlParser.h.


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