Open
Graph Drawing
Framework

 v.2012.07
 

OgmlParser.h
Go to the documentation of this file.
1 /*
2  * $Revision: 2523 $
3  *
4  * last checkin:
5  * $Author: gutwenger $
6  * $Date: 2012-07-02 20:59:27 +0200 (Mon, 02 Jul 2012) $
7  ***************************************************************/
8 
45 #ifdef _MSC_VER
46 #pragma once
47 #endif
48 
49 //KK: Commented out the constraint stuff using //o
50 //CG: compound graph stuff has been removed with commit 2465
51 
52 #ifndef OGDF_OGML_PARSER_H
53 #define OGDF_OGML_PARSER_H
54 
55 #include <ogdf/fileformats/Ogml.h>
57 #include <ogdf/basic/Hashing.h>
58 #include <ogdf/basic/String.h>
61 
62 // constraints
63 //o#include <ogdf/Constraints.h>
64 
65 
66 namespace ogdf {
67 
68 //
69 // ---------- O g m l P a r s e r ------------------------
70 //
71 
75 {
76 private:
77 
78  // struct definitions for mapping of templates
79  struct OgmlNodeTemplate;
80  struct OgmlEdgeTemplate;
81  //struct OgmlLabelTemplate;
82 
83  struct OgmlSegment;
84 
85  class OgmlAttributeValue;
86  class OgmlAttribute;
87  class OgmlTag;
88 
89  friend ostream& operator<<(ostream& os, const OgmlParser::OgmlAttribute& oa);
90  friend ostream& operator<<(ostream& os, const OgmlParser::OgmlTag& ot);
91 
95 
96 
98  static void buildHashTables();
99 
101 
103 
112  int validate(const XmlTagObject *xmlTag, int ogmlTag);
113 
118  //bool validate(const char* fileName);
119 
121  void printValidityInfo(const OgmlTag &ot,
122  const XmlTagObject &xto,
123  int valStatus,
124  int line);
125 
132  //bool getXmlTagObjectById(XmlTagObject *recTag, String id, XmlTagObject *&xmlTag);
133 
139  bool checkGraphType(const XmlTagObject *xmlTag) const;
140 
142  bool isGraphHierarchical(const XmlTagObject *xmlTag) const;
143 
145  bool isNodeHierarchical(const XmlTagObject *xmlTag) const;
146 
148 
149 
150  // id hash tables
151  // required variables for building
152  // hash table with id from file and node
156  // hash table for bend-points
158 
159  // hash table for checking uniqueness of ids
160  // (key:) int = id in the created graph
161  // (info:) String = id in the ogml file
165 
166  // build methods
167 
169  bool buildGraph(Graph &G);
170 
172  bool buildCluster(
173  const XmlTagObject *rootTag,
174  Graph &G,
175  ClusterGraph &CG);
176 
179  const XmlTagObject *xmlTag,
180  cluster parent,
181  Graph &G,
182  ClusterGraph &CG);
183 
186  Graph &G,
188  const XmlTagObject *root);
189 
191  bool setLabelsRecursive(
192  Graph &G,
194  XmlTagObject *root);
195 
196  // helping pointer for constraints-loading
197  // this pointer is set in the building methods
198  // so we don't have to traverse the tree in buildConstraints
200 
201  // hashing lists for templates
202  // string = id
205  //Hashing<String, OgmlLabelTemplate> m_ogmlLabelTemplates;
206 
207  // auxiliary methods for mapping graph attributes
208 
211 
213  int getShapeAsInt(String s);
214 
217 
219  int getLineTypeAsInt(String s);
220 
222  int getImageStyleAsInt(String s);
223 
226 
227  // arrow style, actually a "boolean" function
228  // because it returns only 0 or 1 according to GDE
229  // sot <=> source or target
230  int getArrowStyleAsInt(String s, String sot);
231 
232  // the matching method to getArrowStyleAsInt
234 
235  // function that operates on a string
236  // the input string contains "&lt;" instead of "<"
237  // and "&gt;" instead of ">"
238  // to disable interpreting the string as xml-tags (by DinoXmlParser)
239  // so this function substitutes "<" for "&lt;"
241 
243  bool getIdFromString(String str, int &id);
244 
246  void validate(const char* fileName);
247 
248 public:
249 
252 
254 
255 
257 
263  bool read(
264  const char* fileName,
265  Graph &G,
266  ClusterGraph &CG);
267 
269 
276  bool read(
277  const char* fileName,
278  Graph &G,
279  ClusterGraph &CG,
281 
282 };//end class OGMLParser
283 
284 }//end namespace ogdf
285 
286 #endif
287