COIN-OR::LEMON - Graph Library

Changeset 294:cbe3ec2d59d2 in lemon-1.2 for lemon/lgf_writer.h


Ignore:
Timestamp:
10/01/08 13:56:40 (16 years ago)
Author:
Alpar Juttner <alpar@…>
Branch:
default
Children:
295:7c796c1cf1b0, 296:9768e60aa4e1
Parents:
293:47fbc814aa31 (diff), 292:e7af73f1805e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Phase:
public
Message:

Merge

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • lemon/lgf_writer.h

    r291 r294  
    353353
    354354  template <typename Digraph>
    355   DigraphWriter<Digraph> digraphWriter(std::ostream& os,
    356                                        const Digraph& digraph);
     355  DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
     356                                       std::ostream& os = std::cout);
    357357
    358358  template <typename Digraph>
    359   DigraphWriter<Digraph> digraphWriter(const std::string& fn,
    360                                        const Digraph& digraph);
     359  DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
     360                                       const std::string& fn);
    361361
    362362  template <typename Digraph>
    363   DigraphWriter<Digraph> digraphWriter(const char *fn,
    364                                        const Digraph& digraph);
     363  DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
     364                                       const char *fn);
    365365
    366366  /// \ingroup lemon_io
     
    383383  ///
    384384  ///\code
    385   /// DigraphWriter<Digraph>(std::cout, digraph).
     385  /// DigraphWriter<Digraph>(digraph, std::cout).
    386386  ///   nodeMap("coordinates", coord_map).
    387387  ///   nodeMap("size", size).
     
    453453    /// Construct a directed graph writer, which writes to the given
    454454    /// output stream.
    455     DigraphWriter(std::ostream& is, const Digraph& digraph)
    456       : _os(&is), local_os(false), _digraph(digraph),
     455    DigraphWriter(const Digraph& digraph, std::ostream& os = std::cout)
     456      : _os(&os), local_os(false), _digraph(digraph),
    457457        _skip_nodes(false), _skip_arcs(false) {}
    458458
     
    461461    /// Construct a directed graph writer, which writes to the given
    462462    /// output file.
    463     DigraphWriter(const std::string& fn, const Digraph& digraph)
     463    DigraphWriter(const Digraph& digraph, const std::string& fn)
    464464      : _os(new std::ofstream(fn.c_str())), local_os(true), _digraph(digraph),
    465465        _skip_nodes(false), _skip_arcs(false) {
     
    471471    /// Construct a directed graph writer, which writes to the given
    472472    /// output file.
    473     DigraphWriter(const char* fn, const Digraph& digraph)
     473    DigraphWriter(const Digraph& digraph, const char* fn)
    474474      : _os(new std::ofstream(fn)), local_os(true), _digraph(digraph),
    475475        _skip_nodes(false), _skip_arcs(false) {
     
    501501  private:
    502502
    503     friend DigraphWriter<Digraph> digraphWriter<>(std::ostream& os,
    504                                                   const Digraph& digraph);
    505     friend DigraphWriter<Digraph> digraphWriter<>(const std::string& fn,
    506                                                   const Digraph& digraph);
    507     friend DigraphWriter<Digraph> digraphWriter<>(const char *fn,
    508                                                   const Digraph& digraph);
     503    friend DigraphWriter<Digraph> digraphWriter<>(const Digraph& digraph,
     504                                                  std::ostream& os);
     505    friend DigraphWriter<Digraph> digraphWriter<>(const Digraph& digraph,
     506                                                  const std::string& fn);
     507    friend DigraphWriter<Digraph> digraphWriter<>(const Digraph& digraph,
     508                                                  const char *fn);
    509509
    510510    DigraphWriter(DigraphWriter& other)
     
    913913  /// \relates DigraphWriter
    914914  template <typename Digraph>
    915   DigraphWriter<Digraph> digraphWriter(std::ostream& os,
    916                                        const Digraph& digraph) {
    917     DigraphWriter<Digraph> tmp(os, digraph);
     915  DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
     916                                       std::ostream& os = std::cout) {
     917    DigraphWriter<Digraph> tmp(digraph, os);
    918918    return tmp;
    919919  }
     
    924924  /// \relates DigraphWriter
    925925  template <typename Digraph>
    926   DigraphWriter<Digraph> digraphWriter(const std::string& fn,
    927                                        const Digraph& digraph) {
    928     DigraphWriter<Digraph> tmp(fn, digraph);
     926  DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
     927                                       const std::string& fn) {
     928    DigraphWriter<Digraph> tmp(digraph, fn);
    929929    return tmp;
    930930  }
     
    935935  /// \relates DigraphWriter
    936936  template <typename Digraph>
    937   DigraphWriter<Digraph> digraphWriter(const char* fn,
    938                                        const Digraph& digraph) {
    939     DigraphWriter<Digraph> tmp(fn, digraph);
     937  DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
     938                                       const char* fn) {
     939    DigraphWriter<Digraph> tmp(digraph, fn);
    940940    return tmp;
    941941  }
     
    945945
    946946  template <typename Graph>
    947   GraphWriter<Graph> graphWriter(std::ostream& os, const Graph& graph);
     947  GraphWriter<Graph> graphWriter(const Graph& graph,
     948                                 std::ostream& os = std::cout);
    948949
    949950  template <typename Graph>
    950   GraphWriter<Graph> graphWriter(const std::string& fn, const Graph& graph);
     951  GraphWriter<Graph> graphWriter(const Graph& graph, const std::string& fn);
    951952
    952953  template <typename Graph>
    953   GraphWriter<Graph> graphWriter(const char *fn, const Graph& graph);
     954  GraphWriter<Graph> graphWriter(const Graph& graph, const char *fn);
    954955
    955956  /// \ingroup lemon_io
     
    10131014    /// Construct a directed graph writer, which writes to the given
    10141015    /// output stream.
    1015     GraphWriter(std::ostream& is, const Graph& graph)
    1016       : _os(&is), local_os(false), _graph(graph),
     1016    GraphWriter(const Graph& graph, std::ostream& os = std::cout)
     1017      : _os(&os), local_os(false), _graph(graph),
    10171018        _skip_nodes(false), _skip_edges(false) {}
    10181019
     
    10211022    /// Construct a directed graph writer, which writes to the given
    10221023    /// output file.
    1023     GraphWriter(const std::string& fn, const Graph& graph)
     1024    GraphWriter(const Graph& graph, const std::string& fn)
    10241025      : _os(new std::ofstream(fn.c_str())), local_os(true), _graph(graph),
    10251026        _skip_nodes(false), _skip_edges(false) {
     
    10311032    /// Construct a directed graph writer, which writes to the given
    10321033    /// output file.
    1033     GraphWriter(const char* fn, const Graph& graph)
     1034    GraphWriter(const Graph& graph, const char* fn)
    10341035      : _os(new std::ofstream(fn)), local_os(true), _graph(graph),
    10351036        _skip_nodes(false), _skip_edges(false) {
     
    10611062  private:
    10621063
    1063     friend GraphWriter<Graph> graphWriter<>(std::ostream& os,
    1064                                             const Graph& graph);
    1065     friend GraphWriter<Graph> graphWriter<>(const std::string& fn,
    1066                                             const Graph& graph);
    1067     friend GraphWriter<Graph> graphWriter<>(const char *fn,
    1068                                             const Graph& graph);
     1064    friend GraphWriter<Graph> graphWriter<>(const Graph& graph,
     1065                                            std::ostream& os);
     1066    friend GraphWriter<Graph> graphWriter<>(const Graph& graph,
     1067                                            const std::string& fn);
     1068    friend GraphWriter<Graph> graphWriter<>(const Graph& graph,
     1069                                            const char *fn);
    10691070
    10701071    GraphWriter(GraphWriter& other)
     
    15191520  /// \relates GraphWriter
    15201521  template <typename Graph>
    1521   GraphWriter<Graph> graphWriter(std::ostream& os, const Graph& graph) {
    1522     GraphWriter<Graph> tmp(os, graph);
     1522  GraphWriter<Graph> graphWriter(const Graph& graph,
     1523                                 std::ostream& os = std::cout) {
     1524    GraphWriter<Graph> tmp(graph, os);
    15231525    return tmp;
    15241526  }
     
    15291531  /// \relates GraphWriter
    15301532  template <typename Graph>
    1531   GraphWriter<Graph> graphWriter(const std::string& fn, const Graph& graph) {
    1532     GraphWriter<Graph> tmp(fn, graph);
     1533  GraphWriter<Graph> graphWriter(const Graph& graph, const std::string& fn) {
     1534    GraphWriter<Graph> tmp(graph, fn);
    15331535    return tmp;
    15341536  }
     
    15391541  /// \relates GraphWriter
    15401542  template <typename Graph>
    1541   GraphWriter<Graph> graphWriter(const char* fn, const Graph& graph) {
    1542     GraphWriter<Graph> tmp(fn, graph);
     1543  GraphWriter<Graph> graphWriter(const Graph& graph, const char* fn) {
     1544    GraphWriter<Graph> tmp(graph, fn);
    15431545    return tmp;
    15441546  }
  • lemon/lgf_writer.h

    r293 r294  
    5656    template <typename T>
    5757    bool operator<(const T&, const T&) {
    58       throw DataFormatError("Label map is not comparable");
     58      throw FormatError("Label map is not comparable");
    5959    }
    6060
     
    204204          _map.find(str);
    205205        if (it == _map.end()) {
    206           throw DataFormatError("Item not found");
     206          throw FormatError("Item not found");
    207207        }
    208208        return it->second;
     
    224224          ::const_iterator it = _map.find(val);
    225225        if (it == _map.end()) {
    226           throw DataFormatError("Item not found");
     226          throw FormatError("Item not found");
    227227        }
    228228        return (_graph.direction(val) ? '+' : '-') + it->second;
     
    463463    DigraphWriter(const Digraph& digraph, const std::string& fn)
    464464      : _os(new std::ofstream(fn.c_str())), local_os(true), _digraph(digraph),
    465         _skip_nodes(false), _skip_arcs(false) {}
     465        _skip_nodes(false), _skip_arcs(false) {
     466      if (!(*_os)) throw IoError("Cannot write file", fn);
     467    }
    466468
    467469    /// \brief Constructor
     
    471473    DigraphWriter(const Digraph& digraph, const char* fn)
    472474      : _os(new std::ofstream(fn)), local_os(true), _digraph(digraph),
    473         _skip_nodes(false), _skip_arcs(false) {}
     475        _skip_nodes(false), _skip_arcs(false) {
     476      if (!(*_os)) throw IoError("Cannot write file", fn);
     477    }
    474478
    475479    /// \brief Destructor
     
    10201024    GraphWriter(const Graph& graph, const std::string& fn)
    10211025      : _os(new std::ofstream(fn.c_str())), local_os(true), _graph(graph),
    1022         _skip_nodes(false), _skip_edges(false) {}
     1026        _skip_nodes(false), _skip_edges(false) {
     1027      if (!(*_os)) throw IoError("Cannot write file", fn);
     1028    }
    10231029
    10241030    /// \brief Constructor
     
    10281034    GraphWriter(const Graph& graph, const char* fn)
    10291035      : _os(new std::ofstream(fn)), local_os(true), _graph(graph),
    1030         _skip_nodes(false), _skip_edges(false) {}
     1036        _skip_nodes(false), _skip_edges(false) {
     1037      if (!(*_os)) throw IoError("Cannot write file", fn);
     1038    }
    10311039
    10321040    /// \brief Destructor
     
    15791587    /// Construct a section writer, which writes into the given file.
    15801588    SectionWriter(const std::string& fn)
    1581       : _os(new std::ofstream(fn.c_str())), local_os(true) {}
     1589      : _os(new std::ofstream(fn.c_str())), local_os(true) {
     1590      if (!(*_os)) throw IoError("Cannot write file", fn);
     1591    }
    15821592
    15831593    /// \brief Constructor
     
    15851595    /// Construct a section writer, which writes into the given file.
    15861596    SectionWriter(const char* fn)
    1587       : _os(new std::ofstream(fn)), local_os(true) {}
     1597      : _os(new std::ofstream(fn)), local_os(true) {
     1598      if (!(*_os)) throw IoError("Cannot write file", fn);
     1599    }
    15881600
    15891601    /// \brief Destructor
Note: See TracChangeset for help on using the changeset viewer.