lemon/lgf_writer.h
changeset 290 f6899946c1ac
parent 248 8fada33fc60a
child 291 d901321d6555
     1.1 --- a/lemon/lgf_writer.h	Sat Sep 27 14:33:28 2008 +0200
     1.2 +++ b/lemon/lgf_writer.h	Tue Sep 30 20:53:18 2008 +0200
     1.3 @@ -55,7 +55,7 @@
     1.4  
     1.5      template <typename T>
     1.6      bool operator<(const T&, const T&) {
     1.7 -      throw DataFormatError("Label map is not comparable");
     1.8 +      throw FormatError("Label map is not comparable");
     1.9      }
    1.10  
    1.11      template <typename _Map>
    1.12 @@ -203,7 +203,7 @@
    1.13          typename std::map<Value, std::string>::const_iterator it =
    1.14            _map.find(str);
    1.15          if (it == _map.end()) {
    1.16 -          throw DataFormatError("Item not found");
    1.17 +          throw FormatError("Item not found");
    1.18          }
    1.19          return it->second;
    1.20        }
    1.21 @@ -223,7 +223,7 @@
    1.22          typename std::map<typename Graph::Edge, std::string>
    1.23            ::const_iterator it = _map.find(val);
    1.24          if (it == _map.end()) {
    1.25 -          throw DataFormatError("Item not found");
    1.26 +          throw FormatError("Item not found");
    1.27          }
    1.28          return (_graph.direction(val) ? '+' : '-') + it->second;
    1.29        }
    1.30 @@ -462,7 +462,9 @@
    1.31      /// output file.
    1.32      DigraphWriter(const std::string& fn, const Digraph& digraph)
    1.33        : _os(new std::ofstream(fn.c_str())), local_os(true), _digraph(digraph),
    1.34 -        _skip_nodes(false), _skip_arcs(false) {}
    1.35 +        _skip_nodes(false), _skip_arcs(false) {
    1.36 +      if (!(*_os)) throw IoError(fn, "Cannot write file");
    1.37 +    }
    1.38  
    1.39      /// \brief Constructor
    1.40      ///
    1.41 @@ -470,7 +472,9 @@
    1.42      /// output file.
    1.43      DigraphWriter(const char* fn, const Digraph& digraph)
    1.44        : _os(new std::ofstream(fn)), local_os(true), _digraph(digraph),
    1.45 -        _skip_nodes(false), _skip_arcs(false) {}
    1.46 +        _skip_nodes(false), _skip_arcs(false) {
    1.47 +      if (!(*_os)) throw IoError(fn, "Cannot write file");
    1.48 +    }
    1.49  
    1.50      /// \brief Destructor
    1.51      ~DigraphWriter() {
    1.52 @@ -1018,7 +1022,9 @@
    1.53      /// output file.
    1.54      GraphWriter(const std::string& fn, const Graph& graph)
    1.55        : _os(new std::ofstream(fn.c_str())), local_os(true), _graph(graph),
    1.56 -        _skip_nodes(false), _skip_edges(false) {}
    1.57 +        _skip_nodes(false), _skip_edges(false) {
    1.58 +      if (!(*_os)) throw IoError(fn, "Cannot write file");
    1.59 +    }
    1.60  
    1.61      /// \brief Constructor
    1.62      ///
    1.63 @@ -1026,7 +1032,9 @@
    1.64      /// output file.
    1.65      GraphWriter(const char* fn, const Graph& graph)
    1.66        : _os(new std::ofstream(fn)), local_os(true), _graph(graph),
    1.67 -        _skip_nodes(false), _skip_edges(false) {}
    1.68 +        _skip_nodes(false), _skip_edges(false) {
    1.69 +      if (!(*_os)) throw IoError(fn, "Cannot write file");
    1.70 +    }
    1.71  
    1.72      /// \brief Destructor
    1.73      ~GraphWriter() {
    1.74 @@ -1576,13 +1584,17 @@
    1.75      ///
    1.76      /// Construct a section writer, which writes into the given file.
    1.77      SectionWriter(const std::string& fn)
    1.78 -      : _os(new std::ofstream(fn.c_str())), local_os(true) {}
    1.79 +      : _os(new std::ofstream(fn.c_str())), local_os(true) {
    1.80 +      if (!(*_os)) throw IoError(fn, "Cannot write file");
    1.81 +    }
    1.82  
    1.83      /// \brief Constructor
    1.84      ///
    1.85      /// Construct a section writer, which writes into the given file.
    1.86      SectionWriter(const char* fn)
    1.87 -      : _os(new std::ofstream(fn)), local_os(true) {}
    1.88 +      : _os(new std::ofstream(fn)), local_os(true) {
    1.89 +      if (!(*_os)) throw IoError(fn, "Cannot write file");
    1.90 +    }
    1.91  
    1.92      /// \brief Destructor
    1.93      ~SectionWriter() {