diff -r d91884dcd572 -r 47fbc814aa31 lemon/lgf_reader.h --- a/lemon/lgf_reader.h Mon Sep 29 12:34:08 2008 +0200 +++ b/lemon/lgf_reader.h Wed Oct 01 12:44:16 2008 +0200 @@ -390,13 +390,14 @@ class DigraphReader; template - DigraphReader digraphReader(std::istream& is, Digraph& digraph); + DigraphReader digraphReader(Digraph& digraph, + std::istream& is = std::cin); template - DigraphReader digraphReader(const std::string& fn, Digraph& digraph); + DigraphReader digraphReader(Digraph& digraph, const std::string& fn); template - DigraphReader digraphReader(const char *fn, Digraph& digraph); + DigraphReader digraphReader(Digraph& digraph, const char *fn); /// \ingroup lemon_io /// @@ -419,7 +420,7 @@ /// rules. /// ///\code - /// DigraphReader(std::cin, digraph). + /// DigraphReader(digraph, std::cin). /// nodeMap("coordinates", coord_map). /// arcMap("capacity", cap_map). /// node("source", src). @@ -499,7 +500,7 @@ /// /// Construct a directed graph reader, which reads from the given /// input stream. - DigraphReader(std::istream& is, Digraph& digraph) + DigraphReader(Digraph& digraph, std::istream& is = std::cin) : _is(&is), local_is(false), _digraph(digraph), _use_nodes(false), _use_arcs(false), _skip_nodes(false), _skip_arcs(false) {} @@ -508,7 +509,7 @@ /// /// Construct a directed graph reader, which reads from the given /// file. - DigraphReader(const std::string& fn, Digraph& digraph) + DigraphReader(Digraph& digraph, const std::string& fn) : _is(new std::ifstream(fn.c_str())), local_is(true), _digraph(digraph), _use_nodes(false), _use_arcs(false), _skip_nodes(false), _skip_arcs(false) {} @@ -517,7 +518,7 @@ /// /// Construct a directed graph reader, which reads from the given /// file. - DigraphReader(const char* fn, Digraph& digraph) + DigraphReader(Digraph& digraph, const char* fn) : _is(new std::ifstream(fn)), local_is(true), _digraph(digraph), _use_nodes(false), _use_arcs(false), _skip_nodes(false), _skip_arcs(false) {} @@ -547,12 +548,12 @@ private: - friend DigraphReader digraphReader<>(std::istream& is, - Digraph& digraph); - friend DigraphReader digraphReader<>(const std::string& fn, - Digraph& digraph); - friend DigraphReader digraphReader<>(const char *fn, - Digraph& digraph); + friend DigraphReader digraphReader<>(Digraph& digraph, + std::istream& is); + friend DigraphReader digraphReader<>(Digraph& digraph, + const std::string& fn); + friend DigraphReader digraphReader<>(Digraph& digraph, + const char *fn); DigraphReader(DigraphReader& other) : _is(other._is), local_is(other.local_is), _digraph(other._digraph), @@ -1180,8 +1181,9 @@ /// This function just returns a \ref DigraphReader class. /// \relates DigraphReader template - DigraphReader digraphReader(std::istream& is, Digraph& digraph) { - DigraphReader tmp(is, digraph); + DigraphReader digraphReader(Digraph& digraph, + std::istream& is = std::cin) { + DigraphReader tmp(digraph, is); return tmp; } @@ -1190,9 +1192,9 @@ /// This function just returns a \ref DigraphReader class. /// \relates DigraphReader template - DigraphReader digraphReader(const std::string& fn, - Digraph& digraph) { - DigraphReader tmp(fn, digraph); + DigraphReader digraphReader(Digraph& digraph, + const std::string& fn) { + DigraphReader tmp(digraph, fn); return tmp; } @@ -1201,8 +1203,8 @@ /// This function just returns a \ref DigraphReader class. /// \relates DigraphReader template - DigraphReader digraphReader(const char* fn, Digraph& digraph) { - DigraphReader tmp(fn, digraph); + DigraphReader digraphReader(Digraph& digraph, const char* fn) { + DigraphReader tmp(digraph, fn); return tmp; } @@ -1210,13 +1212,14 @@ class GraphReader; template - GraphReader graphReader(std::istream& is, Graph& graph); + GraphReader graphReader(Graph& graph, + std::istream& is = std::cin); template - GraphReader graphReader(const std::string& fn, Graph& graph); + GraphReader graphReader(Graph& graph, const std::string& fn); template - GraphReader graphReader(const char *fn, Graph& graph); + GraphReader graphReader(Graph& graph, const char *fn); /// \ingroup lemon_io /// @@ -1283,7 +1286,7 @@ /// /// Construct an undirected graph reader, which reads from the given /// input stream. - GraphReader(std::istream& is, Graph& graph) + GraphReader(Graph& graph, std::istream& is = std::cin) : _is(&is), local_is(false), _graph(graph), _use_nodes(false), _use_edges(false), _skip_nodes(false), _skip_edges(false) {} @@ -1292,7 +1295,7 @@ /// /// Construct an undirected graph reader, which reads from the given /// file. - GraphReader(const std::string& fn, Graph& graph) + GraphReader(Graph& graph, const std::string& fn) : _is(new std::ifstream(fn.c_str())), local_is(true), _graph(graph), _use_nodes(false), _use_edges(false), _skip_nodes(false), _skip_edges(false) {} @@ -1301,7 +1304,7 @@ /// /// Construct an undirected graph reader, which reads from the given /// file. - GraphReader(const char* fn, Graph& graph) + GraphReader(Graph& graph, const char* fn) : _is(new std::ifstream(fn)), local_is(true), _graph(graph), _use_nodes(false), _use_edges(false), _skip_nodes(false), _skip_edges(false) {} @@ -1330,10 +1333,10 @@ } private: - friend GraphReader graphReader<>(std::istream& is, Graph& graph); - friend GraphReader graphReader<>(const std::string& fn, - Graph& graph); - friend GraphReader graphReader<>(const char *fn, Graph& graph); + friend GraphReader graphReader<>(Graph& graph, std::istream& is); + friend GraphReader graphReader<>(Graph& graph, + const std::string& fn); + friend GraphReader graphReader<>(Graph& graph, const char *fn); GraphReader(GraphReader& other) : _is(other._is), local_is(other.local_is), _graph(other._graph), @@ -2006,8 +2009,8 @@ /// This function just returns a \ref GraphReader class. /// \relates GraphReader template - GraphReader graphReader(std::istream& is, Graph& graph) { - GraphReader tmp(is, graph); + GraphReader graphReader(Graph& graph, std::istream& is = std::cin) { + GraphReader tmp(graph, is); return tmp; } @@ -2016,9 +2019,8 @@ /// This function just returns a \ref GraphReader class. /// \relates GraphReader template - GraphReader graphReader(const std::string& fn, - Graph& graph) { - GraphReader tmp(fn, graph); + GraphReader graphReader(Graph& graph, const std::string& fn) { + GraphReader tmp(graph, fn); return tmp; } @@ -2027,8 +2029,8 @@ /// This function just returns a \ref GraphReader class. /// \relates GraphReader template - GraphReader graphReader(const char* fn, Graph& graph) { - GraphReader tmp(fn, graph); + GraphReader graphReader(Graph& graph, const char* fn) { + GraphReader tmp(graph, fn); return tmp; }