diff -r aa7428d22aaf -r 43c7b3085212 lemon/bits/item_writer.h --- a/lemon/bits/item_writer.h Mon Jul 04 15:03:25 2005 +0000 +++ b/lemon/bits/item_writer.h Mon Jul 04 16:11:00 2005 +0000 @@ -56,7 +56,7 @@ void write(std::ostream& os, const std::string& value) { os << "\""; if (escaped) { - std::ostringstream ls; + std::ostringstream ls(value); for (int i = 0; i < (int)value.size(); ++i) { writeEscape(ls, value[i]); } @@ -118,6 +118,34 @@ }; /// \ingroup item_io + /// \brief Writer class for quoted char array. + /// + /// Writer class for quoted char array. It can process the escape + /// sequences in the char array. + /// \author Balazs Dezso + class QuotedCharArrayWriter { + public: + typedef const char* Value; + + /// \brief Constructor for the writer. + /// + /// Constructor for the writer. If the given parameter is true + /// the writer creates escape sequences from special characters. + QuotedCharArrayWriter(bool _escaped = true) : escaped(_escaped) {} + + /// \brief Writes a quoted char array to the given stream. + /// + /// Writes a quoted char array to the given stream. + void write(std::ostream& os, const char* value) { + QuotedStringWriter(escaped).write(os, std::string(value)); + } + + private: + bool escaped; + }; + + + /// \ingroup item_io /// /// \brief Writer for standard containers. /// @@ -181,6 +209,14 @@ class DefaultWriter : public QuotedStringWriter {}; + template + class DefaultWriter + : public QuotedCharArrayWriter {}; + + template + class DefaultWriter + : public QuotedCharArrayWriter {}; + template class DefaultWriter > : public IterableWriter > {}; @@ -210,7 +246,9 @@ struct DefaultWriterTraits { template - struct Writer : DefaultWriter<_Value> {}; + struct Writer : DefaultWriter<_Value> { + typedef DefaultWriter<_Value> Parent; + }; };