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 #include <ogdf/fileformats/Tlp.h>
40 
41 #include <iostream>
42 #include <map>
43 #include <sstream>
44 #include <string>
45 
46 namespace ogdf {
47 
48 namespace tlp {
49 
50 
51 class Parser {
52 private:
53  using Iterator = std::vector<Token>::const_iterator;
54  std::map<int, node> m_idNode;
55  std::map<int, edge> m_idEdge;
56 
57  std::istream& m_istream;
59 
60  bool readEdge(Graph& G);
61  bool readNodes(Graph& G, ClusterGraph* C, cluster c);
62  bool readCluster(Graph& G, ClusterGraph* C, cluster c);
63  bool readProperty(Graph& G, GraphAttributes* GA);
64 
67  bool readPropertyStatement(GraphAttributes* GA, const Attribute& attr, NodeArray<bool>& nodeDone,
68  std::string& nodeDefault, EdgeArray<bool>& edgeDone, std::string& edgeDefault);
69 
70  bool readGraph(Graph& G, GraphAttributes* GA, ClusterGraph* C);
71 
72  inline bool applyNodes(Graph& G, ClusterGraph* C, cluster c, const std::string& str);
73  inline void tokenError(const char* str, bool got = true);
74  inline void tokenError(const std::string& str, bool got = true);
75 
76 public:
77  explicit Parser(std::istream& is);
78 
79  bool read(Graph& G) { return readGraph(G, nullptr, nullptr); }
80 
81  bool read(Graph& G, GraphAttributes& GA) { return readGraph(G, &GA, nullptr); }
82 
83  bool read(Graph& G, ClusterGraph& C) { return readGraph(G, nullptr, &C); }
84 
86  return readGraph(G, &CA, &C);
87  }
88 };
89 
90 }
91 }
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::tlp::Parser::m_istream
std::istream & m_istream
Definition: TlpParser.h:57
Graph.h
Includes declaration of graph class.
ogdf::tlp::Parser::m_begin
Iterator m_begin
Definition: TlpParser.h:58
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:85
ogdf::tlp::Parser::read
bool read(Graph &G)
Definition: TlpParser.h:79
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:53
Tlp.h
Declaration of TLP string conversion functions.
ogdf::tlp::Parser::readStatement
bool readStatement(Graph &G, GraphAttributes *GA, ClusterGraph *C)
ogdf::ClusterElement
Representation of clusters in a clustered graph.
Definition: ClusterGraph.h:55
ogdf::ClusterGraphAttributes
Stores additional attributes of a clustered graph (like layout information).
Definition: ClusterGraphAttributes.h:46
ogdf::tlp::Attribute
Attribute
Definition: Tlp.h:41
TlpLexer.h
Declares a TLP file format lexer class and related structures.
ogdf::internal::GraphRegisteredArray
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition: Graph_d.h:651
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:862
ogdf::tlp::Parser
Definition: TlpParser.h:51
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:83
ogdf::tlp::Parser::m_end
Iterator m_end
Definition: TlpParser.h:58
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:55
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:81
ogdf::ClusterGraph
Representation of clustered graphs.
Definition: ClusterGraph.h:339
ogdf::tlp::Parser::m_idNode
std::map< int, node > m_idNode
Definition: TlpParser.h:54
ogdf::internal::EdgeArrayBase2
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
Definition: Graph_d.h:709