diff --git a/lemon/lgf_reader.h b/lemon/lgf_reader.h --- a/lemon/lgf_reader.h +++ b/lemon/lgf_reader.h @@ -467,7 +467,7 @@ : _is(other._is), local_is(other.local_is), _digraph(other._digraph), _use_nodes(other._use_nodes), _use_arcs(other._use_arcs) { - other.is = 0; + other._is = 0; other.local_is = false; _node_index.swap(other._node_index); @@ -1078,8 +1078,10 @@ /// /// This function starts the batch processing void run() { - LEMON_ASSERT(_is != 0, "This reader assigned to an other reader"); + if (!*_is) { + throw DataFormatError("Cannot find file"); + } bool nodes_done = false; bool arcs_done = false; @@ -1160,20 +1162,23 @@ /// \relates DigraphReader template DigraphReader digraphReader(std::istream& is, Digraph& digraph) { - return DigraphReader(is, digraph); + DigraphReader tmp(is, digraph); + return tmp; } /// \relates DigraphReader template DigraphReader digraphReader(const std::string& fn, Digraph& digraph) { - return DigraphReader(fn, digraph); + DigraphReader tmp(fn, digraph); + return tmp; } /// \relates DigraphReader template DigraphReader digraphReader(const char* fn, Digraph& digraph) { - return DigraphReader(fn, digraph); + DigraphReader tmp(fn, digraph); + return tmp; } } diff --git a/lemon/lgf_writer.h b/lemon/lgf_writer.h --- a/lemon/lgf_writer.h +++ b/lemon/lgf_writer.h @@ -195,7 +195,9 @@ return; default: if (c < 0x20) { + std::ios::fmtflags flags = os.flags(); os << '\\' << std::oct << static_cast(c); + os.flags(flags); } else { os << c; } @@ -243,12 +245,12 @@ /// writer, and eventually the writing is executed with the \c run() /// member function. A map writing rule can be added to the writer /// with the \c nodeMap() or \c arcMap() members. An optional - /// converter parameter can also be added as a standard functor converting from - /// the value type of the map to std::string. If it is set, it will - /// determine how the map's value type is written to the output - /// stream. If the functor is not set, then a default conversion - /// will be used. The \c attribute(), \c node() and \c arc() functions - /// are used to add attribute writing rules. + /// converter parameter can also be added as a standard functor + /// converting from the value type of the map to std::string. If it + /// is set, it will determine how the map's value type is written to + /// the output stream. If the functor is not set, then a default + /// conversion will be used. The \c attribute(), \c node() and \c + /// arc() functions are used to add attribute writing rules. /// ///\code /// DigraphWriter(std::cout, digraph). @@ -269,13 +271,13 @@ /// attributes() functions. /// /// The \c skipNodes() and \c skipArcs() functions forbid the - /// writing of the sections. If two arc sections should be written to the - /// output, it can be done in two passes, the first pass writes the - /// node section and the first arc section, then the second pass - /// skips the node section and writes just the arc section to the - /// stream. The output stream can be retrieved with the \c ostream() - /// function, hence the second pass can append its output to the output of the - /// first pass. + /// writing of the sections. If two arc sections should be written + /// to the output, it can be done in two passes, the first pass + /// writes the node section and the first arc section, then the + /// second pass skips the node section and writes just the arc + /// section to the stream. The output stream can be retrieved with + /// the \c ostream() function, hence the second pass can append its + /// output to the output of the first pass. template class DigraphWriter { public: @@ -349,7 +351,7 @@ : _os(other._os), local_os(other.local_os), _digraph(other._digraph), _skip_nodes(other._skip_nodes), _skip_arcs(other._skip_arcs) { - other.is = 0; + other._os = 0; other.local_os = false; _node_index.swap(other._node_index); @@ -717,21 +719,24 @@ /// \relates DigraphWriter template - DigraphWriter digraphWriter(std::istream& is, Digraph& digraph) { - return DigraphWriter(is, digraph); + DigraphWriter digraphWriter(std::ostream& os, Digraph& digraph) { + DigraphWriter tmp(os, digraph); + return tmp; } /// \relates DigraphWriter template DigraphWriter digraphWriter(const std::string& fn, Digraph& digraph) { - return DigraphWriter(fn, digraph); + DigraphWriter tmp(fn, digraph); + return tmp; } /// \relates DigraphWriter template DigraphWriter digraphWriter(const char* fn, Digraph& digraph) { - return DigraphWriter(fn, digraph); + DigraphWriter tmp(fn, digraph); + return tmp; } }