221 |
221 |
222 std::string operator()(const typename Graph::Arc& val) { |
222 std::string operator()(const typename Graph::Arc& val) { |
223 typename std::map<typename Graph::Edge, std::string> |
223 typename std::map<typename Graph::Edge, std::string> |
224 ::const_iterator it = _map.find(val); |
224 ::const_iterator it = _map.find(val); |
225 if (it == _map.end()) { |
225 if (it == _map.end()) { |
226 throw DataFormatError("Item not found"); |
226 throw FormatError("Item not found"); |
227 } |
227 } |
228 return (_graph.direction(val) ? '+' : '-') + it->second; |
228 return (_graph.direction(val) ? '+' : '-') + it->second; |
229 } |
229 } |
230 }; |
230 }; |
231 |
231 |
460 /// |
460 /// |
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 std::string& fn, const Digraph& digraph) |
463 DigraphWriter(const std::string& fn, const Digraph& digraph) |
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(fn, "Cannot write file"); |
|
467 } |
466 |
468 |
467 /// \brief Constructor |
469 /// \brief Constructor |
468 /// |
470 /// |
469 /// Construct a directed graph writer, which writes to the given |
471 /// Construct a directed graph writer, which writes to the given |
470 /// output file. |
472 /// output file. |
471 DigraphWriter(const char* fn, const Digraph& digraph) |
473 DigraphWriter(const char* fn, const Digraph& digraph) |
472 : _os(new std::ofstream(fn)), local_os(true), _digraph(digraph), |
474 : _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(fn, "Cannot write file"); |
|
477 } |
474 |
478 |
475 /// \brief Destructor |
479 /// \brief Destructor |
476 ~DigraphWriter() { |
480 ~DigraphWriter() { |
477 for (typename NodeMaps::iterator it = _node_maps.begin(); |
481 for (typename NodeMaps::iterator it = _node_maps.begin(); |
478 it != _node_maps.end(); ++it) { |
482 it != _node_maps.end(); ++it) { |
1016 /// |
1020 /// |
1017 /// Construct a directed graph writer, which writes to the given |
1021 /// Construct a directed graph writer, which writes to the given |
1018 /// output file. |
1022 /// output file. |
1019 GraphWriter(const std::string& fn, const Graph& graph) |
1023 GraphWriter(const std::string& fn, const Graph& graph) |
1020 : _os(new std::ofstream(fn.c_str())), local_os(true), _graph(graph), |
1024 : _os(new std::ofstream(fn.c_str())), local_os(true), _graph(graph), |
1021 _skip_nodes(false), _skip_edges(false) {} |
1025 _skip_nodes(false), _skip_edges(false) { |
|
1026 if (!(*_os)) throw IoError(fn, "Cannot write file"); |
|
1027 } |
1022 |
1028 |
1023 /// \brief Constructor |
1029 /// \brief Constructor |
1024 /// |
1030 /// |
1025 /// Construct a directed graph writer, which writes to the given |
1031 /// Construct a directed graph writer, which writes to the given |
1026 /// output file. |
1032 /// output file. |
1027 GraphWriter(const char* fn, const Graph& graph) |
1033 GraphWriter(const char* fn, const Graph& graph) |
1028 : _os(new std::ofstream(fn)), local_os(true), _graph(graph), |
1034 : _os(new std::ofstream(fn)), local_os(true), _graph(graph), |
1029 _skip_nodes(false), _skip_edges(false) {} |
1035 _skip_nodes(false), _skip_edges(false) { |
|
1036 if (!(*_os)) throw IoError(fn, "Cannot write file"); |
|
1037 } |
1030 |
1038 |
1031 /// \brief Destructor |
1039 /// \brief Destructor |
1032 ~GraphWriter() { |
1040 ~GraphWriter() { |
1033 for (typename NodeMaps::iterator it = _node_maps.begin(); |
1041 for (typename NodeMaps::iterator it = _node_maps.begin(); |
1034 it != _node_maps.end(); ++it) { |
1042 it != _node_maps.end(); ++it) { |
1574 |
1582 |
1575 /// \brief Constructor |
1583 /// \brief Constructor |
1576 /// |
1584 /// |
1577 /// Construct a section writer, which writes into the given file. |
1585 /// Construct a section writer, which writes into the given file. |
1578 SectionWriter(const std::string& fn) |
1586 SectionWriter(const std::string& fn) |
1579 : _os(new std::ofstream(fn.c_str())), local_os(true) {} |
1587 : _os(new std::ofstream(fn.c_str())), local_os(true) { |
|
1588 if (!(*_os)) throw IoError(fn, "Cannot write file"); |
|
1589 } |
1580 |
1590 |
1581 /// \brief Constructor |
1591 /// \brief Constructor |
1582 /// |
1592 /// |
1583 /// Construct a section writer, which writes into the given file. |
1593 /// Construct a section writer, which writes into the given file. |
1584 SectionWriter(const char* fn) |
1594 SectionWriter(const char* fn) |
1585 : _os(new std::ofstream(fn)), local_os(true) {} |
1595 : _os(new std::ofstream(fn)), local_os(true) { |
|
1596 if (!(*_os)) throw IoError(fn, "Cannot write file"); |
|
1597 } |
1586 |
1598 |
1587 /// \brief Destructor |
1599 /// \brief Destructor |
1588 ~SectionWriter() { |
1600 ~SectionWriter() { |
1589 for (Sections::iterator it = _sections.begin(); |
1601 for (Sections::iterator it = _sections.begin(); |
1590 it != _sections.end(); ++it) { |
1602 it != _sections.end(); ++it) { |