6 * $Date: 2012-07-02 20:59:27 +0200 (Mon, 02 Jul 2012) $
7 ***************************************************************/
10 * \brief Declaration of class XmlObject.
12 * \author Sebastian Leipert and Carsten Gutwenger
15 * This file is part of the Open Graph Drawing Framework (OGDF).
19 * See README.txt in the root directory of the OGDF installation for details.
22 * This program is free software; you can redistribute it and/or
23 * modify it under the terms of the GNU General Public License
24 * Version 2 or 3 as published by the Free Software Foundation;
25 * see the file LICENSE.txt included in the packaging of this file
29 * This program is distributed in the hope that it will be useful,
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 * GNU General Public License for more details.
35 * You should have received a copy of the GNU General Public
36 * License along with this program; if not, write to the Free
37 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
38 * Boston, MA 02110-1301, USA.
40 * \see http://www.gnu.org/copyleft/gpl.html
41 ***************************************************************/
48 #ifndef OGDF_XML_OBJECT_H
49 #define OGDF_XML_OBJECT_H
56 typedef HashElement
<String
,int> *XmlKey
;
57 enum XmlObjectType
{ xmlIntValue
, xmlDoubleValue
, xmlStringValue
, xmlListBegin
,
58 xmlListEnd
, xmlKey
, xmlEOF
, xmlError
};
61 //---------------------------------------------------------
63 // represents node in XML parse tree
64 //---------------------------------------------------------
65 struct OGDF_EXPORT XmlObject
{
67 XmlObject
*m_pBrother
; // brother of node in tree
68 XmlKey m_key
; // tag of node
69 XmlObjectType m_valueType
; // type of node
71 // the entry in the union is selected according to m_valueType:
72 // xmlIntValue -> m_intValue
73 // xmlDoubleValue -> m_doubleValue
74 // xmlStringValue -> m_stringValue
75 // xmlListBegin -> m_pFirstSon (in case of a list, m_pFirstSon is pointer
76 // to first son and the sons are chained by m_pBrother)
80 const char *m_stringValue
;
81 XmlObject
*m_pFirstSon
;
86 // Some Reference on the XML notation:
87 // XML consists of one or more elements.
88 // An element is marked with the following form:
92 // The opening <body> and the closing </body> are the tags
93 // of the element. The text between the two tags is considered
94 // part of the element.
95 // Elemets can have attributes applied, e.g.
96 // <body style="bold">blablabla</body>
97 // The attribute is specified inside the opening tag
98 // and is called "style". It is given a value "bold" which is expressed
99 // inside quotation marks.
103 // Stores the "tag" of an XML element
104 XmlObject(XmlKey key
) : m_pBrother(0), m_key(key
),
105 m_valueType(xmlListBegin
), m_pFirstSon(0) { }
107 // Stores an integer "attribute" of an XML element
108 XmlObject(XmlKey key
, int intValue
) : m_pBrother(0), m_key(key
),
109 m_valueType(xmlIntValue
), m_intValue(intValue
) { }
111 // Stores a double "attribute" of an XML element
112 XmlObject(XmlKey key
, double doubleValue
) : m_pBrother(0), m_key(key
),
113 m_valueType(xmlDoubleValue
), m_doubleValue(doubleValue
) { }
115 // Stores a string "attribute" of an XML element
116 XmlObject(XmlKey key
, const char *stringValue
) : m_pBrother(0), m_key(key
),
117 m_valueType(xmlStringValue
), m_stringValue(stringValue
) { }
119 // Stores the body of the element
120 XmlObject(const char *stringValue
) : m_pBrother(0), m_key(0),
121 m_valueType(xmlStringValue
), m_stringValue(stringValue
) { }
127 } // end namespace ogdf