summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/import.cc4
-rw-r--r--src/linearextrude.cc4
-rw-r--r--src/rotateextrude.cc4
-rw-r--r--src/surface.cc4
-rw-r--r--src/value.cc26
-rw-r--r--src/value.h16
6 files changed, 45 insertions, 13 deletions
diff --git a/src/import.cc b/src/import.cc
index 230cab2..b77c120 100644
--- a/src/import.cc
+++ b/src/import.cc
@@ -228,8 +228,8 @@ std::string ImportNode::toString() const
std::stringstream stream;
stream << this->name();
- stream << "(file = \"" << this->filename << "\", "
- "layer = \"" << this->layername << "\", "
+ stream << "(file = " << this->filename << ", "
+ "layer = " << QuotedString(this->layername) << ", "
"origin = [" << std::dec << this->origin_x << ", " << this->origin_y << "], "
"scale = " << this->scale << ", "
"convexity = " << this->convexity << ", "
diff --git a/src/linearextrude.cc b/src/linearextrude.cc
index 3d91ac4..bc11629 100644
--- a/src/linearextrude.cc
+++ b/src/linearextrude.cc
@@ -137,8 +137,8 @@ std::string LinearExtrudeNode::toString() const
stream << this->name() << "(";
if (!this->filename.empty()) { // Ignore deprecated parameters if empty
stream <<
- "file = \"" << this->filename << "\", "
- "layer = \"" << this->layername << "\", "
+ "file = " << this->filename << ", "
+ "layer = " << QuotedString(this->layername) << ", "
"origin = [" << this->origin_x << ", " << this->origin_y << "], "
"scale = " << this->scale << ", ";
}
diff --git a/src/rotateextrude.cc b/src/rotateextrude.cc
index e64f6f1..4e2db9e 100644
--- a/src/rotateextrude.cc
+++ b/src/rotateextrude.cc
@@ -115,8 +115,8 @@ std::string RotateExtrudeNode::toString() const
stream << this->name() << "(";
if (!this->filename.empty()) { // Ignore deprecated parameters if empty
stream <<
- "file = \"" << this->filename << "\", "
- "layer = \"" << this->layername << "\", "
+ "file = " << this->filename << ", "
+ "layer = " << QuotedString(this->layername) << ", "
"origin = [" << std::dec << this->origin_x << ", " << this->origin_y << "], "
"scale = " << this->scale << ", ";
}
diff --git a/src/surface.cc b/src/surface.cc
index ec5d790..1a5f9bd 100644
--- a/src/surface.cc
+++ b/src/surface.cc
@@ -209,8 +209,8 @@ std::string SurfaceNode::toString() const
{
std::stringstream stream;
- stream << this->name() << "(file = \"" << this->filename
- << "\", center = " << (this->center ? "true" : "false") << ")";
+ stream << this->name() << "(file = " << this->filename << ", "
+ "center = " << (this->center ? "true" : "false") << ")";
return stream.str();
}
diff --git a/src/value.cc b/src/value.cc
index 0b7cd9b..e08b2d8 100644
--- a/src/value.cc
+++ b/src/value.cc
@@ -29,6 +29,7 @@
#include <assert.h>
#include <sstream>
#include <QDir>
+#include <boost/foreach.hpp>
Value::Value()
{
@@ -416,7 +417,30 @@ std::ostream &operator<<(std::ostream &stream, const Value &value)
std::ostream &operator<<(std::ostream &stream, const Filename &filename)
{
- stream << QDir::current().relativeFilePath(QString::fromStdString(filename)).toStdString();
+ stream << QuotedString(QDir::current().relativeFilePath(QString::fromStdString(filename)).toStdString());
return stream;
}
+std::ostream &operator<<(std::ostream &stream, const QuotedString &s)
+{
+ stream << '"';
+ BOOST_FOREACH(char c, s) {
+ switch (c) {
+ case '\t':
+ stream << "\\t";
+ break;
+ case '\n':
+ stream << "\\n";
+ break;
+ case '"':
+ case '\\':
+ stream << '\\';
+ stream << c;
+ break;
+ default:
+ stream << c;
+ }
+ }
+ stream << '"';
+ return stream;
+}
diff --git a/src/value.h b/src/value.h
index f81d28e..a2cfbdf 100644
--- a/src/value.h
+++ b/src/value.h
@@ -4,12 +4,21 @@
#include <vector>
#include <string>
-class Filename : public std::string
+class QuotedString : public std::string
{
public:
- Filename() : std::string() {}
- Filename(const std::string &f) : std::string(f) {}
+ QuotedString() : std::string() {}
+ QuotedString(const std::string &s) : std::string(s) {}
};
+std::ostream &operator<<(std::ostream &stream, const QuotedString &s);
+
+class Filename : public QuotedString
+{
+public:
+ Filename() : QuotedString() {}
+ Filename(const std::string &f) : QuotedString(f) {}
+};
+std::ostream &operator<<(std::ostream &stream, const Filename &filename);
class Value
{
@@ -77,6 +86,5 @@ private:
};
std::ostream &operator<<(std::ostream &stream, const Value &value);
-std::ostream &operator<<(std::ostream &stream, const Filename &filename);
#endif
contact: Jan Huwald // Impressum