lemon/lgf_reader.h
changeset 293 47fbc814aa31
parent 236 da953e387d31
child 294 cbe3ec2d59d2
     1.1 --- a/lemon/lgf_reader.h	Mon Sep 29 12:34:08 2008 +0200
     1.2 +++ b/lemon/lgf_reader.h	Wed Oct 01 12:44:16 2008 +0200
     1.3 @@ -390,13 +390,14 @@
     1.4    class DigraphReader;
     1.5  
     1.6    template <typename Digraph>
     1.7 -  DigraphReader<Digraph> digraphReader(std::istream& is, Digraph& digraph);
     1.8 +  DigraphReader<Digraph> digraphReader(Digraph& digraph,
     1.9 +                                       std::istream& is = std::cin);
    1.10  
    1.11    template <typename Digraph>
    1.12 -  DigraphReader<Digraph> digraphReader(const std::string& fn, Digraph& digraph);
    1.13 +  DigraphReader<Digraph> digraphReader(Digraph& digraph, const std::string& fn);
    1.14  
    1.15    template <typename Digraph>
    1.16 -  DigraphReader<Digraph> digraphReader(const char *fn, Digraph& digraph);
    1.17 +  DigraphReader<Digraph> digraphReader(Digraph& digraph, const char *fn);
    1.18  
    1.19    /// \ingroup lemon_io
    1.20    ///
    1.21 @@ -419,7 +420,7 @@
    1.22    /// rules.
    1.23    ///
    1.24    ///\code
    1.25 -  /// DigraphReader<Digraph>(std::cin, digraph).
    1.26 +  /// DigraphReader<Digraph>(digraph, std::cin).
    1.27    ///   nodeMap("coordinates", coord_map).
    1.28    ///   arcMap("capacity", cap_map).
    1.29    ///   node("source", src).
    1.30 @@ -499,7 +500,7 @@
    1.31      ///
    1.32      /// Construct a directed graph reader, which reads from the given
    1.33      /// input stream.
    1.34 -    DigraphReader(std::istream& is, Digraph& digraph)
    1.35 +    DigraphReader(Digraph& digraph, std::istream& is = std::cin)
    1.36        : _is(&is), local_is(false), _digraph(digraph),
    1.37          _use_nodes(false), _use_arcs(false),
    1.38          _skip_nodes(false), _skip_arcs(false) {}
    1.39 @@ -508,7 +509,7 @@
    1.40      ///
    1.41      /// Construct a directed graph reader, which reads from the given
    1.42      /// file.
    1.43 -    DigraphReader(const std::string& fn, Digraph& digraph)
    1.44 +    DigraphReader(Digraph& digraph, const std::string& fn)
    1.45        : _is(new std::ifstream(fn.c_str())), local_is(true), _digraph(digraph),
    1.46          _use_nodes(false), _use_arcs(false),
    1.47          _skip_nodes(false), _skip_arcs(false) {}
    1.48 @@ -517,7 +518,7 @@
    1.49      ///
    1.50      /// Construct a directed graph reader, which reads from the given
    1.51      /// file.
    1.52 -    DigraphReader(const char* fn, Digraph& digraph)
    1.53 +    DigraphReader(Digraph& digraph, const char* fn)
    1.54        : _is(new std::ifstream(fn)), local_is(true), _digraph(digraph),
    1.55          _use_nodes(false), _use_arcs(false),
    1.56          _skip_nodes(false), _skip_arcs(false) {}
    1.57 @@ -547,12 +548,12 @@
    1.58  
    1.59    private:
    1.60  
    1.61 -    friend DigraphReader<Digraph> digraphReader<>(std::istream& is,
    1.62 -                                                  Digraph& digraph);
    1.63 -    friend DigraphReader<Digraph> digraphReader<>(const std::string& fn,
    1.64 -                                                  Digraph& digraph);
    1.65 -    friend DigraphReader<Digraph> digraphReader<>(const char *fn,
    1.66 -                                                  Digraph& digraph);
    1.67 +    friend DigraphReader<Digraph> digraphReader<>(Digraph& digraph,
    1.68 +                                                  std::istream& is);
    1.69 +    friend DigraphReader<Digraph> digraphReader<>(Digraph& digraph,
    1.70 +                                                  const std::string& fn);
    1.71 +    friend DigraphReader<Digraph> digraphReader<>(Digraph& digraph,
    1.72 +                                                  const char *fn);
    1.73  
    1.74      DigraphReader(DigraphReader& other)
    1.75        : _is(other._is), local_is(other.local_is), _digraph(other._digraph),
    1.76 @@ -1180,8 +1181,9 @@
    1.77    /// This function just returns a \ref DigraphReader class.
    1.78    /// \relates DigraphReader
    1.79    template <typename Digraph>
    1.80 -  DigraphReader<Digraph> digraphReader(std::istream& is, Digraph& digraph) {
    1.81 -    DigraphReader<Digraph> tmp(is, digraph);
    1.82 +  DigraphReader<Digraph> digraphReader(Digraph& digraph,
    1.83 +                                       std::istream& is = std::cin) {
    1.84 +    DigraphReader<Digraph> tmp(digraph, is);
    1.85      return tmp;
    1.86    }
    1.87  
    1.88 @@ -1190,9 +1192,9 @@
    1.89    /// This function just returns a \ref DigraphReader class.
    1.90    /// \relates DigraphReader
    1.91    template <typename Digraph>
    1.92 -  DigraphReader<Digraph> digraphReader(const std::string& fn,
    1.93 -                                       Digraph& digraph) {
    1.94 -    DigraphReader<Digraph> tmp(fn, digraph);
    1.95 +  DigraphReader<Digraph> digraphReader(Digraph& digraph,
    1.96 +                                       const std::string& fn) {
    1.97 +    DigraphReader<Digraph> tmp(digraph, fn);
    1.98      return tmp;
    1.99    }
   1.100  
   1.101 @@ -1201,8 +1203,8 @@
   1.102    /// This function just returns a \ref DigraphReader class.
   1.103    /// \relates DigraphReader
   1.104    template <typename Digraph>
   1.105 -  DigraphReader<Digraph> digraphReader(const char* fn, Digraph& digraph) {
   1.106 -    DigraphReader<Digraph> tmp(fn, digraph);
   1.107 +  DigraphReader<Digraph> digraphReader(Digraph& digraph, const char* fn) {
   1.108 +    DigraphReader<Digraph> tmp(digraph, fn);
   1.109      return tmp;
   1.110    }
   1.111  
   1.112 @@ -1210,13 +1212,14 @@
   1.113    class GraphReader;
   1.114  
   1.115    template <typename Graph>
   1.116 -  GraphReader<Graph> graphReader(std::istream& is, Graph& graph);
   1.117 +  GraphReader<Graph> graphReader(Graph& graph,
   1.118 +                                 std::istream& is = std::cin);
   1.119  
   1.120    template <typename Graph>
   1.121 -  GraphReader<Graph> graphReader(const std::string& fn, Graph& graph);
   1.122 +  GraphReader<Graph> graphReader(Graph& graph, const std::string& fn);
   1.123  
   1.124    template <typename Graph>
   1.125 -  GraphReader<Graph> graphReader(const char *fn, Graph& graph);
   1.126 +  GraphReader<Graph> graphReader(Graph& graph, const char *fn);
   1.127  
   1.128    /// \ingroup lemon_io
   1.129    ///
   1.130 @@ -1283,7 +1286,7 @@
   1.131      ///
   1.132      /// Construct an undirected graph reader, which reads from the given
   1.133      /// input stream.
   1.134 -    GraphReader(std::istream& is, Graph& graph)
   1.135 +    GraphReader(Graph& graph, std::istream& is = std::cin)
   1.136        : _is(&is), local_is(false), _graph(graph),
   1.137          _use_nodes(false), _use_edges(false),
   1.138          _skip_nodes(false), _skip_edges(false) {}
   1.139 @@ -1292,7 +1295,7 @@
   1.140      ///
   1.141      /// Construct an undirected graph reader, which reads from the given
   1.142      /// file.
   1.143 -    GraphReader(const std::string& fn, Graph& graph)
   1.144 +    GraphReader(Graph& graph, const std::string& fn)
   1.145        : _is(new std::ifstream(fn.c_str())), local_is(true), _graph(graph),
   1.146          _use_nodes(false), _use_edges(false),
   1.147          _skip_nodes(false), _skip_edges(false) {}
   1.148 @@ -1301,7 +1304,7 @@
   1.149      ///
   1.150      /// Construct an undirected graph reader, which reads from the given
   1.151      /// file.
   1.152 -    GraphReader(const char* fn, Graph& graph)
   1.153 +    GraphReader(Graph& graph, const char* fn)
   1.154        : _is(new std::ifstream(fn)), local_is(true), _graph(graph),
   1.155          _use_nodes(false), _use_edges(false),
   1.156          _skip_nodes(false), _skip_edges(false) {}
   1.157 @@ -1330,10 +1333,10 @@
   1.158      }
   1.159  
   1.160    private:
   1.161 -    friend GraphReader<Graph> graphReader<>(std::istream& is, Graph& graph);
   1.162 -    friend GraphReader<Graph> graphReader<>(const std::string& fn,
   1.163 -                                            Graph& graph);
   1.164 -    friend GraphReader<Graph> graphReader<>(const char *fn, Graph& graph);
   1.165 +    friend GraphReader<Graph> graphReader<>(Graph& graph, std::istream& is);
   1.166 +    friend GraphReader<Graph> graphReader<>(Graph& graph,
   1.167 +                                            const std::string& fn);
   1.168 +    friend GraphReader<Graph> graphReader<>(Graph& graph, const char *fn);
   1.169  
   1.170      GraphReader(GraphReader& other)
   1.171        : _is(other._is), local_is(other.local_is), _graph(other._graph),
   1.172 @@ -2006,8 +2009,8 @@
   1.173    /// This function just returns a \ref GraphReader class.
   1.174    /// \relates GraphReader
   1.175    template <typename Graph>
   1.176 -  GraphReader<Graph> graphReader(std::istream& is, Graph& graph) {
   1.177 -    GraphReader<Graph> tmp(is, graph);
   1.178 +  GraphReader<Graph> graphReader(Graph& graph, std::istream& is = std::cin) {
   1.179 +    GraphReader<Graph> tmp(graph, is);
   1.180      return tmp;
   1.181    }
   1.182  
   1.183 @@ -2016,9 +2019,8 @@
   1.184    /// This function just returns a \ref GraphReader class.
   1.185    /// \relates GraphReader
   1.186    template <typename Graph>
   1.187 -  GraphReader<Graph> graphReader(const std::string& fn,
   1.188 -                                       Graph& graph) {
   1.189 -    GraphReader<Graph> tmp(fn, graph);
   1.190 +  GraphReader<Graph> graphReader(Graph& graph, const std::string& fn) {
   1.191 +    GraphReader<Graph> tmp(graph, fn);
   1.192      return tmp;
   1.193    }
   1.194  
   1.195 @@ -2027,8 +2029,8 @@
   1.196    /// This function just returns a \ref GraphReader class.
   1.197    /// \relates GraphReader
   1.198    template <typename Graph>
   1.199 -  GraphReader<Graph> graphReader(const char* fn, Graph& graph) {
   1.200 -    GraphReader<Graph> tmp(fn, graph);
   1.201 +  GraphReader<Graph> graphReader(Graph& graph, const char* fn) {
   1.202 +    GraphReader<Graph> tmp(graph, fn);
   1.203      return tmp;
   1.204    }
   1.205