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 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); |
|
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 Digraph& digraph, const char* fn) |
473 DigraphWriter(const Digraph& digraph, const char* fn) |
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("Cannot write file", fn); |
|
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) { |
1017 /// |
1021 /// |
1018 /// Construct a directed graph writer, which writes to the given |
1022 /// Construct a directed graph writer, which writes to the given |
1019 /// output file. |
1023 /// output file. |
1020 GraphWriter(const Graph& graph, const std::string& fn) |
1024 GraphWriter(const Graph& graph, const std::string& fn) |
1021 : _os(new std::ofstream(fn.c_str())), local_os(true), _graph(graph), |
1025 : _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 } |
1023 |
1029 |
1024 /// \brief Constructor |
1030 /// \brief Constructor |
1025 /// |
1031 /// |
1026 /// Construct a directed graph writer, which writes to the given |
1032 /// Construct a directed graph writer, which writes to the given |
1027 /// output file. |
1033 /// output file. |
1028 GraphWriter(const Graph& graph, const char* fn) |
1034 GraphWriter(const Graph& graph, const char* fn) |
1029 : _os(new std::ofstream(fn)), local_os(true), _graph(graph), |
1035 : _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 } |
1031 |
1039 |
1032 /// \brief Destructor |
1040 /// \brief Destructor |
1033 ~GraphWriter() { |
1041 ~GraphWriter() { |
1034 for (typename NodeMaps::iterator it = _node_maps.begin(); |
1042 for (typename NodeMaps::iterator it = _node_maps.begin(); |
1035 it != _node_maps.end(); ++it) { |
1043 it != _node_maps.end(); ++it) { |
1576 |
1584 |
1577 /// \brief Constructor |
1585 /// \brief Constructor |
1578 /// |
1586 /// |
1579 /// Construct a section writer, which writes into the given file. |
1587 /// Construct a section writer, which writes into the given file. |
1580 SectionWriter(const std::string& fn) |
1588 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 } |
1582 |
1592 |
1583 /// \brief Constructor |
1593 /// \brief Constructor |
1584 /// |
1594 /// |
1585 /// Construct a section writer, which writes into the given file. |
1595 /// Construct a section writer, which writes into the given file. |
1586 SectionWriter(const char* fn) |
1596 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 } |
1588 |
1600 |
1589 /// \brief Destructor |
1601 /// \brief Destructor |
1590 ~SectionWriter() { |
1602 ~SectionWriter() { |
1591 for (Sections::iterator it = _sections.begin(); |
1603 for (Sections::iterator it = _sections.begin(); |
1592 it != _sections.end(); ++it) { |
1604 it != _sections.end(); ++it) { |