lemon/lgf_writer.h
changeset 293 47fbc814aa31
parent 248 8fada33fc60a
child 294 cbe3ec2d59d2
     1.1 --- a/lemon/lgf_writer.h	Mon Sep 29 12:34:08 2008 +0200
     1.2 +++ b/lemon/lgf_writer.h	Wed Oct 01 12:44:16 2008 +0200
     1.3 @@ -352,16 +352,16 @@
     1.4    class DigraphWriter;
     1.5  
     1.6    template <typename Digraph>
     1.7 -  DigraphWriter<Digraph> digraphWriter(std::ostream& os,
     1.8 -                                       const Digraph& digraph);
     1.9 +  DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
    1.10 +                                       std::ostream& os = std::cout);
    1.11  
    1.12    template <typename Digraph>
    1.13 -  DigraphWriter<Digraph> digraphWriter(const std::string& fn,
    1.14 -                                       const Digraph& digraph);
    1.15 +  DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
    1.16 +                                       const std::string& fn);
    1.17  
    1.18    template <typename Digraph>
    1.19 -  DigraphWriter<Digraph> digraphWriter(const char *fn,
    1.20 -                                       const Digraph& digraph);
    1.21 +  DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
    1.22 +                                       const char *fn);
    1.23  
    1.24    /// \ingroup lemon_io
    1.25    ///
    1.26 @@ -382,7 +382,7 @@
    1.27    /// arc() functions are used to add attribute writing rules.
    1.28    ///
    1.29    ///\code
    1.30 -  /// DigraphWriter<Digraph>(std::cout, digraph).
    1.31 +  /// DigraphWriter<Digraph>(digraph, std::cout).
    1.32    ///   nodeMap("coordinates", coord_map).
    1.33    ///   nodeMap("size", size).
    1.34    ///   nodeMap("title", title).
    1.35 @@ -452,15 +452,15 @@
    1.36      ///
    1.37      /// Construct a directed graph writer, which writes to the given
    1.38      /// output stream.
    1.39 -    DigraphWriter(std::ostream& is, const Digraph& digraph)
    1.40 -      : _os(&is), local_os(false), _digraph(digraph),
    1.41 +    DigraphWriter(const Digraph& digraph, std::ostream& os = std::cout)
    1.42 +      : _os(&os), local_os(false), _digraph(digraph),
    1.43          _skip_nodes(false), _skip_arcs(false) {}
    1.44  
    1.45      /// \brief Constructor
    1.46      ///
    1.47      /// Construct a directed graph writer, which writes to the given
    1.48      /// output file.
    1.49 -    DigraphWriter(const std::string& fn, const Digraph& digraph)
    1.50 +    DigraphWriter(const Digraph& digraph, const std::string& fn)
    1.51        : _os(new std::ofstream(fn.c_str())), local_os(true), _digraph(digraph),
    1.52          _skip_nodes(false), _skip_arcs(false) {}
    1.53  
    1.54 @@ -468,7 +468,7 @@
    1.55      ///
    1.56      /// Construct a directed graph writer, which writes to the given
    1.57      /// output file.
    1.58 -    DigraphWriter(const char* fn, const Digraph& digraph)
    1.59 +    DigraphWriter(const Digraph& digraph, const char* fn)
    1.60        : _os(new std::ofstream(fn)), local_os(true), _digraph(digraph),
    1.61          _skip_nodes(false), _skip_arcs(false) {}
    1.62  
    1.63 @@ -496,12 +496,12 @@
    1.64  
    1.65    private:
    1.66  
    1.67 -    friend DigraphWriter<Digraph> digraphWriter<>(std::ostream& os,
    1.68 -                                                  const Digraph& digraph);
    1.69 -    friend DigraphWriter<Digraph> digraphWriter<>(const std::string& fn,
    1.70 -                                                  const Digraph& digraph);
    1.71 -    friend DigraphWriter<Digraph> digraphWriter<>(const char *fn,
    1.72 -                                                  const Digraph& digraph);
    1.73 +    friend DigraphWriter<Digraph> digraphWriter<>(const Digraph& digraph,
    1.74 +                                                  std::ostream& os);
    1.75 +    friend DigraphWriter<Digraph> digraphWriter<>(const Digraph& digraph,
    1.76 +                                                  const std::string& fn);
    1.77 +    friend DigraphWriter<Digraph> digraphWriter<>(const Digraph& digraph,
    1.78 +                                                  const char *fn);
    1.79  
    1.80      DigraphWriter(DigraphWriter& other)
    1.81        : _os(other._os), local_os(other.local_os), _digraph(other._digraph),
    1.82 @@ -908,9 +908,9 @@
    1.83    /// This function just returns a \ref DigraphWriter class.
    1.84    /// \relates DigraphWriter
    1.85    template <typename Digraph>
    1.86 -  DigraphWriter<Digraph> digraphWriter(std::ostream& os,
    1.87 -                                       const Digraph& digraph) {
    1.88 -    DigraphWriter<Digraph> tmp(os, digraph);
    1.89 +  DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
    1.90 +                                       std::ostream& os = std::cout) {
    1.91 +    DigraphWriter<Digraph> tmp(digraph, os);
    1.92      return tmp;
    1.93    }
    1.94  
    1.95 @@ -919,9 +919,9 @@
    1.96    /// This function just returns a \ref DigraphWriter class.
    1.97    /// \relates DigraphWriter
    1.98    template <typename Digraph>
    1.99 -  DigraphWriter<Digraph> digraphWriter(const std::string& fn,
   1.100 -                                       const Digraph& digraph) {
   1.101 -    DigraphWriter<Digraph> tmp(fn, digraph);
   1.102 +  DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
   1.103 +                                       const std::string& fn) {
   1.104 +    DigraphWriter<Digraph> tmp(digraph, fn);
   1.105      return tmp;
   1.106    }
   1.107  
   1.108 @@ -930,9 +930,9 @@
   1.109    /// This function just returns a \ref DigraphWriter class.
   1.110    /// \relates DigraphWriter
   1.111    template <typename Digraph>
   1.112 -  DigraphWriter<Digraph> digraphWriter(const char* fn,
   1.113 -                                       const Digraph& digraph) {
   1.114 -    DigraphWriter<Digraph> tmp(fn, digraph);
   1.115 +  DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
   1.116 +                                       const char* fn) {
   1.117 +    DigraphWriter<Digraph> tmp(digraph, fn);
   1.118      return tmp;
   1.119    }
   1.120  
   1.121 @@ -940,13 +940,14 @@
   1.122    class GraphWriter;
   1.123  
   1.124    template <typename Graph>
   1.125 -  GraphWriter<Graph> graphWriter(std::ostream& os, const Graph& graph);
   1.126 +  GraphWriter<Graph> graphWriter(const Graph& graph,
   1.127 +                                 std::ostream& os = std::cout);
   1.128  
   1.129    template <typename Graph>
   1.130 -  GraphWriter<Graph> graphWriter(const std::string& fn, const Graph& graph);
   1.131 +  GraphWriter<Graph> graphWriter(const Graph& graph, const std::string& fn);
   1.132  
   1.133    template <typename Graph>
   1.134 -  GraphWriter<Graph> graphWriter(const char *fn, const Graph& graph);
   1.135 +  GraphWriter<Graph> graphWriter(const Graph& graph, const char *fn);
   1.136  
   1.137    /// \ingroup lemon_io
   1.138    ///
   1.139 @@ -1008,15 +1009,15 @@
   1.140      ///
   1.141      /// Construct a directed graph writer, which writes to the given
   1.142      /// output stream.
   1.143 -    GraphWriter(std::ostream& is, const Graph& graph)
   1.144 -      : _os(&is), local_os(false), _graph(graph),
   1.145 +    GraphWriter(const Graph& graph, std::ostream& os = std::cout)
   1.146 +      : _os(&os), local_os(false), _graph(graph),
   1.147          _skip_nodes(false), _skip_edges(false) {}
   1.148  
   1.149      /// \brief Constructor
   1.150      ///
   1.151      /// Construct a directed graph writer, which writes to the given
   1.152      /// output file.
   1.153 -    GraphWriter(const std::string& fn, const Graph& graph)
   1.154 +    GraphWriter(const Graph& graph, const std::string& fn)
   1.155        : _os(new std::ofstream(fn.c_str())), local_os(true), _graph(graph),
   1.156          _skip_nodes(false), _skip_edges(false) {}
   1.157  
   1.158 @@ -1024,7 +1025,7 @@
   1.159      ///
   1.160      /// Construct a directed graph writer, which writes to the given
   1.161      /// output file.
   1.162 -    GraphWriter(const char* fn, const Graph& graph)
   1.163 +    GraphWriter(const Graph& graph, const char* fn)
   1.164        : _os(new std::ofstream(fn)), local_os(true), _graph(graph),
   1.165          _skip_nodes(false), _skip_edges(false) {}
   1.166  
   1.167 @@ -1052,12 +1053,12 @@
   1.168  
   1.169    private:
   1.170  
   1.171 -    friend GraphWriter<Graph> graphWriter<>(std::ostream& os,
   1.172 -                                            const Graph& graph);
   1.173 -    friend GraphWriter<Graph> graphWriter<>(const std::string& fn,
   1.174 -                                            const Graph& graph);
   1.175 -    friend GraphWriter<Graph> graphWriter<>(const char *fn,
   1.176 -                                            const Graph& graph);
   1.177 +    friend GraphWriter<Graph> graphWriter<>(const Graph& graph,
   1.178 +                                            std::ostream& os);
   1.179 +    friend GraphWriter<Graph> graphWriter<>(const Graph& graph,
   1.180 +                                            const std::string& fn);
   1.181 +    friend GraphWriter<Graph> graphWriter<>(const Graph& graph,
   1.182 +                                            const char *fn);
   1.183  
   1.184      GraphWriter(GraphWriter& other)
   1.185        : _os(other._os), local_os(other.local_os), _graph(other._graph),
   1.186 @@ -1510,8 +1511,9 @@
   1.187    /// This function just returns a \ref GraphWriter class.
   1.188    /// \relates GraphWriter
   1.189    template <typename Graph>
   1.190 -  GraphWriter<Graph> graphWriter(std::ostream& os, const Graph& graph) {
   1.191 -    GraphWriter<Graph> tmp(os, graph);
   1.192 +  GraphWriter<Graph> graphWriter(const Graph& graph,
   1.193 +                                 std::ostream& os = std::cout) {
   1.194 +    GraphWriter<Graph> tmp(graph, os);
   1.195      return tmp;
   1.196    }
   1.197  
   1.198 @@ -1520,8 +1522,8 @@
   1.199    /// This function just returns a \ref GraphWriter class.
   1.200    /// \relates GraphWriter
   1.201    template <typename Graph>
   1.202 -  GraphWriter<Graph> graphWriter(const std::string& fn, const Graph& graph) {
   1.203 -    GraphWriter<Graph> tmp(fn, graph);
   1.204 +  GraphWriter<Graph> graphWriter(const Graph& graph, const std::string& fn) {
   1.205 +    GraphWriter<Graph> tmp(graph, fn);
   1.206      return tmp;
   1.207    }
   1.208  
   1.209 @@ -1530,8 +1532,8 @@
   1.210    /// This function just returns a \ref GraphWriter class.
   1.211    /// \relates GraphWriter
   1.212    template <typename Graph>
   1.213 -  GraphWriter<Graph> graphWriter(const char* fn, const Graph& graph) {
   1.214 -    GraphWriter<Graph> tmp(fn, graph);
   1.215 +  GraphWriter<Graph> graphWriter(const Graph& graph, const char* fn) {
   1.216 +    GraphWriter<Graph> tmp(graph, fn);
   1.217      return tmp;
   1.218    }
   1.219