From 44af7b7b66e2083819103c760ab3bf4980469f86 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 3 Aug 2015 01:47:24 +0000 Subject: Optional quoting for atom to string. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@5702 a436a847-0d15-0410-975c-d299462d15a1 --- ingen/Forge.hpp | 2 +- src/Forge.cpp | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/ingen/Forge.hpp b/ingen/Forge.hpp index a5b7bd5e..83a94319 100644 --- a/ingen/Forge.hpp +++ b/ingen/Forge.hpp @@ -34,7 +34,7 @@ class INGEN_API Forge : public LV2_Atom_Forge { public: explicit Forge(URIMap& map); - std::string str(const Atom& atom); + std::string str(const Atom& atom, bool quoted=true); Atom make() { return Atom(); } Atom make(int32_t v) { return Atom(sizeof(v), Int, &v); } diff --git a/src/Forge.cpp b/src/Forge.cpp index de6fcf00..89c194f9 100644 --- a/src/Forge.cpp +++ b/src/Forge.cpp @@ -29,7 +29,7 @@ Forge::Forge(URIMap& map) } std::string -Forge::str(const Atom& atom) +Forge::str(const Atom& atom, bool quoted) { std::ostringstream ss; if (atom.type() == Int) { @@ -39,11 +39,17 @@ Forge::str(const Atom& atom) } else if (atom.type() == Bool) { ss << (atom.get() ? "true" : "false"); } else if (atom.type() == URI) { - ss << "<" << atom.ptr() << ">"; + ss << (quoted ? "<" : "") + << atom.ptr() + << (quoted ? ">" : ""); } else if (atom.type() == URID) { - ss << "<" << _map.unmap_uri(atom.get()) << ">"; + ss << (quoted ? "<" : "") + << _map.unmap_uri(atom.get()) + << (quoted ? ">" : ""); } else if (atom.type() == String) { - ss << "\"" << atom.ptr() << "\""; + ss << (quoted ? "\"" : "") + << atom.ptr() + << (quoted ? "\"" : ""); } return ss.str(); } -- cgit v1.2.1