lemon/lgf_writer.h
changeset 511 8a144437db7d
parent 319 5e12d7734036
child 517 2b6d5d22bb23
equal deleted inserted replaced
25:b556bc206c77 27:467569230fa7
   348   }
   348   }
   349 
   349 
   350   template <typename Digraph>
   350   template <typename Digraph>
   351   class DigraphWriter;
   351   class DigraphWriter;
   352 
   352 
   353   /// \brief Return a \ref DigraphWriter class
       
   354   ///
       
   355   /// This function just returns a \ref DigraphWriter class.
       
   356   /// \relates DigraphWriter
       
   357   template <typename Digraph>
   353   template <typename Digraph>
   358   DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
   354   DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
   359                                        std::ostream& os = std::cout) {
   355                                        std::ostream& os = std::cout);
   360     DigraphWriter<Digraph> tmp(digraph, os);
       
   361     return tmp;
       
   362   }
       
   363 
       
   364   /// \brief Return a \ref DigraphWriter class
       
   365   ///
       
   366   /// This function just returns a \ref DigraphWriter class.
       
   367   /// \relates DigraphWriter
       
   368   template <typename Digraph>
   356   template <typename Digraph>
   369   DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
   357   DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
   370                                        const std::string& fn) {
   358                                        const std::string& fn);
   371     DigraphWriter<Digraph> tmp(digraph, fn);
   359 
   372     return tmp;
       
   373   }
       
   374 
       
   375   /// \brief Return a \ref DigraphWriter class
       
   376   ///
       
   377   /// This function just returns a \ref DigraphWriter class.
       
   378   /// \relates DigraphWriter
       
   379   template <typename Digraph>
   360   template <typename Digraph>
   380   DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
   361   DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
   381                                        const char* fn) {
   362                                        const char* fn);
   382     DigraphWriter<Digraph> tmp(digraph, fn);
   363 
   383     return tmp;
       
   384   }
       
   385 
   364 
   386   /// \ingroup lemon_io
   365   /// \ingroup lemon_io
   387   ///
   366   ///
   388   /// \brief \ref lgf-format "LGF" writer for directed graphs
   367   /// \brief \ref lgf-format "LGF" writer for directed graphs
   389   ///
   368   ///
   524       }
   503       }
   525     }
   504     }
   526 
   505 
   527   private:
   506   private:
   528 
   507 
   529     friend DigraphWriter<Digraph> digraphWriter<>(const Digraph& digraph,
   508     template <typename DGR>
   530                                                   std::ostream& os);
   509     friend DigraphWriter<DGR> digraphWriter(const DGR& digraph, 
   531     friend DigraphWriter<Digraph> digraphWriter<>(const Digraph& digraph,
   510                                             std::ostream& os);
   532                                                   const std::string& fn);
   511     template <typename DGR>
   533     friend DigraphWriter<Digraph> digraphWriter<>(const Digraph& digraph,
   512     friend DigraphWriter<DGR> digraphWriter(const DGR& digraph,
   534                                                   const char *fn);
   513                                             const std::string& fn);
       
   514     template <typename DGR>
       
   515     friend DigraphWriter<DGR> digraphWriter(const DGR& digraph,
       
   516                                             const char *fn);
   535 
   517 
   536     DigraphWriter(DigraphWriter& other)
   518     DigraphWriter(DigraphWriter& other)
   537       : _os(other._os), local_os(other.local_os), _digraph(other._digraph),
   519       : _os(other._os), local_os(other.local_os), _digraph(other._digraph),
   538         _skip_nodes(other._skip_nodes), _skip_arcs(other._skip_arcs) {
   520         _skip_nodes(other._skip_nodes), _skip_arcs(other._skip_arcs) {
   539 
   521 
   931     }
   913     }
   932 
   914 
   933     /// @}
   915     /// @}
   934   };
   916   };
   935 
   917 
       
   918   /// \brief Return a \ref DigraphWriter class
       
   919   ///
       
   920   /// This function just returns a \ref DigraphWriter class.
       
   921   /// \relates DigraphWriter
       
   922   template <typename Digraph>
       
   923   DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
       
   924                                        std::ostream& os) {
       
   925     DigraphWriter<Digraph> tmp(digraph, os);
       
   926     return tmp;
       
   927   }
       
   928 
       
   929   /// \brief Return a \ref DigraphWriter class
       
   930   ///
       
   931   /// This function just returns a \ref DigraphWriter class.
       
   932   /// \relates DigraphWriter
       
   933   template <typename Digraph>
       
   934   DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
       
   935                                        const std::string& fn) {
       
   936     DigraphWriter<Digraph> tmp(digraph, fn);
       
   937     return tmp;
       
   938   }
       
   939 
       
   940   /// \brief Return a \ref DigraphWriter class
       
   941   ///
       
   942   /// This function just returns a \ref DigraphWriter class.
       
   943   /// \relates DigraphWriter
       
   944   template <typename Digraph>
       
   945   DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
       
   946                                        const char* fn) {
       
   947     DigraphWriter<Digraph> tmp(digraph, fn);
       
   948     return tmp;
       
   949   }
       
   950 
   936   template <typename Graph>
   951   template <typename Graph>
   937   class GraphWriter;
   952   class GraphWriter;
   938 
   953 
   939   /// \brief Return a \ref GraphWriter class
       
   940   ///
       
   941   /// This function just returns a \ref GraphWriter class.
       
   942   /// \relates GraphWriter
       
   943   template <typename Graph>
   954   template <typename Graph>
   944   GraphWriter<Graph> graphWriter(const Graph& graph,
   955   GraphWriter<Graph> graphWriter(const Graph& graph,
   945                                  std::ostream& os = std::cout) {
   956                                  std::ostream& os = std::cout);
   946     GraphWriter<Graph> tmp(graph, os);
       
   947     return tmp;
       
   948   }
       
   949 
       
   950   /// \brief Return a \ref GraphWriter class
       
   951   ///
       
   952   /// This function just returns a \ref GraphWriter class.
       
   953   /// \relates GraphWriter
       
   954   template <typename Graph>
   957   template <typename Graph>
   955   GraphWriter<Graph> graphWriter(const Graph& graph, const std::string& fn) {
   958   GraphWriter<Graph> graphWriter(const Graph& graph, const std::string& fn);
   956     GraphWriter<Graph> tmp(graph, fn);
       
   957     return tmp;
       
   958   }
       
   959 
       
   960   /// \brief Return a \ref GraphWriter class
       
   961   ///
       
   962   /// This function just returns a \ref GraphWriter class.
       
   963   /// \relates GraphWriter
       
   964   template <typename Graph>
   959   template <typename Graph>
   965   GraphWriter<Graph> graphWriter(const Graph& graph, const char* fn) {
   960   GraphWriter<Graph> graphWriter(const Graph& graph, const char* fn);
   966     GraphWriter<Graph> tmp(graph, fn);
       
   967     return tmp;
       
   968   }
       
   969 
   961 
   970   /// \ingroup lemon_io
   962   /// \ingroup lemon_io
   971   ///
   963   ///
   972   /// \brief \ref lgf-format "LGF" writer for directed graphs
   964   /// \brief \ref lgf-format "LGF" writer for directed graphs
   973   ///
   965   ///
  1079       }
  1071       }
  1080     }
  1072     }
  1081 
  1073 
  1082   private:
  1074   private:
  1083 
  1075 
  1084     friend GraphWriter<Graph> graphWriter<>(const Graph& graph,
  1076     template <typename GR>
  1085                                             std::ostream& os);
  1077     friend GraphWriter<GR> graphWriter(const GR& graph,
  1086     friend GraphWriter<Graph> graphWriter<>(const Graph& graph,
  1078                                        std::ostream& os);
  1087                                             const std::string& fn);
  1079     template <typename GR>
  1088     friend GraphWriter<Graph> graphWriter<>(const Graph& graph,
  1080     friend GraphWriter<GR> graphWriter(const GR& graph,
  1089                                             const char *fn);
  1081                                        const std::string& fn);
  1090 
  1082     template <typename GR>
       
  1083     friend GraphWriter<GR> graphWriter(const GR& graph,
       
  1084                                        const char *fn);
       
  1085     
  1091     GraphWriter(GraphWriter& other)
  1086     GraphWriter(GraphWriter& other)
  1092       : _os(other._os), local_os(other.local_os), _graph(other._graph),
  1087       : _os(other._os), local_os(other.local_os), _graph(other._graph),
  1093         _skip_nodes(other._skip_nodes), _skip_edges(other._skip_edges) {
  1088         _skip_nodes(other._skip_nodes), _skip_edges(other._skip_edges) {
  1094 
  1089 
  1095       other._os = 0;
  1090       other._os = 0;
  1531       return *_os;
  1526       return *_os;
  1532     }
  1527     }
  1533 
  1528 
  1534     /// @}
  1529     /// @}
  1535   };
  1530   };
       
  1531 
       
  1532   /// \brief Return a \ref GraphWriter class
       
  1533   ///
       
  1534   /// This function just returns a \ref GraphWriter class.
       
  1535   /// \relates GraphWriter
       
  1536   template <typename Graph>
       
  1537   GraphWriter<Graph> graphWriter(const Graph& graph,
       
  1538                                  std::ostream& os) {
       
  1539     GraphWriter<Graph> tmp(graph, os);
       
  1540     return tmp;
       
  1541   }
       
  1542 
       
  1543   /// \brief Return a \ref GraphWriter class
       
  1544   ///
       
  1545   /// This function just returns a \ref GraphWriter class.
       
  1546   /// \relates GraphWriter
       
  1547   template <typename Graph>
       
  1548   GraphWriter<Graph> graphWriter(const Graph& graph, const std::string& fn) {
       
  1549     GraphWriter<Graph> tmp(graph, fn);
       
  1550     return tmp;
       
  1551   }
       
  1552 
       
  1553   /// \brief Return a \ref GraphWriter class
       
  1554   ///
       
  1555   /// This function just returns a \ref GraphWriter class.
       
  1556   /// \relates GraphWriter
       
  1557   template <typename Graph>
       
  1558   GraphWriter<Graph> graphWriter(const Graph& graph, const char* fn) {
       
  1559     GraphWriter<Graph> tmp(graph, fn);
       
  1560     return tmp;
       
  1561   }
  1536 
  1562 
  1537   class SectionWriter;
  1563   class SectionWriter;
  1538 
  1564 
  1539   SectionWriter sectionWriter(std::istream& is);
  1565   SectionWriter sectionWriter(std::istream& is);
  1540   SectionWriter sectionWriter(const std::string& fn);
  1566   SectionWriter sectionWriter(const std::string& fn);