From 22b17482a552b0966a80c19d94651385357d5701 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 21 Oct 2007 05:27:32 +0000 Subject: Fix patch serialisation to a string. Fix patch uploading. Closes ticket 100. git-svn-id: http://svn.drobilla.net/lad/ingen@892 a436a847-0d15-0410-975c-d299462d15a1 --- src/libs/serialisation/Serialiser.cpp | 21 +++++++++++++++++---- src/libs/serialisation/Serialiser.hpp | 7 +++++-- 2 files changed, 22 insertions(+), 6 deletions(-) (limited to 'src/libs/serialisation') diff --git a/src/libs/serialisation/Serialiser.cpp b/src/libs/serialisation/Serialiser.cpp index e3d33094..223093a0 100644 --- a/src/libs/serialisation/Serialiser.cpp +++ b/src/libs/serialisation/Serialiser.cpp @@ -67,12 +67,25 @@ Serialiser::to_file(SharedPtr object, const string& filename) } + string -Serialiser::to_string(SharedPtr object) +Serialiser::to_string(SharedPtr object, + const string& base_uri, + const GraphObject::Variables& extra_rdf) { _root_object = object; - start_to_string(); + start_to_string(base_uri); serialise(object); + + RDF::Node base_rdf_node(_model->world(), RDF::Node::RESOURCE, base_uri); + for (GraphObject::Variables::const_iterator v = extra_rdf.begin(); v != extra_rdf.end(); ++v) { + if (v->first.find(":") != string::npos) { + _model->add_statement(base_rdf_node, v->first, v->second); + } else { + cerr << "Warning: not serialising extra RDF with key '" << v->first << "'" << endl; + } + } + return finish(); } @@ -100,11 +113,11 @@ Serialiser::start_to_filename(const string& filename) * the desired objects have been serialised. */ void -Serialiser::start_to_string() +Serialiser::start_to_string(const string& base_uri) { setlocale(LC_NUMERIC, "C"); - _base_uri = ""; + _base_uri = base_uri; _model = new RDF::Model(_world); _mode = TO_STRING; } diff --git a/src/libs/serialisation/Serialiser.hpp b/src/libs/serialisation/Serialiser.hpp index 041bbb69..fc15cd1a 100644 --- a/src/libs/serialisation/Serialiser.hpp +++ b/src/libs/serialisation/Serialiser.hpp @@ -57,9 +57,12 @@ public: Serialiser(Raul::RDF::World& world); void to_file(SharedPtr object, const string& filename); - string to_string(SharedPtr object); + + string to_string(SharedPtr object, + const string& base_uri, + const GraphObject::Variables& extra_rdf); - void start_to_string(); + void start_to_string(const string& base_uri); void serialise(SharedPtr object) throw (std::logic_error); void serialise_connection(SharedPtr c) throw (std::logic_error); string finish(); -- cgit v1.2.1