1.1 --- a/demo/lgf_demo.cc Mon Sep 29 12:34:08 2008 +0200
1.2 +++ b/demo/lgf_demo.cc Wed Oct 01 12:44:16 2008 +0200
1.3 @@ -44,7 +44,7 @@
1.4 SmartDigraph::Node s, t;
1.5
1.6 try {
1.7 - digraphReader("digraph.lgf", g). // read the directed graph into g
1.8 + digraphReader(g, "digraph.lgf"). // read the directed graph into g
1.9 arcMap("capacity", cap). // read the 'capacity' arc map into cap
1.10 node("source", s). // read 'source' node to s
1.11 node("target", t). // read 'target' node to t
1.12 @@ -60,7 +60,7 @@
1.13
1.14 std::cout << "We can write it to the standard output:" << std::endl;
1.15
1.16 - digraphWriter(std::cout, g). // write g to the standard output
1.17 + digraphWriter(g). // write g to the standard output
1.18 arcMap("capacity", cap). // write cap into 'capacity'
1.19 node("source", s). // write s to 'source'
1.20 node("target", t). // write t to 'target'
2.1 --- a/lemon/lgf_reader.h Mon Sep 29 12:34:08 2008 +0200
2.2 +++ b/lemon/lgf_reader.h Wed Oct 01 12:44:16 2008 +0200
2.3 @@ -390,13 +390,14 @@
2.4 class DigraphReader;
2.5
2.6 template <typename Digraph>
2.7 - DigraphReader<Digraph> digraphReader(std::istream& is, Digraph& digraph);
2.8 + DigraphReader<Digraph> digraphReader(Digraph& digraph,
2.9 + std::istream& is = std::cin);
2.10
2.11 template <typename Digraph>
2.12 - DigraphReader<Digraph> digraphReader(const std::string& fn, Digraph& digraph);
2.13 + DigraphReader<Digraph> digraphReader(Digraph& digraph, const std::string& fn);
2.14
2.15 template <typename Digraph>
2.16 - DigraphReader<Digraph> digraphReader(const char *fn, Digraph& digraph);
2.17 + DigraphReader<Digraph> digraphReader(Digraph& digraph, const char *fn);
2.18
2.19 /// \ingroup lemon_io
2.20 ///
2.21 @@ -419,7 +420,7 @@
2.22 /// rules.
2.23 ///
2.24 ///\code
2.25 - /// DigraphReader<Digraph>(std::cin, digraph).
2.26 + /// DigraphReader<Digraph>(digraph, std::cin).
2.27 /// nodeMap("coordinates", coord_map).
2.28 /// arcMap("capacity", cap_map).
2.29 /// node("source", src).
2.30 @@ -499,7 +500,7 @@
2.31 ///
2.32 /// Construct a directed graph reader, which reads from the given
2.33 /// input stream.
2.34 - DigraphReader(std::istream& is, Digraph& digraph)
2.35 + DigraphReader(Digraph& digraph, std::istream& is = std::cin)
2.36 : _is(&is), local_is(false), _digraph(digraph),
2.37 _use_nodes(false), _use_arcs(false),
2.38 _skip_nodes(false), _skip_arcs(false) {}
2.39 @@ -508,7 +509,7 @@
2.40 ///
2.41 /// Construct a directed graph reader, which reads from the given
2.42 /// file.
2.43 - DigraphReader(const std::string& fn, Digraph& digraph)
2.44 + DigraphReader(Digraph& digraph, const std::string& fn)
2.45 : _is(new std::ifstream(fn.c_str())), local_is(true), _digraph(digraph),
2.46 _use_nodes(false), _use_arcs(false),
2.47 _skip_nodes(false), _skip_arcs(false) {}
2.48 @@ -517,7 +518,7 @@
2.49 ///
2.50 /// Construct a directed graph reader, which reads from the given
2.51 /// file.
2.52 - DigraphReader(const char* fn, Digraph& digraph)
2.53 + DigraphReader(Digraph& digraph, const char* fn)
2.54 : _is(new std::ifstream(fn)), local_is(true), _digraph(digraph),
2.55 _use_nodes(false), _use_arcs(false),
2.56 _skip_nodes(false), _skip_arcs(false) {}
2.57 @@ -547,12 +548,12 @@
2.58
2.59 private:
2.60
2.61 - friend DigraphReader<Digraph> digraphReader<>(std::istream& is,
2.62 - Digraph& digraph);
2.63 - friend DigraphReader<Digraph> digraphReader<>(const std::string& fn,
2.64 - Digraph& digraph);
2.65 - friend DigraphReader<Digraph> digraphReader<>(const char *fn,
2.66 - Digraph& digraph);
2.67 + friend DigraphReader<Digraph> digraphReader<>(Digraph& digraph,
2.68 + std::istream& is);
2.69 + friend DigraphReader<Digraph> digraphReader<>(Digraph& digraph,
2.70 + const std::string& fn);
2.71 + friend DigraphReader<Digraph> digraphReader<>(Digraph& digraph,
2.72 + const char *fn);
2.73
2.74 DigraphReader(DigraphReader& other)
2.75 : _is(other._is), local_is(other.local_is), _digraph(other._digraph),
2.76 @@ -1180,8 +1181,9 @@
2.77 /// This function just returns a \ref DigraphReader class.
2.78 /// \relates DigraphReader
2.79 template <typename Digraph>
2.80 - DigraphReader<Digraph> digraphReader(std::istream& is, Digraph& digraph) {
2.81 - DigraphReader<Digraph> tmp(is, digraph);
2.82 + DigraphReader<Digraph> digraphReader(Digraph& digraph,
2.83 + std::istream& is = std::cin) {
2.84 + DigraphReader<Digraph> tmp(digraph, is);
2.85 return tmp;
2.86 }
2.87
2.88 @@ -1190,9 +1192,9 @@
2.89 /// This function just returns a \ref DigraphReader class.
2.90 /// \relates DigraphReader
2.91 template <typename Digraph>
2.92 - DigraphReader<Digraph> digraphReader(const std::string& fn,
2.93 - Digraph& digraph) {
2.94 - DigraphReader<Digraph> tmp(fn, digraph);
2.95 + DigraphReader<Digraph> digraphReader(Digraph& digraph,
2.96 + const std::string& fn) {
2.97 + DigraphReader<Digraph> tmp(digraph, fn);
2.98 return tmp;
2.99 }
2.100
2.101 @@ -1201,8 +1203,8 @@
2.102 /// This function just returns a \ref DigraphReader class.
2.103 /// \relates DigraphReader
2.104 template <typename Digraph>
2.105 - DigraphReader<Digraph> digraphReader(const char* fn, Digraph& digraph) {
2.106 - DigraphReader<Digraph> tmp(fn, digraph);
2.107 + DigraphReader<Digraph> digraphReader(Digraph& digraph, const char* fn) {
2.108 + DigraphReader<Digraph> tmp(digraph, fn);
2.109 return tmp;
2.110 }
2.111
2.112 @@ -1210,13 +1212,14 @@
2.113 class GraphReader;
2.114
2.115 template <typename Graph>
2.116 - GraphReader<Graph> graphReader(std::istream& is, Graph& graph);
2.117 + GraphReader<Graph> graphReader(Graph& graph,
2.118 + std::istream& is = std::cin);
2.119
2.120 template <typename Graph>
2.121 - GraphReader<Graph> graphReader(const std::string& fn, Graph& graph);
2.122 + GraphReader<Graph> graphReader(Graph& graph, const std::string& fn);
2.123
2.124 template <typename Graph>
2.125 - GraphReader<Graph> graphReader(const char *fn, Graph& graph);
2.126 + GraphReader<Graph> graphReader(Graph& graph, const char *fn);
2.127
2.128 /// \ingroup lemon_io
2.129 ///
2.130 @@ -1283,7 +1286,7 @@
2.131 ///
2.132 /// Construct an undirected graph reader, which reads from the given
2.133 /// input stream.
2.134 - GraphReader(std::istream& is, Graph& graph)
2.135 + GraphReader(Graph& graph, std::istream& is = std::cin)
2.136 : _is(&is), local_is(false), _graph(graph),
2.137 _use_nodes(false), _use_edges(false),
2.138 _skip_nodes(false), _skip_edges(false) {}
2.139 @@ -1292,7 +1295,7 @@
2.140 ///
2.141 /// Construct an undirected graph reader, which reads from the given
2.142 /// file.
2.143 - GraphReader(const std::string& fn, Graph& graph)
2.144 + GraphReader(Graph& graph, const std::string& fn)
2.145 : _is(new std::ifstream(fn.c_str())), local_is(true), _graph(graph),
2.146 _use_nodes(false), _use_edges(false),
2.147 _skip_nodes(false), _skip_edges(false) {}
2.148 @@ -1301,7 +1304,7 @@
2.149 ///
2.150 /// Construct an undirected graph reader, which reads from the given
2.151 /// file.
2.152 - GraphReader(const char* fn, Graph& graph)
2.153 + GraphReader(Graph& graph, const char* fn)
2.154 : _is(new std::ifstream(fn)), local_is(true), _graph(graph),
2.155 _use_nodes(false), _use_edges(false),
2.156 _skip_nodes(false), _skip_edges(false) {}
2.157 @@ -1330,10 +1333,10 @@
2.158 }
2.159
2.160 private:
2.161 - friend GraphReader<Graph> graphReader<>(std::istream& is, Graph& graph);
2.162 - friend GraphReader<Graph> graphReader<>(const std::string& fn,
2.163 - Graph& graph);
2.164 - friend GraphReader<Graph> graphReader<>(const char *fn, Graph& graph);
2.165 + friend GraphReader<Graph> graphReader<>(Graph& graph, std::istream& is);
2.166 + friend GraphReader<Graph> graphReader<>(Graph& graph,
2.167 + const std::string& fn);
2.168 + friend GraphReader<Graph> graphReader<>(Graph& graph, const char *fn);
2.169
2.170 GraphReader(GraphReader& other)
2.171 : _is(other._is), local_is(other.local_is), _graph(other._graph),
2.172 @@ -2006,8 +2009,8 @@
2.173 /// This function just returns a \ref GraphReader class.
2.174 /// \relates GraphReader
2.175 template <typename Graph>
2.176 - GraphReader<Graph> graphReader(std::istream& is, Graph& graph) {
2.177 - GraphReader<Graph> tmp(is, graph);
2.178 + GraphReader<Graph> graphReader(Graph& graph, std::istream& is = std::cin) {
2.179 + GraphReader<Graph> tmp(graph, is);
2.180 return tmp;
2.181 }
2.182
2.183 @@ -2016,9 +2019,8 @@
2.184 /// This function just returns a \ref GraphReader class.
2.185 /// \relates GraphReader
2.186 template <typename Graph>
2.187 - GraphReader<Graph> graphReader(const std::string& fn,
2.188 - Graph& graph) {
2.189 - GraphReader<Graph> tmp(fn, graph);
2.190 + GraphReader<Graph> graphReader(Graph& graph, const std::string& fn) {
2.191 + GraphReader<Graph> tmp(graph, fn);
2.192 return tmp;
2.193 }
2.194
2.195 @@ -2027,8 +2029,8 @@
2.196 /// This function just returns a \ref GraphReader class.
2.197 /// \relates GraphReader
2.198 template <typename Graph>
2.199 - GraphReader<Graph> graphReader(const char* fn, Graph& graph) {
2.200 - GraphReader<Graph> tmp(fn, graph);
2.201 + GraphReader<Graph> graphReader(Graph& graph, const char* fn) {
2.202 + GraphReader<Graph> tmp(graph, fn);
2.203 return tmp;
2.204 }
2.205
3.1 --- a/lemon/lgf_writer.h Mon Sep 29 12:34:08 2008 +0200
3.2 +++ b/lemon/lgf_writer.h Wed Oct 01 12:44:16 2008 +0200
3.3 @@ -352,16 +352,16 @@
3.4 class DigraphWriter;
3.5
3.6 template <typename Digraph>
3.7 - DigraphWriter<Digraph> digraphWriter(std::ostream& os,
3.8 - const Digraph& digraph);
3.9 + DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
3.10 + std::ostream& os = std::cout);
3.11
3.12 template <typename Digraph>
3.13 - DigraphWriter<Digraph> digraphWriter(const std::string& fn,
3.14 - const Digraph& digraph);
3.15 + DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
3.16 + const std::string& fn);
3.17
3.18 template <typename Digraph>
3.19 - DigraphWriter<Digraph> digraphWriter(const char *fn,
3.20 - const Digraph& digraph);
3.21 + DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
3.22 + const char *fn);
3.23
3.24 /// \ingroup lemon_io
3.25 ///
3.26 @@ -382,7 +382,7 @@
3.27 /// arc() functions are used to add attribute writing rules.
3.28 ///
3.29 ///\code
3.30 - /// DigraphWriter<Digraph>(std::cout, digraph).
3.31 + /// DigraphWriter<Digraph>(digraph, std::cout).
3.32 /// nodeMap("coordinates", coord_map).
3.33 /// nodeMap("size", size).
3.34 /// nodeMap("title", title).
3.35 @@ -452,15 +452,15 @@
3.36 ///
3.37 /// Construct a directed graph writer, which writes to the given
3.38 /// output stream.
3.39 - DigraphWriter(std::ostream& is, const Digraph& digraph)
3.40 - : _os(&is), local_os(false), _digraph(digraph),
3.41 + DigraphWriter(const Digraph& digraph, std::ostream& os = std::cout)
3.42 + : _os(&os), local_os(false), _digraph(digraph),
3.43 _skip_nodes(false), _skip_arcs(false) {}
3.44
3.45 /// \brief Constructor
3.46 ///
3.47 /// Construct a directed graph writer, which writes to the given
3.48 /// output file.
3.49 - DigraphWriter(const std::string& fn, const Digraph& digraph)
3.50 + DigraphWriter(const Digraph& digraph, const std::string& fn)
3.51 : _os(new std::ofstream(fn.c_str())), local_os(true), _digraph(digraph),
3.52 _skip_nodes(false), _skip_arcs(false) {}
3.53
3.54 @@ -468,7 +468,7 @@
3.55 ///
3.56 /// Construct a directed graph writer, which writes to the given
3.57 /// output file.
3.58 - DigraphWriter(const char* fn, const Digraph& digraph)
3.59 + DigraphWriter(const Digraph& digraph, const char* fn)
3.60 : _os(new std::ofstream(fn)), local_os(true), _digraph(digraph),
3.61 _skip_nodes(false), _skip_arcs(false) {}
3.62
3.63 @@ -496,12 +496,12 @@
3.64
3.65 private:
3.66
3.67 - friend DigraphWriter<Digraph> digraphWriter<>(std::ostream& os,
3.68 - const Digraph& digraph);
3.69 - friend DigraphWriter<Digraph> digraphWriter<>(const std::string& fn,
3.70 - const Digraph& digraph);
3.71 - friend DigraphWriter<Digraph> digraphWriter<>(const char *fn,
3.72 - const Digraph& digraph);
3.73 + friend DigraphWriter<Digraph> digraphWriter<>(const Digraph& digraph,
3.74 + std::ostream& os);
3.75 + friend DigraphWriter<Digraph> digraphWriter<>(const Digraph& digraph,
3.76 + const std::string& fn);
3.77 + friend DigraphWriter<Digraph> digraphWriter<>(const Digraph& digraph,
3.78 + const char *fn);
3.79
3.80 DigraphWriter(DigraphWriter& other)
3.81 : _os(other._os), local_os(other.local_os), _digraph(other._digraph),
3.82 @@ -908,9 +908,9 @@
3.83 /// This function just returns a \ref DigraphWriter class.
3.84 /// \relates DigraphWriter
3.85 template <typename Digraph>
3.86 - DigraphWriter<Digraph> digraphWriter(std::ostream& os,
3.87 - const Digraph& digraph) {
3.88 - DigraphWriter<Digraph> tmp(os, digraph);
3.89 + DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
3.90 + std::ostream& os = std::cout) {
3.91 + DigraphWriter<Digraph> tmp(digraph, os);
3.92 return tmp;
3.93 }
3.94
3.95 @@ -919,9 +919,9 @@
3.96 /// This function just returns a \ref DigraphWriter class.
3.97 /// \relates DigraphWriter
3.98 template <typename Digraph>
3.99 - DigraphWriter<Digraph> digraphWriter(const std::string& fn,
3.100 - const Digraph& digraph) {
3.101 - DigraphWriter<Digraph> tmp(fn, digraph);
3.102 + DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
3.103 + const std::string& fn) {
3.104 + DigraphWriter<Digraph> tmp(digraph, fn);
3.105 return tmp;
3.106 }
3.107
3.108 @@ -930,9 +930,9 @@
3.109 /// This function just returns a \ref DigraphWriter class.
3.110 /// \relates DigraphWriter
3.111 template <typename Digraph>
3.112 - DigraphWriter<Digraph> digraphWriter(const char* fn,
3.113 - const Digraph& digraph) {
3.114 - DigraphWriter<Digraph> tmp(fn, digraph);
3.115 + DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
3.116 + const char* fn) {
3.117 + DigraphWriter<Digraph> tmp(digraph, fn);
3.118 return tmp;
3.119 }
3.120
3.121 @@ -940,13 +940,14 @@
3.122 class GraphWriter;
3.123
3.124 template <typename Graph>
3.125 - GraphWriter<Graph> graphWriter(std::ostream& os, const Graph& graph);
3.126 + GraphWriter<Graph> graphWriter(const Graph& graph,
3.127 + std::ostream& os = std::cout);
3.128
3.129 template <typename Graph>
3.130 - GraphWriter<Graph> graphWriter(const std::string& fn, const Graph& graph);
3.131 + GraphWriter<Graph> graphWriter(const Graph& graph, const std::string& fn);
3.132
3.133 template <typename Graph>
3.134 - GraphWriter<Graph> graphWriter(const char *fn, const Graph& graph);
3.135 + GraphWriter<Graph> graphWriter(const Graph& graph, const char *fn);
3.136
3.137 /// \ingroup lemon_io
3.138 ///
3.139 @@ -1008,15 +1009,15 @@
3.140 ///
3.141 /// Construct a directed graph writer, which writes to the given
3.142 /// output stream.
3.143 - GraphWriter(std::ostream& is, const Graph& graph)
3.144 - : _os(&is), local_os(false), _graph(graph),
3.145 + GraphWriter(const Graph& graph, std::ostream& os = std::cout)
3.146 + : _os(&os), local_os(false), _graph(graph),
3.147 _skip_nodes(false), _skip_edges(false) {}
3.148
3.149 /// \brief Constructor
3.150 ///
3.151 /// Construct a directed graph writer, which writes to the given
3.152 /// output file.
3.153 - GraphWriter(const std::string& fn, const Graph& graph)
3.154 + GraphWriter(const Graph& graph, const std::string& fn)
3.155 : _os(new std::ofstream(fn.c_str())), local_os(true), _graph(graph),
3.156 _skip_nodes(false), _skip_edges(false) {}
3.157
3.158 @@ -1024,7 +1025,7 @@
3.159 ///
3.160 /// Construct a directed graph writer, which writes to the given
3.161 /// output file.
3.162 - GraphWriter(const char* fn, const Graph& graph)
3.163 + GraphWriter(const Graph& graph, const char* fn)
3.164 : _os(new std::ofstream(fn)), local_os(true), _graph(graph),
3.165 _skip_nodes(false), _skip_edges(false) {}
3.166
3.167 @@ -1052,12 +1053,12 @@
3.168
3.169 private:
3.170
3.171 - friend GraphWriter<Graph> graphWriter<>(std::ostream& os,
3.172 - const Graph& graph);
3.173 - friend GraphWriter<Graph> graphWriter<>(const std::string& fn,
3.174 - const Graph& graph);
3.175 - friend GraphWriter<Graph> graphWriter<>(const char *fn,
3.176 - const Graph& graph);
3.177 + friend GraphWriter<Graph> graphWriter<>(const Graph& graph,
3.178 + std::ostream& os);
3.179 + friend GraphWriter<Graph> graphWriter<>(const Graph& graph,
3.180 + const std::string& fn);
3.181 + friend GraphWriter<Graph> graphWriter<>(const Graph& graph,
3.182 + const char *fn);
3.183
3.184 GraphWriter(GraphWriter& other)
3.185 : _os(other._os), local_os(other.local_os), _graph(other._graph),
3.186 @@ -1510,8 +1511,9 @@
3.187 /// This function just returns a \ref GraphWriter class.
3.188 /// \relates GraphWriter
3.189 template <typename Graph>
3.190 - GraphWriter<Graph> graphWriter(std::ostream& os, const Graph& graph) {
3.191 - GraphWriter<Graph> tmp(os, graph);
3.192 + GraphWriter<Graph> graphWriter(const Graph& graph,
3.193 + std::ostream& os = std::cout) {
3.194 + GraphWriter<Graph> tmp(graph, os);
3.195 return tmp;
3.196 }
3.197
3.198 @@ -1520,8 +1522,8 @@
3.199 /// This function just returns a \ref GraphWriter class.
3.200 /// \relates GraphWriter
3.201 template <typename Graph>
3.202 - GraphWriter<Graph> graphWriter(const std::string& fn, const Graph& graph) {
3.203 - GraphWriter<Graph> tmp(fn, graph);
3.204 + GraphWriter<Graph> graphWriter(const Graph& graph, const std::string& fn) {
3.205 + GraphWriter<Graph> tmp(graph, fn);
3.206 return tmp;
3.207 }
3.208
3.209 @@ -1530,8 +1532,8 @@
3.210 /// This function just returns a \ref GraphWriter class.
3.211 /// \relates GraphWriter
3.212 template <typename Graph>
3.213 - GraphWriter<Graph> graphWriter(const char* fn, const Graph& graph) {
3.214 - GraphWriter<Graph> tmp(fn, graph);
3.215 + GraphWriter<Graph> graphWriter(const Graph& graph, const char* fn) {
3.216 + GraphWriter<Graph> tmp(graph, fn);
3.217 return tmp;
3.218 }
3.219
4.1 --- a/test/bfs_test.cc Mon Sep 29 12:34:08 2008 +0200
4.2 +++ b/test/bfs_test.cc Wed Oct 01 12:44:16 2008 +0200
4.3 @@ -144,7 +144,7 @@
4.4 Node s, t;
4.5
4.6 std::istringstream input(test_lgf);
4.7 - digraphReader(input, G).
4.8 + digraphReader(G, input).
4.9 node("source", s).
4.10 node("target", t).
4.11 run();
5.1 --- a/test/dfs_test.cc Mon Sep 29 12:34:08 2008 +0200
5.2 +++ b/test/dfs_test.cc Wed Oct 01 12:44:16 2008 +0200
5.3 @@ -146,7 +146,7 @@
5.4 Node s, t;
5.5
5.6 std::istringstream input(test_lgf);
5.7 - digraphReader(input, G).
5.8 + digraphReader(G, input).
5.9 node("source", s).
5.10 node("target", t).
5.11 run();
6.1 --- a/test/dijkstra_test.cc Mon Sep 29 12:34:08 2008 +0200
6.2 +++ b/test/dijkstra_test.cc Wed Oct 01 12:44:16 2008 +0200
6.3 @@ -142,7 +142,7 @@
6.4 LengthMap length(G);
6.5
6.6 std::istringstream input(test_lgf);
6.7 - digraphReader(input, G).
6.8 + digraphReader(G, input).
6.9 arcMap("length", length).
6.10 node("source", s).
6.11 node("target", t).
7.1 --- a/test/heap_test.cc Mon Sep 29 12:34:08 2008 +0200
7.2 +++ b/test/heap_test.cc Wed Oct 01 12:44:16 2008 +0200
7.3 @@ -167,7 +167,7 @@
7.4 Node source;
7.5
7.6 std::istringstream input(test_lgf);
7.7 - digraphReader(input, digraph).
7.8 + digraphReader(digraph, input).
7.9 arcMap("capacity", length).
7.10 node("source", source).
7.11 run();