Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

TlpParser.h
Go to the documentation of this file.
1 
32 #pragma once
33 
34 #include <ogdf/basic/Graph.h>
38 
39 #include <iostream>
40 #include <map>
41 #include <string>
42 #include <vector>
43 
44 namespace ogdf::tlp {
45 enum class Attribute;
46 } // namespace ogdf::tlp
47 
48 namespace ogdf {
49 class GraphAttributes;
50 
51 namespace tlp {
52 
53 
54 class Parser {
55 private:
56  using Iterator = std::vector<Token>::const_iterator;
57  std::map<int, node> m_idNode;
58  std::map<int, edge> m_idEdge;
59 
60  std::istream& m_istream;
62 
63  bool readEdge(Graph& G);
64  bool readNodes(Graph& G, ClusterGraph* C, cluster c);
65  bool readCluster(Graph& G, ClusterGraph* C, cluster c);
66  bool readProperty(Graph& G, GraphAttributes* GA);
67 
70  bool readPropertyStatement(GraphAttributes* GA, const Attribute& attr, NodeArray<bool>& nodeDone,
71  std::string& nodeDefault, EdgeArray<bool>& edgeDone, std::string& edgeDefault);
72 
73  bool readGraph(Graph& G, GraphAttributes* GA, ClusterGraph* C);
74 
75  inline bool applyNodes(Graph& G, ClusterGraph* C, cluster c, const std::string& str);
76  inline void tokenError(const char* str, bool got = true);
77  inline void tokenError(const std::string& str, bool got = true);
78 
79 public:
80  explicit Parser(std::istream& is);
81 
82  bool read(Graph& G) { return readGraph(G, nullptr, nullptr); }
83 
84  bool read(Graph& G, GraphAttributes& GA) { return readGraph(G, &GA, nullptr); }
85 
86  bool read(Graph& G, ClusterGraph& C) { return readGraph(G, nullptr, &C); }
87 
89  return readGraph(G, &CA, &C);
90  }
91 };
92 
93 }
94 }
ogdf
The namespace for all OGDF objects.
Definition: multilevelmixer.cpp:39
ogdf::GraphAttributes
Stores additional attributes of a graph (like layout information).
Definition: GraphAttributes.h:72
ogdf::tlp::Parser::m_istream
std::istream & m_istream
Definition: TlpParser.h:60
Graph.h
Includes declaration of graph class.
ogdf::tlp::Parser::m_begin
Iterator m_begin
Definition: TlpParser.h:61
ogdf::tlp::Parser::readPropertyStatement
bool readPropertyStatement(GraphAttributes *GA, const Attribute &attr, NodeArray< bool > &nodeDone, std::string &nodeDefault, EdgeArray< bool > &edgeDone, std::string &edgeDefault)
ogdf::tlp::Parser::read
bool read(Graph &G, ClusterGraph &C, ClusterGraphAttributes &CA)
Definition: TlpParser.h:88
ogdf::tlp::Parser::read
bool read(Graph &G)
Definition: TlpParser.h:82
ogdf::tlp::Parser::tokenError
void tokenError(const char *str, bool got=true)
ogdf::tlp::Parser::Iterator
std::vector< Token >::const_iterator Iterator
Definition: TlpParser.h:56
ogdf::tlp::Parser::readStatement
bool readStatement(Graph &G, GraphAttributes *GA, ClusterGraph *C)
ogdf::ClusterElement
Representation of clusters in a clustered graph.
Definition: ClusterGraph.h:62
ogdf::ClusterGraphAttributes
Stores additional attributes of a clustered graph (like layout information).
Definition: ClusterGraphAttributes.h:52
ogdf::tlp::Attribute
Attribute
Definition: Tlp.h:41
TlpLexer.h
Declares a TLP file format lexer class and related structures.
ogdf::tlp
Definition: Tlp.h:38
ogdf::internal::GraphRegisteredArray
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition: Graph_d.h:658
ogdf::tlp::Parser::readClusterStatement
bool readClusterStatement(Graph &G, ClusterGraph *C, cluster c)
ogdf::Graph
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:869
ogdf::tlp::Parser
Definition: TlpParser.h:54
ogdf::tlp::Parser::readNodes
bool readNodes(Graph &G, ClusterGraph *C, cluster c)
ogdf::tlp::Parser::readProperty
bool readProperty(Graph &G, GraphAttributes *GA)
ogdf::tlp::Parser::Parser
Parser(std::istream &is)
ogdf::tlp::Parser::read
bool read(Graph &G, ClusterGraph &C)
Definition: TlpParser.h:86
ogdf::tlp::Parser::m_end
Iterator m_end
Definition: TlpParser.h:61
ogdf::tlp::Parser::readCluster
bool readCluster(Graph &G, ClusterGraph *C, cluster c)
ogdf::tlp::Parser::applyNodes
bool applyNodes(Graph &G, ClusterGraph *C, cluster c, const std::string &str)
ogdf::tlp::Parser::m_idEdge
std::map< int, edge > m_idEdge
Definition: TlpParser.h:58
ogdf::tlp::Parser::readEdge
bool readEdge(Graph &G)
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::tlp::Parser::readGraph
bool readGraph(Graph &G, GraphAttributes *GA, ClusterGraph *C)
ogdf::tlp::Parser::read
bool read(Graph &G, GraphAttributes &GA)
Definition: TlpParser.h:84
ogdf::ClusterGraph
Representation of clustered graphs.
Definition: ClusterGraph.h:346
ogdf::tlp::Parser::m_idNode
std::map< int, node > m_idNode
Definition: TlpParser.h:57
ogdf::internal::EdgeArrayBase2
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
Definition: Graph_d.h:716