Open
Graph Drawing
Framework

 v. 2020.02 (Catalpa)
 

GmlParser.h
Go to the documentation of this file.
1 
32 #pragma once
33 
37 #include <ogdf/fileformats/GML.h>
38 
39 namespace ogdf {
40 
41 namespace gml {
42 
45  Object *pBrother; // brother of node in tree
46  Key key; // tag of node
47  ObjectType valueType; // type of node
48 
49  // the entry in the union is selected according to m_valueType:
50  // IntValue -> m_intValue
51  // DoubleValue -> m_doubleValue
52  // StringValue -> m_stringValue
53  // ListBegin -> m_pFirstSon (in case of a list, m_pFirstSon is pointer
54  // to first son and the sons are chained by m_pBrother)
55  union {
56  int intValue;
57  double doubleValue;
58  const char *stringValue;
60  };
61 
62  // construction
63  Object(Key k, int value) : pBrother(nullptr), key(k),
64  valueType(ObjectType::IntValue), intValue(value) { }
65 
66  Object(Key k, double value) : pBrother(nullptr), key(k),
67  valueType(ObjectType::DoubleValue), doubleValue(value) { }
68 
69  Object(Key k, const char *value) : pBrother(nullptr), key(k),
70  valueType(ObjectType::StringValue), stringValue(value) { }
71 
72  Object(Key k) : pBrother(nullptr), key(k),
73  valueType(ObjectType::ListBegin), pFirstSon(nullptr) { }
74 
76 };
77 
78 
81  std::istream *m_is;
82  bool m_error;
83 
84  char *m_rLineBuffer, *m_lineBuffer, *m_pCurrent, *m_pStore, m_cStore;
85 
88  const char *m_stringSymbol;
90  string m_longString;
91 
92  Object *m_objectTree; // root node of GML parse tree
93 
94  bool m_doCheck;
97 
98 public:
99  // construction: creates object tree
100  // sets m_error flag if an error occured
101  explicit Parser(std::istream &is, bool doCheck = false);
102 
104  ~Parser();
105 
106  // true <=> an error in GML files has been detected
107  bool error() const { return m_error; }
108 
109  // creates graph from GML parse tree
110  bool read(Graph &G);
111  // creates attributed graph from GML parse tree
112  bool read(Graph &G, GraphAttributes &GA);
113 
114  //read only cluster part of object tree and create cluster graph structure
115  bool readCluster(Graph &G, ClusterGraph &CG, ClusterGraphAttributes *ACG = nullptr);
116 
117 protected:
118 
120  bool recursiveClusterRead(
121  Object* clusterObject,
122  ClusterGraph& CG,
123  cluster c,
124  ClusterGraphAttributes* ACG = nullptr);
125 
126 private:
127  void createObjectTree(std::istream &is, bool doCheck);
128  void setError(const char *errorString, Logger::Level level = Logger::Level::Default);
129 
130  Object *parseList(ObjectType closingKey);
131  ObjectType getNextSymbol();
132  bool getLine();
133 
134  Object *getNodeIdRange(int &minId,int &maxId);
135  void readLineAttribute(Object *object, DPolyline &dpl);
136 
137  void destroyObjectList(Object *object);
138 };
139 
140 }
141 
142 }
Declaration of class GraphAttributes which extends a Graph by additional attributes.
Derived class of GraphObserver providing additional functionality to handle clustered graphs...
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:492
GML related enums and string conversion functions.
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:99
double doubleValue
Definition: GmlParser.h:57
Key
Definition: GML.h:55
bool error() const
Definition: GmlParser.h:107
Object(Key k, double value)
Definition: GmlParser.h:66
ObjectType
Definition: GML.h:44
Object(Key k, int value)
Definition: GmlParser.h:63
const char * stringValue
Definition: GmlParser.h:58
Representation of clustered graphs.
Definition: ClusterGraph.h:291
Object * m_objectTree
Definition: GmlParser.h:92
Object * pBrother
Definition: GmlParser.h:45
Reads GML file and constructs GML parse tree.
Definition: GmlParser.h:80
Stores additional attributes of a graph (like layout information).
ObjectType valueType
Definition: GmlParser.h:47
const char * m_stringSymbol
Definition: GmlParser.h:88
Stores additional attributes of a clustered graph (like layout information).
double m_doubleSymbol
Definition: GmlParser.h:87
Polylines with PointType points.
Definition: geometry.h:263
Object * m_graphObject
Definition: GmlParser.h:96
#define OGDF_NEW_DELETE
Makes the class use OGDF&#39;s memory allocator.
Definition: memory.h:84
char * m_rLineBuffer
Definition: GmlParser.h:84
string m_longString
Definition: GmlParser.h:90
Declares ClusterGraphAttributes, an extension of class GraphAttributes, to store clustergraph layout ...
Representation of clusters in a clustered graph.
Definition: ClusterGraph.h:53
Level
supported log-levels from lowest to highest importance
Definition: Logger.h:103
Object(Key k, const char *value)
Definition: GmlParser.h:69
The namespace for all OGDF objects.
Array< node > m_mapToNode
Definition: GmlParser.h:95
std::istream * m_is
Definition: GmlParser.h:81
Object * pFirstSon
Definition: GmlParser.h:59
Represents node in GML parse tree.
Definition: GmlParser.h:44