Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
GmlParser.h
Go to the documentation of this file.
1
32#pragma once
33
34#include <ogdf/basic/Array.h>
35#include <ogdf/basic/Graph.h>
36#include <ogdf/basic/Logger.h>
37#include <ogdf/basic/basic.h>
38#include <ogdf/basic/geometry.h>
39#include <ogdf/basic/memory.h>
42
43#include <iosfwd>
44#include <string>
45
46namespace ogdf {
47class ClusterGraphAttributes;
48class GraphAttributes;
49
50namespace gml {
51
54 Object* pBrother; // brother of node in tree
55 Key key; // tag of node
56 ObjectType valueType; // type of node
57
58 // the entry in the union is selected according to m_valueType:
59 // IntValue -> m_intValue
60 // DoubleValue -> m_doubleValue
61 // StringValue -> m_stringValue
62 // ListBegin -> m_pFirstSon (in case of a list, m_pFirstSon is pointer
63 // to first son and the sons are chained by m_pBrother)
64 union {
67 const char* stringValue;
69 };
70
71 // construction
72 Object(Key k, int value)
73 : pBrother(nullptr), key(k), valueType(ObjectType::IntValue), intValue(value) { }
74
75 Object(Key k, double value)
76 : pBrother(nullptr), key(k), valueType(ObjectType::DoubleValue), doubleValue(value) { }
77
78 Object(Key k, const char* value)
79 : pBrother(nullptr), key(k), valueType(ObjectType::StringValue), stringValue(value) { }
80
82 : pBrother(nullptr), key(k), valueType(ObjectType::ListBegin), pFirstSon(nullptr) { }
83
85};
86
89 std::istream* m_is;
90 bool m_error;
91
92 char *m_rLineBuffer, *m_lineBuffer, *m_pCurrent, *m_pStore, m_cStore;
93
96 const char* m_stringSymbol;
99
100 Object* m_objectTree; // root node of GML parse tree
101
105
106public:
107 // construction: creates object tree
108 // sets m_error flag if an error occured
109 explicit Parser(std::istream& is, bool doCheck = false);
110
113
114 // true <=> an error in GML files has been detected
115 bool error() const { return m_error; }
116
117 // creates graph from GML parse tree
118 bool read(Graph& G);
119 // creates attributed graph from GML parse tree
121
122 //read only cluster part of object tree and create cluster graph structure
124
125protected:
127 bool recursiveClusterRead(Object* clusterObject, ClusterGraph& CG, cluster c,
128 ClusterGraphAttributes* ACG = nullptr);
129
130private:
131 void createObjectTree(std::istream& is, bool doCheck);
132 void setError(const string& errorString, Logger::Level level = Logger::Level::Default);
133
136 bool getLine();
137
138 Object* getNodeIdRange(int& minId, int& maxId);
139 void readLineAttribute(Object* object, DPolyline& dpl);
140
142};
143
144}
145
146}
Declaration and implementation of Array class and Array algorithms.
Derived class of GraphObserver providing additional functionality to handle clustered graphs.
GML related enums and string conversion functions.
Includes declaration of graph class.
Contains logging functionality.
Declaration of classes GenericPoint, GenericPolyline, GenericLine, GenericSegment,...
Basic declarations, included by all source files.
The parameterized class Array implements dynamic arrays of type E.
Definition Array.h:219
Representation of clusters in a clustered graph.
Stores additional attributes of a clustered graph (like layout information).
Representation of clustered graphs.
Polylines with PointType points.
Definition geometry.h:261
Stores additional attributes of a graph (like layout information).
Data type for general directed graphs (adjacency list representation).
Definition Graph_d.h:866
Level
supported log-levels from lowest to highest importance
Definition Logger.h:105
Reads GML file and constructs GML parse tree.
Definition GmlParser.h:88
void createObjectTree(std::istream &is, bool doCheck)
~Parser()
Destruction: destroys object tree.
Object * getNodeIdRange(int &minId, int &maxId)
Object * parseList(ObjectType closingKey)
Object * m_graphObject
Definition GmlParser.h:104
Array< node > m_mapToNode
Definition GmlParser.h:103
string m_longString
Definition GmlParser.h:98
Parser(std::istream &is, bool doCheck=false)
void setError(const string &errorString, Logger::Level level=Logger::Level::Default)
ObjectType getNextSymbol()
void readLineAttribute(Object *object, DPolyline &dpl)
std::istream * m_is
Definition GmlParser.h:89
bool readCluster(Graph &G, ClusterGraph &CG, ClusterGraphAttributes *ACG=nullptr)
double m_doubleSymbol
Definition GmlParser.h:95
bool read(Graph &G, GraphAttributes &GA)
bool read(Graph &G)
bool error() const
Definition GmlParser.h:115
bool recursiveClusterRead(Object *clusterObject, ClusterGraph &CG, cluster c, ClusterGraphAttributes *ACG=nullptr)
Reads cluster subtree information recursively.
const char * m_stringSymbol
Definition GmlParser.h:96
Object * m_objectTree
Definition GmlParser.h:100
void destroyObjectList(Object *object)
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF dynamic library (shared object / DLL),...
Definition config.h:117
#define OGDF_NEW_DELETE
Makes the class use OGDF's memory allocator.
Definition memory.h:85
Declaration of memory manager for allocating small pieces of memory.
ObjectType
Definition GML.h:45
The namespace for all OGDF objects.
Represents node in GML parse tree.
Definition GmlParser.h:53
ObjectType valueType
Definition GmlParser.h:56
Object(Key k, double value)
Definition GmlParser.h:75
Object(Key k, int value)
Definition GmlParser.h:72
Object(Key k, const char *value)
Definition GmlParser.h:78
Object * pFirstSon
Definition GmlParser.h:68
Object * pBrother
Definition GmlParser.h:54
const char * stringValue
Definition GmlParser.h:67