lemon/lgf_reader.h
changeset 522 22f932bbb305
parent 440 88ed40ad0d4f
parent 487 afd134142111
child 559 c5fd2d996909
equal deleted inserted replaced
35:30b9e0cfac6c 37:09a1d939e96d
   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) {
  1210 
  1187 
  1211     /// @}
  1188     /// @}
  1212 
  1189 
  1213   };
  1190   };
  1214 
  1191 
       
  1192   /// \brief Return a \ref DigraphReader class
       
  1193   ///
       
  1194   /// This function just returns a \ref DigraphReader class.
       
  1195   /// \relates DigraphReader
       
  1196   template <typename Digraph>
       
  1197   DigraphReader<Digraph> digraphReader(Digraph& digraph, std::istream& is) {
       
  1198     DigraphReader<Digraph> tmp(digraph, is);
       
  1199     return tmp;
       
  1200   }
       
  1201 
       
  1202   /// \brief Return a \ref DigraphReader class
       
  1203   ///
       
  1204   /// This function just returns a \ref DigraphReader class.
       
  1205   /// \relates DigraphReader
       
  1206   template <typename Digraph>
       
  1207   DigraphReader<Digraph> digraphReader(Digraph& digraph,
       
  1208                                        const std::string& fn) {
       
  1209     DigraphReader<Digraph> tmp(digraph, fn);
       
  1210     return tmp;
       
  1211   }
       
  1212 
       
  1213   /// \brief Return a \ref DigraphReader class
       
  1214   ///
       
  1215   /// This function just returns a \ref DigraphReader class.
       
  1216   /// \relates DigraphReader
       
  1217   template <typename Digraph>
       
  1218   DigraphReader<Digraph> digraphReader(Digraph& digraph, const char* fn) {
       
  1219     DigraphReader<Digraph> tmp(digraph, fn);
       
  1220     return tmp;
       
  1221   }
       
  1222 
  1215   template <typename Graph>
  1223   template <typename Graph>
  1216   class GraphReader;
  1224   class GraphReader;
  1217 
  1225  
  1218   /// \brief Return a \ref GraphReader class
       
  1219   ///
       
  1220   /// This function just returns a \ref GraphReader class.
       
  1221   /// \relates GraphReader
       
  1222   template <typename Graph>
  1226   template <typename Graph>
  1223   GraphReader<Graph> graphReader(Graph& graph, std::istream& is = std::cin) {
  1227   GraphReader<Graph> graphReader(Graph& graph, 
  1224     GraphReader<Graph> tmp(graph, is);
  1228                                  std::istream& is = std::cin);
  1225     return tmp;
       
  1226   }
       
  1227 
       
  1228   /// \brief Return a \ref GraphReader class
       
  1229   ///
       
  1230   /// This function just returns a \ref GraphReader class.
       
  1231   /// \relates GraphReader
       
  1232   template <typename Graph>
  1229   template <typename Graph>
  1233   GraphReader<Graph> graphReader(Graph& graph, const std::string& fn) {
  1230   GraphReader<Graph> graphReader(Graph& graph, const std::string& fn);
  1234     GraphReader<Graph> tmp(graph, fn);
       
  1235     return tmp;
       
  1236   }
       
  1237 
       
  1238   /// \brief Return a \ref GraphReader class
       
  1239   ///
       
  1240   /// This function just returns a \ref GraphReader class.
       
  1241   /// \relates GraphReader
       
  1242   template <typename Graph>
  1231   template <typename Graph>
  1243   GraphReader<Graph> graphReader(Graph& graph, const char* fn) {
  1232   GraphReader<Graph> graphReader(Graph& graph, const char *fn);
  1244     GraphReader<Graph> tmp(graph, fn);
       
  1245     return tmp;
       
  1246   }
       
  1247 
  1233 
  1248   /// \ingroup lemon_io
  1234   /// \ingroup lemon_io
  1249   ///
  1235   ///
  1250   /// \brief \ref lgf-format "LGF" reader for undirected graphs
  1236   /// \brief \ref lgf-format "LGF" reader for undirected graphs
  1251   ///
  1237   ///
  1368       }
  1354       }
  1369 
  1355 
  1370     }
  1356     }
  1371 
  1357 
  1372   private:
  1358   private:
  1373     friend GraphReader<Graph> graphReader<>(Graph& graph, std::istream& is);
  1359     template <typename GR>
  1374     friend GraphReader<Graph> graphReader<>(Graph& graph,
  1360     friend GraphReader<GR> graphReader(GR& graph, std::istream& is);
  1375                                             const std::string& fn);
  1361     template <typename GR>
  1376     friend GraphReader<Graph> graphReader<>(Graph& graph, const char *fn);
  1362     friend GraphReader<GR> graphReader(GR& graph, const std::string& fn); 
       
  1363     template <typename GR>
       
  1364     friend GraphReader<GR> graphReader(GR& graph, const char *fn);
  1377 
  1365 
  1378     GraphReader(GraphReader& other)
  1366     GraphReader(GraphReader& other)
  1379       : _is(other._is), local_is(other.local_is), _graph(other._graph),
  1367       : _is(other._is), local_is(other.local_is), _graph(other._graph),
  1380         _use_nodes(other._use_nodes), _use_edges(other._use_edges),
  1368         _use_nodes(other._use_nodes), _use_edges(other._use_edges),
  1381         _skip_nodes(other._skip_nodes), _skip_edges(other._skip_edges) {
  1369         _skip_nodes(other._skip_nodes), _skip_edges(other._skip_edges) {
  2041     }
  2029     }
  2042 
  2030 
  2043     /// @}
  2031     /// @}
  2044 
  2032 
  2045   };
  2033   };
       
  2034 
       
  2035   /// \brief Return a \ref GraphReader class
       
  2036   ///
       
  2037   /// This function just returns a \ref GraphReader class.
       
  2038   /// \relates GraphReader
       
  2039   template <typename Graph>
       
  2040   GraphReader<Graph> graphReader(Graph& graph, std::istream& is) {
       
  2041     GraphReader<Graph> tmp(graph, is);
       
  2042     return tmp;
       
  2043   }
       
  2044 
       
  2045   /// \brief Return a \ref GraphReader class
       
  2046   ///
       
  2047   /// This function just returns a \ref GraphReader class.
       
  2048   /// \relates GraphReader
       
  2049   template <typename Graph>
       
  2050   GraphReader<Graph> graphReader(Graph& graph, const std::string& fn) {
       
  2051     GraphReader<Graph> tmp(graph, fn);
       
  2052     return tmp;
       
  2053   }
       
  2054 
       
  2055   /// \brief Return a \ref GraphReader class
       
  2056   ///
       
  2057   /// This function just returns a \ref GraphReader class.
       
  2058   /// \relates GraphReader
       
  2059   template <typename Graph>
       
  2060   GraphReader<Graph> graphReader(Graph& graph, const char* fn) {
       
  2061     GraphReader<Graph> tmp(graph, fn);
       
  2062     return tmp;
       
  2063   }
  2046 
  2064 
  2047   class SectionReader;
  2065   class SectionReader;
  2048 
  2066 
  2049   SectionReader sectionReader(std::istream& is);
  2067   SectionReader sectionReader(std::istream& is);
  2050   SectionReader sectionReader(const std::string& fn);
  2068   SectionReader sectionReader(const std::string& fn);