diff --git a/lemon/lgf_writer.h b/lemon/lgf_writer.h --- a/lemon/lgf_writer.h +++ b/lemon/lgf_writer.h @@ -352,16 +352,16 @@ class DigraphWriter; template - DigraphWriter digraphWriter(std::ostream& os, - const Digraph& digraph); + DigraphWriter digraphWriter(const Digraph& digraph, + std::ostream& os = std::cout); template - DigraphWriter digraphWriter(const std::string& fn, - const Digraph& digraph); + DigraphWriter digraphWriter(const Digraph& digraph, + const std::string& fn); template - DigraphWriter digraphWriter(const char *fn, - const Digraph& digraph); + DigraphWriter digraphWriter(const Digraph& digraph, + const char *fn); /// \ingroup lemon_io /// @@ -382,7 +382,7 @@ /// arc() functions are used to add attribute writing rules. /// ///\code - /// DigraphWriter(std::cout, digraph). + /// DigraphWriter(digraph, std::cout). /// nodeMap("coordinates", coord_map). /// nodeMap("size", size). /// nodeMap("title", title). @@ -452,15 +452,15 @@ /// /// Construct a directed graph writer, which writes to the given /// output stream. - DigraphWriter(std::ostream& is, const Digraph& digraph) - : _os(&is), local_os(false), _digraph(digraph), + DigraphWriter(const Digraph& digraph, std::ostream& os = std::cout) + : _os(&os), local_os(false), _digraph(digraph), _skip_nodes(false), _skip_arcs(false) {} /// \brief Constructor /// /// Construct a directed graph writer, which writes to the given /// output file. - DigraphWriter(const std::string& fn, const Digraph& digraph) + DigraphWriter(const Digraph& digraph, const std::string& fn) : _os(new std::ofstream(fn.c_str())), local_os(true), _digraph(digraph), _skip_nodes(false), _skip_arcs(false) {} @@ -468,7 +468,7 @@ /// /// Construct a directed graph writer, which writes to the given /// output file. - DigraphWriter(const char* fn, const Digraph& digraph) + DigraphWriter(const Digraph& digraph, const char* fn) : _os(new std::ofstream(fn)), local_os(true), _digraph(digraph), _skip_nodes(false), _skip_arcs(false) {} @@ -496,12 +496,12 @@ private: - friend DigraphWriter digraphWriter<>(std::ostream& os, - const Digraph& digraph); - friend DigraphWriter digraphWriter<>(const std::string& fn, - const Digraph& digraph); - friend DigraphWriter digraphWriter<>(const char *fn, - const Digraph& digraph); + friend DigraphWriter digraphWriter<>(const Digraph& digraph, + std::ostream& os); + friend DigraphWriter digraphWriter<>(const Digraph& digraph, + const std::string& fn); + friend DigraphWriter digraphWriter<>(const Digraph& digraph, + const char *fn); DigraphWriter(DigraphWriter& other) : _os(other._os), local_os(other.local_os), _digraph(other._digraph), @@ -908,9 +908,9 @@ /// This function just returns a \ref DigraphWriter class. /// \relates DigraphWriter template - DigraphWriter digraphWriter(std::ostream& os, - const Digraph& digraph) { - DigraphWriter tmp(os, digraph); + DigraphWriter digraphWriter(const Digraph& digraph, + std::ostream& os = std::cout) { + DigraphWriter tmp(digraph, os); return tmp; } @@ -919,9 +919,9 @@ /// This function just returns a \ref DigraphWriter class. /// \relates DigraphWriter template - DigraphWriter digraphWriter(const std::string& fn, - const Digraph& digraph) { - DigraphWriter tmp(fn, digraph); + DigraphWriter digraphWriter(const Digraph& digraph, + const std::string& fn) { + DigraphWriter tmp(digraph, fn); return tmp; } @@ -930,9 +930,9 @@ /// This function just returns a \ref DigraphWriter class. /// \relates DigraphWriter template - DigraphWriter digraphWriter(const char* fn, - const Digraph& digraph) { - DigraphWriter tmp(fn, digraph); + DigraphWriter digraphWriter(const Digraph& digraph, + const char* fn) { + DigraphWriter tmp(digraph, fn); return tmp; } @@ -940,13 +940,14 @@ class GraphWriter; template - GraphWriter graphWriter(std::ostream& os, const Graph& graph); + GraphWriter graphWriter(const Graph& graph, + std::ostream& os = std::cout); template - GraphWriter graphWriter(const std::string& fn, const Graph& graph); + GraphWriter graphWriter(const Graph& graph, const std::string& fn); template - GraphWriter graphWriter(const char *fn, const Graph& graph); + GraphWriter graphWriter(const Graph& graph, const char *fn); /// \ingroup lemon_io /// @@ -1008,15 +1009,15 @@ /// /// Construct a directed graph writer, which writes to the given /// output stream. - GraphWriter(std::ostream& is, const Graph& graph) - : _os(&is), local_os(false), _graph(graph), + GraphWriter(const Graph& graph, std::ostream& os = std::cout) + : _os(&os), local_os(false), _graph(graph), _skip_nodes(false), _skip_edges(false) {} /// \brief Constructor /// /// Construct a directed graph writer, which writes to the given /// output file. - GraphWriter(const std::string& fn, const Graph& graph) + GraphWriter(const Graph& graph, const std::string& fn) : _os(new std::ofstream(fn.c_str())), local_os(true), _graph(graph), _skip_nodes(false), _skip_edges(false) {} @@ -1024,7 +1025,7 @@ /// /// Construct a directed graph writer, which writes to the given /// output file. - GraphWriter(const char* fn, const Graph& graph) + GraphWriter(const Graph& graph, const char* fn) : _os(new std::ofstream(fn)), local_os(true), _graph(graph), _skip_nodes(false), _skip_edges(false) {} @@ -1052,12 +1053,12 @@ private: - friend GraphWriter graphWriter<>(std::ostream& os, - const Graph& graph); - friend GraphWriter graphWriter<>(const std::string& fn, - const Graph& graph); - friend GraphWriter graphWriter<>(const char *fn, - const Graph& graph); + friend GraphWriter graphWriter<>(const Graph& graph, + std::ostream& os); + friend GraphWriter graphWriter<>(const Graph& graph, + const std::string& fn); + friend GraphWriter graphWriter<>(const Graph& graph, + const char *fn); GraphWriter(GraphWriter& other) : _os(other._os), local_os(other.local_os), _graph(other._graph), @@ -1510,8 +1511,9 @@ /// This function just returns a \ref GraphWriter class. /// \relates GraphWriter template - GraphWriter graphWriter(std::ostream& os, const Graph& graph) { - GraphWriter tmp(os, graph); + GraphWriter graphWriter(const Graph& graph, + std::ostream& os = std::cout) { + GraphWriter tmp(graph, os); return tmp; } @@ -1520,8 +1522,8 @@ /// This function just returns a \ref GraphWriter class. /// \relates GraphWriter template - GraphWriter graphWriter(const std::string& fn, const Graph& graph) { - GraphWriter tmp(fn, graph); + GraphWriter graphWriter(const Graph& graph, const std::string& fn) { + GraphWriter tmp(graph, fn); return tmp; } @@ -1530,8 +1532,8 @@ /// This function just returns a \ref GraphWriter class. /// \relates GraphWriter template - GraphWriter graphWriter(const char* fn, const Graph& graph) { - GraphWriter tmp(fn, graph); + GraphWriter graphWriter(const Graph& graph, const char* fn) { + GraphWriter tmp(graph, fn); return tmp; }