[Lemon-commits] deba: r3263 - lemon/trunk/lemon/bits
Lemon SVN
svn at lemon.cs.elte.hu
Thu Apr 19 17:14:35 CEST 2007
Author: deba
Date: Thu Apr 19 17:14:34 2007
New Revision: 3263
Modified:
lemon/trunk/lemon/bits/item_reader.h
lemon/trunk/lemon/bits/item_writer.h
Log:
Allowing 'string' type quoting
Modified: lemon/trunk/lemon/bits/item_reader.h
==============================================================================
--- lemon/trunk/lemon/bits/item_reader.h (original)
+++ lemon/trunk/lemon/bits/item_reader.h Thu Apr 19 17:14:34 2007
@@ -30,6 +30,9 @@
#include <deque>
#include <list>
#include <set>
+#include <map>
+
+#include <lemon/error.h>
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 {
Modified: lemon/trunk/lemon/bits/item_writer.h
==============================================================================
--- lemon/trunk/lemon/bits/item_writer.h (original)
+++ lemon/trunk/lemon/bits/item_writer.h Thu Apr 19 17:14:34 2007
@@ -31,6 +31,9 @@
#include <deque>
#include <list>
#include <set>
+#include <map>
+
+#include <lemon/error.h>
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
More information about the Lemon-commits
mailing list