# HG changeset patch # User deba # Date 1176995674 0 # Node ID 6e1027a05d738bb713b0077381953dc4ceef91ea # Parent 08b64ae5a564e5d648a8a6be8e3b58692a4a8e12 Allowing 'string' type quoting diff -r 08b64ae5a564 -r 6e1027a05d73 lemon/bits/item_reader.h --- a/lemon/bits/item_reader.h Thu Apr 19 15:12:59 2007 +0000 +++ b/lemon/bits/item_reader.h Thu Apr 19 15:14:34 2007 +0000 @@ -30,6 +30,9 @@ #include #include #include +#include + +#include namespace lemon { @@ -172,9 +175,10 @@ char c; value.clear(); is >> std::ws; - if (!is.get(c) || c != '\"') + if (!is.get(c) || (c != '\"' && c != '\'')) throw DataFormatError("Quoted format error"); - while (is.get(c) && c != '\"') { + char quote = c; + while (is.get(c) && c != quote) { if (escaped && c == '\\') { value += readEscape(is); } else { diff -r 08b64ae5a564 -r 6e1027a05d73 lemon/bits/item_writer.h --- a/lemon/bits/item_writer.h Thu Apr 19 15:12:59 2007 +0000 +++ b/lemon/bits/item_writer.h Thu Apr 19 15:14:34 2007 +0000 @@ -31,6 +31,9 @@ #include #include #include +#include + +#include namespace lemon { @@ -146,13 +149,14 @@ /// /// Constructor for the writer. If the given parameter is true /// the writer creates escape sequences from special characters. - QuotedStringWriter(bool _escaped = true) : escaped(_escaped) {} + QuotedStringWriter(bool _escaped = true, char _quote = '\"') + : escaped(_escaped), quote(_quote) {} /// \brief Writes a quoted string to the given stream. /// /// Writes a quoted string to the given stream. void write(std::ostream& os, const std::string& value) const { - os << "\""; + os << quote; if (escaped) { std::ostringstream ls; for (int i = 0; i < int(value.size()); ++i) { @@ -162,7 +166,7 @@ } else { os << value; } - os << "\""; + os << quote; } private: @@ -213,6 +217,7 @@ } private: bool escaped; + char quote; }; /// \ingroup item_io