lemon/lgf_reader.h
changeset 801 e9c203fb003d
parent 319 5e12d7734036
child 517 2b6d5d22bb23
child 949 54464584b157
equal deleted inserted replaced
33:c71b68907964 36:46f2d261df48
   388   }
   388   }
   389 
   389 
   390   template <typename Digraph>
   390   template <typename Digraph>
   391   class DigraphReader;
   391   class DigraphReader;
   392 
   392 
   393   /// \brief Return a \ref DigraphReader class
       
   394   ///
       
   395   /// This function just returns a \ref DigraphReader class.
       
   396   /// \relates DigraphReader
       
   397   template <typename Digraph>
   393   template <typename Digraph>
   398   DigraphReader<Digraph> digraphReader(Digraph& digraph,
   394   DigraphReader<Digraph> digraphReader(Digraph& digraph, 
   399                                        std::istream& is = std::cin) {
   395                                        std::istream& is = std::cin);
   400     DigraphReader<Digraph> tmp(digraph, is);
       
   401     return tmp;
       
   402   }
       
   403 
       
   404   /// \brief Return a \ref DigraphReader class
       
   405   ///
       
   406   /// This function just returns a \ref DigraphReader class.
       
   407   /// \relates DigraphReader
       
   408   template <typename Digraph>
   396   template <typename Digraph>
   409   DigraphReader<Digraph> digraphReader(Digraph& digraph,
   397   DigraphReader<Digraph> digraphReader(Digraph& digraph, const std::string& fn);
   410                                        const std::string& fn) {
       
   411     DigraphReader<Digraph> tmp(digraph, fn);
       
   412     return tmp;
       
   413   }
       
   414 
       
   415   /// \brief Return a \ref DigraphReader class
       
   416   ///
       
   417   /// This function just returns a \ref DigraphReader class.
       
   418   /// \relates DigraphReader
       
   419   template <typename Digraph>
   398   template <typename Digraph>
   420   DigraphReader<Digraph> digraphReader(Digraph& digraph, const char* fn) {
   399   DigraphReader<Digraph> digraphReader(Digraph& digraph, const char *fn);
   421     DigraphReader<Digraph> tmp(digraph, fn);
       
   422     return tmp;
       
   423   }
       
   424 
   400 
   425   /// \ingroup lemon_io
   401   /// \ingroup lemon_io
   426   ///
   402   ///
   427   /// \brief \ref lgf-format "LGF" reader for directed graphs
   403   /// \brief \ref lgf-format "LGF" reader for directed graphs
   428   ///
   404   ///
   582 
   558 
   583     }
   559     }
   584 
   560 
   585   private:
   561   private:
   586 
   562 
   587     friend DigraphReader<Digraph> digraphReader<>(Digraph& digraph,
   563     template <typename DGR>
   588                                                   std::istream& is);
   564     friend DigraphReader<DGR> digraphReader(DGR& digraph, std::istream& is);
   589     friend DigraphReader<Digraph> digraphReader<>(Digraph& digraph,
   565     template <typename DGR>
   590                                                   const std::string& fn);
   566     friend DigraphReader<DGR> digraphReader(DGR& digraph, 
   591     friend DigraphReader<Digraph> digraphReader<>(Digraph& digraph,
   567                                             const std::string& fn);
   592                                                   const char *fn);
   568     template <typename DGR>
       
   569     friend DigraphReader<DGR> digraphReader(DGR& digraph, const char *fn);
   593 
   570 
   594     DigraphReader(DigraphReader& other)
   571     DigraphReader(DigraphReader& other)
   595       : _is(other._is), local_is(other.local_is), _digraph(other._digraph),
   572       : _is(other._is), local_is(other.local_is), _digraph(other._digraph),
   596         _use_nodes(other._use_nodes), _use_arcs(other._use_arcs),
   573         _use_nodes(other._use_nodes), _use_arcs(other._use_arcs),
   597         _skip_nodes(other._skip_nodes), _skip_arcs(other._skip_arcs) {
   574         _skip_nodes(other._skip_nodes), _skip_arcs(other._skip_arcs) {
  1208 
  1185 
  1209     /// @}
  1186     /// @}
  1210 
  1187 
  1211   };
  1188   };
  1212 
  1189 
       
  1190   /// \brief Return a \ref DigraphReader class
       
  1191   ///
       
  1192   /// This function just returns a \ref DigraphReader class.
       
  1193   /// \relates DigraphReader
       
  1194   template <typename Digraph>
       
  1195   DigraphReader<Digraph> digraphReader(Digraph& digraph, std::istream& is) {
       
  1196     DigraphReader<Digraph> tmp(digraph, is);
       
  1197     return tmp;
       
  1198   }
       
  1199 
       
  1200   /// \brief Return a \ref DigraphReader class
       
  1201   ///
       
  1202   /// This function just returns a \ref DigraphReader class.
       
  1203   /// \relates DigraphReader
       
  1204   template <typename Digraph>
       
  1205   DigraphReader<Digraph> digraphReader(Digraph& digraph,
       
  1206                                        const std::string& fn) {
       
  1207     DigraphReader<Digraph> tmp(digraph, fn);
       
  1208     return tmp;
       
  1209   }
       
  1210 
       
  1211   /// \brief Return a \ref DigraphReader class
       
  1212   ///
       
  1213   /// This function just returns a \ref DigraphReader class.
       
  1214   /// \relates DigraphReader
       
  1215   template <typename Digraph>
       
  1216   DigraphReader<Digraph> digraphReader(Digraph& digraph, const char* fn) {
       
  1217     DigraphReader<Digraph> tmp(digraph, fn);
       
  1218     return tmp;
       
  1219   }
       
  1220 
  1213   template <typename Graph>
  1221   template <typename Graph>
  1214   class GraphReader;
  1222   class GraphReader;
  1215 
  1223  
  1216   /// \brief Return a \ref GraphReader class
       
  1217   ///
       
  1218   /// This function just returns a \ref GraphReader class.
       
  1219   /// \relates GraphReader
       
  1220   template <typename Graph>
  1224   template <typename Graph>
  1221   GraphReader<Graph> graphReader(Graph& graph, std::istream& is = std::cin) {
  1225   GraphReader<Graph> graphReader(Graph& graph, 
  1222     GraphReader<Graph> tmp(graph, is);
  1226                                  std::istream& is = std::cin);
  1223     return tmp;
       
  1224   }
       
  1225 
       
  1226   /// \brief Return a \ref GraphReader class
       
  1227   ///
       
  1228   /// This function just returns a \ref GraphReader class.
       
  1229   /// \relates GraphReader
       
  1230   template <typename Graph>
  1227   template <typename Graph>
  1231   GraphReader<Graph> graphReader(Graph& graph, const std::string& fn) {
  1228   GraphReader<Graph> graphReader(Graph& graph, const std::string& fn);
  1232     GraphReader<Graph> tmp(graph, fn);
       
  1233     return tmp;
       
  1234   }
       
  1235 
       
  1236   /// \brief Return a \ref GraphReader class
       
  1237   ///
       
  1238   /// This function just returns a \ref GraphReader class.
       
  1239   /// \relates GraphReader
       
  1240   template <typename Graph>
  1229   template <typename Graph>
  1241   GraphReader<Graph> graphReader(Graph& graph, const char* fn) {
  1230   GraphReader<Graph> graphReader(Graph& graph, const char *fn);
  1242     GraphReader<Graph> tmp(graph, fn);
       
  1243     return tmp;
       
  1244   }
       
  1245 
  1231 
  1246   /// \ingroup lemon_io
  1232   /// \ingroup lemon_io
  1247   ///
  1233   ///
  1248   /// \brief \ref lgf-format "LGF" reader for undirected graphs
  1234   /// \brief \ref lgf-format "LGF" reader for undirected graphs
  1249   ///
  1235   ///
  1366       }
  1352       }
  1367 
  1353 
  1368     }
  1354     }
  1369 
  1355 
  1370   private:
  1356   private:
  1371     friend GraphReader<Graph> graphReader<>(Graph& graph, std::istream& is);
  1357     template <typename GR>
  1372     friend GraphReader<Graph> graphReader<>(Graph& graph,
  1358     friend GraphReader<GR> graphReader(GR& graph, std::istream& is);
  1373                                             const std::string& fn);
  1359     template <typename GR>
  1374     friend GraphReader<Graph> graphReader<>(Graph& graph, const char *fn);
  1360     friend GraphReader<GR> graphReader(GR& graph, const std::string& fn); 
       
  1361     template <typename GR>
       
  1362     friend GraphReader<GR> graphReader(GR& graph, const char *fn);
  1375 
  1363 
  1376     GraphReader(GraphReader& other)
  1364     GraphReader(GraphReader& other)
  1377       : _is(other._is), local_is(other.local_is), _graph(other._graph),
  1365       : _is(other._is), local_is(other.local_is), _graph(other._graph),
  1378         _use_nodes(other._use_nodes), _use_edges(other._use_edges),
  1366         _use_nodes(other._use_nodes), _use_edges(other._use_edges),
  1379         _skip_nodes(other._skip_nodes), _skip_edges(other._skip_edges) {
  1367         _skip_nodes(other._skip_nodes), _skip_edges(other._skip_edges) {
  2037     }
  2025     }
  2038 
  2026 
  2039     /// @}
  2027     /// @}
  2040 
  2028 
  2041   };
  2029   };
       
  2030 
       
  2031   /// \brief Return a \ref GraphReader class
       
  2032   ///
       
  2033   /// This function just returns a \ref GraphReader class.
       
  2034   /// \relates GraphReader
       
  2035   template <typename Graph>
       
  2036   GraphReader<Graph> graphReader(Graph& graph, std::istream& is) {
       
  2037     GraphReader<Graph> tmp(graph, is);
       
  2038     return tmp;
       
  2039   }
       
  2040 
       
  2041   /// \brief Return a \ref GraphReader class
       
  2042   ///
       
  2043   /// This function just returns a \ref GraphReader class.
       
  2044   /// \relates GraphReader
       
  2045   template <typename Graph>
       
  2046   GraphReader<Graph> graphReader(Graph& graph, const std::string& fn) {
       
  2047     GraphReader<Graph> tmp(graph, fn);
       
  2048     return tmp;
       
  2049   }
       
  2050 
       
  2051   /// \brief Return a \ref GraphReader class
       
  2052   ///
       
  2053   /// This function just returns a \ref GraphReader class.
       
  2054   /// \relates GraphReader
       
  2055   template <typename Graph>
       
  2056   GraphReader<Graph> graphReader(Graph& graph, const char* fn) {
       
  2057     GraphReader<Graph> tmp(graph, fn);
       
  2058     return tmp;
       
  2059   }
  2042 
  2060 
  2043   class SectionReader;
  2061   class SectionReader;
  2044 
  2062 
  2045   SectionReader sectionReader(std::istream& is);
  2063   SectionReader sectionReader(std::istream& is);
  2046   SectionReader sectionReader(const std::string& fn);
  2064   SectionReader sectionReader(const std::string& fn);