Open
Graph Drawing
Framework

 v. 2020.02 (Catalpa)
 

TlpParser.h
Go to the documentation of this file.
1 
32 #pragma once
33 
34 #include <ogdf/basic/Graph.h>
38 #include <ogdf/fileformats/Tlp.h>
40 
41 #include <iostream>
42 #include <string>
43 #include <sstream>
44 #include <map>
45 
46 
47 namespace ogdf {
48 
49 namespace tlp {
50 
51 
52 class Parser {
53 private:
54  using Iterator = std::vector<Token>::const_iterator;
55  std::map<int, node> m_idNode;
56  std::map<int, edge> m_idEdge;
57 
58  std::istream &m_istream;
60 
61  bool readEdge(Graph &G);
62  bool readNodes(Graph &G, ClusterGraph *C, cluster c);
63  bool readCluster(Graph &G, ClusterGraph *C, cluster c);
64  bool readProperty(Graph &G, GraphAttributes *GA);
65 
67  Graph &G, ClusterGraph *C, cluster c);
68  bool readStatement(
69  Graph &G, GraphAttributes *GA, ClusterGraph *C);
71  GraphAttributes *GA, const Attribute &attr,
72  NodeArray<bool> &nodeDone, std::string &nodeDefault,
73  EdgeArray<bool> &edgeDone, std::string &edgeDefault);
74 
75  bool readGraph(Graph &G, GraphAttributes *GA, ClusterGraph *C);
76 
77  inline bool applyNodes(
78  Graph &G, ClusterGraph *C, cluster c,
79  const std::string &str);
80  inline void tokenError(const char *str, bool got = true);
81  inline void tokenError(const std::string &str, bool got = true);
82 
83 public:
84  explicit Parser(std::istream &is);
85 
86  bool read(Graph &G) {
87  return readGraph(G, nullptr, nullptr);
88  }
89 
90  bool read(Graph &G, GraphAttributes &GA) {
91  return readGraph(G, &GA, nullptr);
92  }
93 
94  bool read(Graph &G, ClusterGraph &C) {
95  return readGraph(G, nullptr, &C);
96  }
97 
99  return readGraph(G, &CA, &C);
100  }
101 };
102 
103 }
104 }
bool read(Graph &G)
Definition: TlpParser.h:86
std::map< int, node > m_idNode
Definition: TlpParser.h:55
Attribute
Definition: Tlp.h:42
Declaration of class GraphAttributes which extends a Graph by additional attributes.
Derived class of GraphObserver providing additional functionality to handle clustered graphs...
std::istream & m_istream
Definition: TlpParser.h:58
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:492
std::vector< Token >::const_iterator Iterator
Definition: TlpParser.h:54
void tokenError(const char *str, bool got=true)
Iterator m_begin
Definition: TlpParser.h:59
bool read(Graph &G, ClusterGraph &C, ClusterGraphAttributes &CA)
Definition: TlpParser.h:98
bool readPropertyStatement(GraphAttributes *GA, const Attribute &attr, NodeArray< bool > &nodeDone, std::string &nodeDefault, EdgeArray< bool > &edgeDone, std::string &edgeDefault)
Representation of clustered graphs.
Definition: ClusterGraph.h:291
bool applyNodes(Graph &G, ClusterGraph *C, cluster c, const std::string &str)
bool readStatement(Graph &G, GraphAttributes *GA, ClusterGraph *C)
bool readNodes(Graph &G, ClusterGraph *C, cluster c)
Stores additional attributes of a graph (like layout information).
bool read(Graph &G, ClusterGraph &C)
Definition: TlpParser.h:94
Stores additional attributes of a clustered graph (like layout information).
bool readGraph(Graph &G, GraphAttributes *GA, ClusterGraph *C)
std::map< int, edge > m_idEdge
Definition: TlpParser.h:56
Declares ClusterGraphAttributes, an extension of class GraphAttributes, to store clustergraph layout ...
Representation of clusters in a clustered graph.
Definition: ClusterGraph.h:53
Includes declaration of graph class.
Declaration of TLP string conversion functions.
Iterator m_end
Definition: TlpParser.h:59
bool readEdge(Graph &G)
Parser(std::istream &is)
bool readClusterStatement(Graph &G, ClusterGraph *C, cluster c)
The namespace for all OGDF objects.
bool readProperty(Graph &G, GraphAttributes *GA)
bool read(Graph &G, GraphAttributes &GA)
Definition: TlpParser.h:90
bool readCluster(Graph &G, ClusterGraph *C, cluster c)
Declares a TLP file format lexer class and related structures.