lemon/lgf_writer.h
changeset 306 2bf7c645d5a6
parent 294 cbe3ec2d59d2
child 303 a3a69f5bba62
equal deleted inserted replaced
22:fd5941d43a83 23:6f76525ec480
   461     /// Construct a directed graph writer, which writes to the given
   461     /// Construct a directed graph writer, which writes to the given
   462     /// output file.
   462     /// output file.
   463     DigraphWriter(const Digraph& digraph, const std::string& fn)
   463     DigraphWriter(const Digraph& digraph, const std::string& fn)
   464       : _os(new std::ofstream(fn.c_str())), local_os(true), _digraph(digraph),
   464       : _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);
   466       if (!(*_os)) {
       
   467         delete _os;
       
   468         throw IoError("Cannot write file", fn);
       
   469       }
   467     }
   470     }
   468 
   471 
   469     /// \brief Constructor
   472     /// \brief Constructor
   470     ///
   473     ///
   471     /// Construct a directed graph writer, which writes to the given
   474     /// Construct a directed graph writer, which writes to the given
   472     /// output file.
   475     /// output file.
   473     DigraphWriter(const Digraph& digraph, const char* fn)
   476     DigraphWriter(const Digraph& digraph, const char* fn)
   474       : _os(new std::ofstream(fn)), local_os(true), _digraph(digraph),
   477       : _os(new std::ofstream(fn)), local_os(true), _digraph(digraph),
   475         _skip_nodes(false), _skip_arcs(false) {
   478         _skip_nodes(false), _skip_arcs(false) {
   476       if (!(*_os)) throw IoError("Cannot write file", fn);
   479       if (!(*_os)) {
       
   480         delete _os;
       
   481         throw IoError("Cannot write file", fn);
       
   482       }
   477     }
   483     }
   478 
   484 
   479     /// \brief Destructor
   485     /// \brief Destructor
   480     ~DigraphWriter() {
   486     ~DigraphWriter() {
   481       for (typename NodeMaps::iterator it = _node_maps.begin();
   487       for (typename NodeMaps::iterator it = _node_maps.begin();
  1022     /// Construct a directed graph writer, which writes to the given
  1028     /// Construct a directed graph writer, which writes to the given
  1023     /// output file.
  1029     /// output file.
  1024     GraphWriter(const Graph& graph, const std::string& fn)
  1030     GraphWriter(const Graph& graph, const std::string& fn)
  1025       : _os(new std::ofstream(fn.c_str())), local_os(true), _graph(graph),
  1031       : _os(new std::ofstream(fn.c_str())), local_os(true), _graph(graph),
  1026         _skip_nodes(false), _skip_edges(false) {
  1032         _skip_nodes(false), _skip_edges(false) {
  1027       if (!(*_os)) throw IoError("Cannot write file", fn);
  1033       if (!(*_os)) {
       
  1034         delete _os;
       
  1035         throw IoError("Cannot write file", fn);
       
  1036       }
  1028     }
  1037     }
  1029 
  1038 
  1030     /// \brief Constructor
  1039     /// \brief Constructor
  1031     ///
  1040     ///
  1032     /// Construct a directed graph writer, which writes to the given
  1041     /// Construct a directed graph writer, which writes to the given
  1033     /// output file.
  1042     /// output file.
  1034     GraphWriter(const Graph& graph, const char* fn)
  1043     GraphWriter(const Graph& graph, const char* fn)
  1035       : _os(new std::ofstream(fn)), local_os(true), _graph(graph),
  1044       : _os(new std::ofstream(fn)), local_os(true), _graph(graph),
  1036         _skip_nodes(false), _skip_edges(false) {
  1045         _skip_nodes(false), _skip_edges(false) {
  1037       if (!(*_os)) throw IoError("Cannot write file", fn);
  1046       if (!(*_os)) {
       
  1047         delete _os;
       
  1048         throw IoError("Cannot write file", fn);
       
  1049       }
  1038     }
  1050     }
  1039 
  1051 
  1040     /// \brief Destructor
  1052     /// \brief Destructor
  1041     ~GraphWriter() {
  1053     ~GraphWriter() {
  1042       for (typename NodeMaps::iterator it = _node_maps.begin();
  1054       for (typename NodeMaps::iterator it = _node_maps.begin();
  1585     /// \brief Constructor
  1597     /// \brief Constructor
  1586     ///
  1598     ///
  1587     /// Construct a section writer, which writes into the given file.
  1599     /// Construct a section writer, which writes into the given file.
  1588     SectionWriter(const std::string& fn)
  1600     SectionWriter(const std::string& fn)
  1589       : _os(new std::ofstream(fn.c_str())), local_os(true) {
  1601       : _os(new std::ofstream(fn.c_str())), local_os(true) {
  1590       if (!(*_os)) throw IoError("Cannot write file", fn);
  1602       if (!(*_os)) {
       
  1603         delete _os;
       
  1604         throw IoError("Cannot write file", fn);
       
  1605       }
  1591     }
  1606     }
  1592 
  1607 
  1593     /// \brief Constructor
  1608     /// \brief Constructor
  1594     ///
  1609     ///
  1595     /// Construct a section writer, which writes into the given file.
  1610     /// Construct a section writer, which writes into the given file.
  1596     SectionWriter(const char* fn)
  1611     SectionWriter(const char* fn)
  1597       : _os(new std::ofstream(fn)), local_os(true) {
  1612       : _os(new std::ofstream(fn)), local_os(true) {
  1598       if (!(*_os)) throw IoError("Cannot write file", fn);
  1613       if (!(*_os)) {
       
  1614         delete _os;
       
  1615         throw IoError("Cannot write file", fn);
       
  1616       }
  1599     }
  1617     }
  1600 
  1618 
  1601     /// \brief Destructor
  1619     /// \brief Destructor
  1602     ~SectionWriter() {
  1620     ~SectionWriter() {
  1603       for (Sections::iterator it = _sections.begin();
  1621       for (Sections::iterator it = _sections.begin();