From dc8ea0e48d04c77804df9e2bedcaf16a7113cc7f Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 27 Nov 2008 03:50:14 +0000 Subject: Save patch document properly for loaded subpatches too. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@1787 a436a847-0d15-0410-975c-d299462d15a1 --- src/serialisation/Parser.cpp | 49 +++++++++++++++++++++++++------------------- src/serialisation/Parser.hpp | 8 ++++---- 2 files changed, 32 insertions(+), 25 deletions(-) (limited to 'src/serialisation') diff --git a/src/serialisation/Parser.cpp b/src/serialisation/Parser.cpp index 408a3c7d..e11de4e5 100644 --- a/src/serialisation/Parser.cpp +++ b/src/serialisation/Parser.cpp @@ -88,17 +88,19 @@ Parser::parse_document( if (symbol) cout << "[Parser] Symbol: " << symbol.get() << endl; - bool ret = parse(world, target, model, document_uri, engine_base, object_uri, symbol, data); + boost::optional parsed_path + = parse(world, target, model, document_uri, engine_base, object_uri, symbol, data); const string object_path = (document_uri == object_uri) ? "/" : uri_relative_to_base(document_uri, object_uri); - if (Path::is_valid(object_path)) - target->set_variable(object_path, "ingen:document", Atom(document_uri.c_str())); - else + if (parsed_path) { + target->set_variable(*parsed_path, "ingen:document", Atom(document_uri.c_str())); + } else { cerr << "WARNING: " << object_path << " is not a valid path, document URI lost" << endl; + } - return ret; + return parsed_path; } @@ -200,7 +202,7 @@ Parser::parse_update( } -bool +boost::optional Parser::parse( Ingen::Shared::World* world, Ingen::Shared::CommonInterface* target, @@ -240,8 +242,9 @@ Parser::parse( const Redland::Node subject_uri(*world->rdf_world, res, subject_str); - bool ret = false; std::string path_str; + boost::optional ret; + boost::optional root_path; for (Redland::Query::Results::iterator i = results.begin(); i != results.end(); ++i) { const Redland::Node& subject = (object_uri ? subject_uri : (*i)["subject"]); @@ -286,10 +289,14 @@ Parser::parse( ret = parse_port(world, target, model, base_uri, Glib::ustring("<") + subject.to_c_string() + ">", path, data); } else if (rdf_class == ladspa_class || rdf_class == lv2_class || rdf_class == internal_class) - if (ret == false) { + if (!ret) { cerr << "Failed to parse object " << object_uri << endl; - return ret; + return boost::optional(); } + + if (object_uri && subject.to_string() == *object_uri) + root_path = ret; + } else if (is_plugin) { if (path_str.length() > 0) { const string uri = path_str.substr(1); @@ -298,12 +305,12 @@ Parser::parse( } } - - return ret; + + return root_path; } -bool +boost::optional Parser::parse_patch( Ingen::Shared::World* world, Ingen::Shared::CommonInterface* target, @@ -342,7 +349,7 @@ Parser::parse_patch( if (results.size() == 0) { cerr << "[Parser] ERROR: No polyphony found!" << endl; cerr << "Query was:" << endl << query.string() << endl; - return false; + return boost::optional(); } const Redland::Node& poly_node = (*results.begin())["poly"]; @@ -550,11 +557,11 @@ Parser::parse_patch( } } - return true; + return patch_path; } -bool +boost::optional Parser::parse_node( Ingen::Shared::World* world, Ingen::Shared::CommonInterface* target, @@ -572,23 +579,22 @@ Parser::parse_node( if (results.size() == 0) { cerr << "[Parser] ERROR: Node missing mandatory ingen:plugin property" << endl; - return false; + return boost::optional(); } const Redland::Node& plugin_node = (*results.begin())["plug"]; if (plugin_node.type() != Redland::Node::RESOURCE) { cerr << "[Parser] ERROR: node's ingen:plugin property is not a resource" << endl; - return false; + return boost::optional(); } target->new_node(path, world->rdf_world->expand_uri(plugin_node.to_c_string())); parse_variables(world, target, model, base_uri, subject, path, data); - - return true; + return path; } -bool +boost::optional Parser::parse_port( Ingen::Shared::World* world, Ingen::Shared::CommonInterface* target, @@ -623,7 +629,8 @@ Parser::parse_port( } world->rdf_world->mutex().unlock(); - return parse_variables(world, target, model, base_uri, subject, path, data); + parse_variables(world, target, model, base_uri, subject, path, data); + return path; } diff --git a/src/serialisation/Parser.hpp b/src/serialisation/Parser.hpp index b2d8d7e7..a5db7c0d 100644 --- a/src/serialisation/Parser.hpp +++ b/src/serialisation/Parser.hpp @@ -73,7 +73,7 @@ private: Glib::ustring uri_relative_to_base(Glib::ustring base, const Glib::ustring uri); - bool parse( + boost::optional parse( Ingen::Shared::World* world, Shared::CommonInterface* target, Redland::Model& model, @@ -83,7 +83,7 @@ private: boost::optional symbol=boost::optional(), boost::optional data=boost::optional()); - bool parse_patch( + boost::optional parse_patch( Ingen::Shared::World* world, Ingen::Shared::CommonInterface* target, Redland::Model& model, @@ -92,7 +92,7 @@ private: const Glib::ustring& object_uri, boost::optional data); - bool parse_node( + boost::optional parse_node( Ingen::Shared::World* world, Ingen::Shared::CommonInterface* target, Redland::Model& model, @@ -101,7 +101,7 @@ private: const Raul::Path& path, boost::optional data); - bool parse_port( + boost::optional parse_port( Ingen::Shared::World* world, Ingen::Shared::CommonInterface* target, Redland::Model& model, -- cgit v1.2.1