Open
Graph Drawing
Framework

 v.2012.05
 

XmlObject.h
Go to the documentation of this file.
00001 /*
00002  * $Revision: 2299 $
00003  * 
00004  * last checkin:
00005  *   $Author: gutwenger $ 
00006  *   $Date: 2012-05-07 15:57:08 +0200 (Mon, 07 May 2012) $ 
00007  ***************************************************************/
00008  
00043 #ifdef _MSC_VER
00044 #pragma once
00045 #endif
00046 
00047 #ifndef OGDF_XML_OBJECT_H
00048 #define OGDF_XML_OBJECT_H
00049 
00050 
00051 
00052 namespace ogdf {
00053 
00054 
00055 typedef HashElement<String,int> *XmlKey;
00056 enum XmlObjectType { xmlIntValue, xmlDoubleValue, xmlStringValue, xmlListBegin,
00057     xmlListEnd, xmlKey, xmlEOF, xmlError };
00058 
00059 
00060 //---------------------------------------------------------
00061 // XmlObject
00062 // represents node in XML parse tree
00063 //---------------------------------------------------------
00064 struct OGDF_EXPORT XmlObject {
00065 
00066     XmlObject *m_pBrother; // brother of node in tree
00067     XmlKey m_key; // tag of node
00068     XmlObjectType m_valueType; // type of node
00069 
00070     // the entry in the union is selected according to m_valueType:
00071     //   xmlIntValue -> m_intValue
00072     //   xmlDoubleValue -> m_doubleValue
00073     //   xmlStringValue -> m_stringValue
00074     //   xmlListBegin -> m_pFirstSon (in case of a list, m_pFirstSon is pointer
00075     //     to first son and the sons are chained by m_pBrother)
00076     union {
00077         int m_intValue;
00078         double m_doubleValue;
00079         const char *m_stringValue;
00080         XmlObject *m_pFirstSon;
00081     };
00082 
00083     // construction
00084 
00085     // Some Reference on the XML notation:
00086     // XML consists of one or more elements.
00087     // An element is marked with the following form:
00088     //      <body>
00089     //      elementinformation
00090     //      </body>
00091     // The opening <body> and the closing </body> are the tags
00092     // of the element. The text between the two tags is considered
00093     // part of the element.
00094     // Elemets can have attributes applied, e.g.
00095     //      <body style="bold">blablabla</body>
00096     // The attribute is specified inside the opening tag
00097     // and is called "style". It is given a value "bold" which is expressed
00098     // inside quotation marks.
00099 
00100 
00101 
00102     // Stores the "tag" of an XML element   
00103     XmlObject(XmlKey key) : m_pBrother(0), m_key(key),
00104         m_valueType(xmlListBegin), m_pFirstSon(0)  { }
00105     
00106     // Stores an integer "attribute" of an XML element
00107     XmlObject(XmlKey key, int intValue) : m_pBrother(0), m_key(key),
00108         m_valueType(xmlIntValue), m_intValue(intValue)  { }
00109 
00110     // Stores a double "attribute" of an XML element
00111     XmlObject(XmlKey key, double doubleValue) : m_pBrother(0), m_key(key),
00112         m_valueType(xmlDoubleValue), m_doubleValue(doubleValue)  { }
00113 
00114     // Stores a string "attribute" of an XML element
00115     XmlObject(XmlKey key, const char *stringValue) : m_pBrother(0), m_key(key),
00116         m_valueType(xmlStringValue), m_stringValue(stringValue)  { }
00117 
00118     // Stores the body of the element
00119     XmlObject(const char *stringValue) : m_pBrother(0), m_key(0),
00120         m_valueType(xmlStringValue), m_stringValue(stringValue)  { }
00121 
00122 
00123     OGDF_NEW_DELETE
00124 };
00125 
00126 } // end namespace ogdf
00127 
00128 #endif