lemon/lgf_writer.h
changeset 163 c82fd9568d75
parent 156 e561aa7675de
child 165 b4c336c27a03
     1.1 --- a/lemon/lgf_writer.h	Tue May 27 16:01:20 2008 +0200
     1.2 +++ b/lemon/lgf_writer.h	Sat May 31 12:31:21 2008 +0200
     1.3 @@ -195,7 +195,9 @@
     1.4  	return;
     1.5        default:
     1.6  	if (c < 0x20) {
     1.7 +	  std::ios::fmtflags flags = os.flags();
     1.8  	  os << '\\' << std::oct << static_cast<int>(c);
     1.9 +	  os.flags(flags);
    1.10  	} else {
    1.11  	  os << c;
    1.12  	}
    1.13 @@ -243,12 +245,12 @@
    1.14    /// writer, and eventually the writing is executed with the \c run()
    1.15    /// member function. A map writing rule can be added to the writer
    1.16    /// with the \c nodeMap() or \c arcMap() members. An optional
    1.17 -  /// converter parameter can also be added as a standard functor converting from
    1.18 -  /// the value type of the map to std::string. If it is set, it will
    1.19 -  /// determine how the map's value type is written to the output
    1.20 -  /// stream. If the functor is not set, then a default conversion
    1.21 -  /// will be used. The \c attribute(), \c node() and \c arc() functions
    1.22 -  /// are used to add attribute writing rules.
    1.23 +  /// converter parameter can also be added as a standard functor
    1.24 +  /// converting from the value type of the map to std::string. If it
    1.25 +  /// is set, it will determine how the map's value type is written to
    1.26 +  /// the output stream. If the functor is not set, then a default
    1.27 +  /// conversion will be used. The \c attribute(), \c node() and \c
    1.28 +  /// arc() functions are used to add attribute writing rules.
    1.29    ///
    1.30    ///\code
    1.31    ///     DigraphWriter<Digraph>(std::cout, digraph).
    1.32 @@ -269,13 +271,13 @@
    1.33    /// attributes() functions.
    1.34    ///
    1.35    /// The \c skipNodes() and \c skipArcs() functions forbid the
    1.36 -  /// writing of the sections. If two arc sections should be written to the
    1.37 -  /// output, it can be done in two passes, the first pass writes the
    1.38 -  /// node section and the first arc section, then the second pass
    1.39 -  /// skips the node section and writes just the arc section to the
    1.40 -  /// stream. The output stream can be retrieved with the \c ostream()
    1.41 -  /// function, hence the second pass can append its output to the output of the
    1.42 -  /// first pass.
    1.43 +  /// writing of the sections. If two arc sections should be written
    1.44 +  /// to the output, it can be done in two passes, the first pass
    1.45 +  /// writes the node section and the first arc section, then the
    1.46 +  /// second pass skips the node section and writes just the arc
    1.47 +  /// section to the stream. The output stream can be retrieved with
    1.48 +  /// the \c ostream() function, hence the second pass can append its
    1.49 +  /// output to the output of the first pass.
    1.50    template <typename _Digraph>
    1.51    class DigraphWriter {
    1.52    public:
    1.53 @@ -349,7 +351,7 @@
    1.54        : _os(other._os), local_os(other.local_os), _digraph(other._digraph),
    1.55  	_skip_nodes(other._skip_nodes), _skip_arcs(other._skip_arcs) {
    1.56  
    1.57 -      other.is = 0;
    1.58 +      other._os = 0;
    1.59        other.local_os = false;
    1.60  
    1.61        _node_index.swap(other._node_index);
    1.62 @@ -717,21 +719,24 @@
    1.63  
    1.64    /// \relates DigraphWriter
    1.65    template <typename Digraph>
    1.66 -  DigraphWriter<Digraph> digraphWriter(std::istream& is, Digraph& digraph) {
    1.67 -    return DigraphWriter<Digraph>(is, digraph);
    1.68 +  DigraphWriter<Digraph> digraphWriter(std::ostream& os, Digraph& digraph) {
    1.69 +    DigraphWriter<Digraph> tmp(os, digraph);
    1.70 +    return tmp;
    1.71    }
    1.72  
    1.73    /// \relates DigraphWriter
    1.74    template <typename Digraph>
    1.75    DigraphWriter<Digraph> digraphWriter(const std::string& fn, 
    1.76  				       Digraph& digraph) {
    1.77 -    return DigraphWriter<Digraph>(fn, digraph);
    1.78 +    DigraphWriter<Digraph> tmp(fn, digraph);
    1.79 +    return tmp;
    1.80    }
    1.81  
    1.82    /// \relates DigraphWriter
    1.83    template <typename Digraph>
    1.84    DigraphWriter<Digraph> digraphWriter(const char* fn, Digraph& digraph) {
    1.85 -    return DigraphWriter<Digraph>(fn, digraph);
    1.86 +    DigraphWriter<Digraph> tmp(fn, digraph);
    1.87 +    return tmp;
    1.88    }
    1.89  }
    1.90