Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

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)
64  : pBrother(nullptr), key(k), valueType(ObjectType::IntValue), intValue(value) { }
65 
66  Object(Key k, double value)
67  : pBrother(nullptr), key(k), valueType(ObjectType::DoubleValue), doubleValue(value) { }
68 
69  Object(Key k, const char* value)
70  : pBrother(nullptr), key(k), valueType(ObjectType::StringValue), stringValue(value) { }
71 
73  : pBrother(nullptr), key(k), valueType(ObjectType::ListBegin), pFirstSon(nullptr) { }
74 
76 };
77 
80  std::istream* m_is;
81  bool m_error;
82 
83  char *m_rLineBuffer, *m_lineBuffer, *m_pCurrent, *m_pStore, m_cStore;
84 
87  const char* m_stringSymbol;
89  string m_longString;
90 
91  Object* m_objectTree; // root node of GML parse tree
92 
93  bool m_doCheck;
96 
97 public:
98  // construction: creates object tree
99  // sets m_error flag if an error occured
100  explicit Parser(std::istream& is, bool doCheck = false);
101 
103  ~Parser();
104 
105  // true <=> an error in GML files has been detected
106  bool error() const { return m_error; }
107 
108  // creates graph from GML parse tree
109  bool read(Graph& G);
110  // creates attributed graph from GML parse tree
111  bool read(Graph& G, GraphAttributes& GA);
112 
113  //read only cluster part of object tree and create cluster graph structure
114  bool readCluster(Graph& G, ClusterGraph& CG, ClusterGraphAttributes* ACG = nullptr);
115 
116 protected:
118  bool recursiveClusterRead(Object* clusterObject, ClusterGraph& CG, cluster c,
119  ClusterGraphAttributes* ACG = nullptr);
120 
121 private:
122  void createObjectTree(std::istream& is, bool doCheck);
123  void setError(const string& errorString, Logger::Level level = Logger::Level::Default);
124 
125  Object* parseList(ObjectType closingKey);
126  ObjectType getNextSymbol();
127  bool getLine();
128 
129  Object* getNodeIdRange(int& minId, int& maxId);
130  void readLineAttribute(Object* object, DPolyline& dpl);
131 
132  void destroyObjectList(Object* object);
133 };
134 
135 }
136 
137 }
ogdf::gml::Object::pBrother
Object * pBrother
Definition: GmlParser.h:45
ogdf
The namespace for all OGDF objects.
Definition: AugmentationModule.h:36
ogdf::GraphAttributes
Stores additional attributes of a graph (like layout information).
Definition: GraphAttributes.h:66
GraphAttributes.h
Declaration of class GraphAttributes which extends a Graph by additional attributes.
ogdf::gml::Object::key
Key key
Definition: GmlParser.h:46
ogdf::gml::Parser::m_is
std::istream * m_is
Definition: GmlParser.h:80
ogdf::gml::Parser::error
bool error() const
Definition: GmlParser.h:106
ogdf::GenericPolyline
Polylines with PointType points.
Definition: geometry.h:254
ogdf::gml::Key
Key
Definition: GML.h:55
GML.h
GML related enums and string conversion functions.
ogdf::gml::Object::Object
Object(Key k, const char *value)
Definition: GmlParser.h:69
ogdf::Logger::Level
Level
supported log-levels from lowest to highest importance
Definition: Logger.h:103
ogdf::gml::Object::Object
Object(Key k)
Definition: GmlParser.h:72
ogdf::gml::ObjectType::ListBegin
@ ListBegin
ogdf::gml::Object::valueType
ObjectType valueType
Definition: GmlParser.h:47
ogdf::gml::ObjectType::IntValue
@ IntValue
ogdf::Logger::Level::Default
@ Default
ogdf::gml::Parser::m_intSymbol
int m_intSymbol
Definition: GmlParser.h:85
OGDF_NEW_DELETE
#define OGDF_NEW_DELETE
Makes the class use OGDF's memory allocator.
Definition: memory.h:84
ogdf::gml::Parser::m_doCheck
bool m_doCheck
Definition: GmlParser.h:93
ogdf::gml::Parser::m_objectTree
Object * m_objectTree
Definition: GmlParser.h:91
ogdf::ClusterElement
Representation of clusters in a clustered graph.
Definition: ClusterGraph.h:55
ogdf::gml::Parser
Reads GML file and constructs GML parse tree.
Definition: GmlParser.h:79
ogdf::gml::Object
Represents node in GML parse tree.
Definition: GmlParser.h:44
ogdf::ClusterGraphAttributes
Stores additional attributes of a clustered graph (like layout information).
Definition: ClusterGraphAttributes.h:46
ogdf::gml::ObjectType
ObjectType
Definition: GML.h:44
ogdf::gml::Object::Object
Object(Key k, double value)
Definition: GmlParser.h:66
ogdf::gml::ObjectType::StringValue
@ StringValue
ogdf::gml::Object::stringValue
const char * stringValue
Definition: GmlParser.h:58
ogdf::gml::Object::pFirstSon
Object * pFirstSon
Definition: GmlParser.h:59
ogdf::Array< node >
ogdf::gml::Parser::m_graphObject
Object * m_graphObject
Definition: GmlParser.h:95
ogdf::gml::Parser::m_longString
string m_longString
Definition: GmlParser.h:89
ogdf::Graph
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:862
ogdf::gml::Parser::m_doubleSymbol
double m_doubleSymbol
Definition: GmlParser.h:86
ogdf::gml::Object::doubleValue
double doubleValue
Definition: GmlParser.h:57
ogdf::gml::Parser::m_mapToNode
Array< node > m_mapToNode
Definition: GmlParser.h:94
ogdf::gml::Object::intValue
int intValue
Definition: GmlParser.h:56
ogdf::gml::Parser::m_error
bool m_error
Definition: GmlParser.h:81
ogdf::gml::Parser::m_stringSymbol
const char * m_stringSymbol
Definition: GmlParser.h:87
ogdf::gml::Parser::m_keySymbol
Key m_keySymbol
Definition: GmlParser.h:88
OGDF_EXPORT
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:101
ClusterGraphAttributes.h
Declares ClusterGraphAttributes, an extension of class GraphAttributes, to store clustergraph layout ...
ClusterGraph.h
Derived class of GraphObserver providing additional functionality to handle clustered graphs.
ogdf::gml::Parser::m_rLineBuffer
char * m_rLineBuffer
Definition: GmlParser.h:83
ogdf::ClusterGraph
Representation of clustered graphs.
Definition: ClusterGraph.h:339
ogdf::gml::ObjectType::DoubleValue
@ DoubleValue
ogdf::gml::Object::Object
Object(Key k, int value)
Definition: GmlParser.h:63