From e16206982d074e62956de00eeef611478f01c430 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 19 Aug 2008 18:51:06 +0000 Subject: Preliminary connecting via HTTP in Gtk client. Better handling of overflowed client event receive buffer. Store fixes, complain only once about orphans, don't request an orphan parent over and over. git-svn-id: http://svn.drobilla.net/lad/ingen@1447 a436a847-0d15-0410-975c-d299462d15a1 --- src/libs/serialisation/Parser.cpp | 49 +++++++++++++++++++++++++-------------- src/libs/serialisation/Parser.hpp | 8 +++---- 2 files changed, 36 insertions(+), 21 deletions(-) (limited to 'src/libs/serialisation') diff --git a/src/libs/serialisation/Parser.cpp b/src/libs/serialisation/Parser.cpp index cc8b4e4b..79c69648 100644 --- a/src/libs/serialisation/Parser.cpp +++ b/src/libs/serialisation/Parser.cpp @@ -63,7 +63,7 @@ Parser::parse_document( Ingen::Shared::CommonInterface* target, const Glib::ustring& document_uri, Glib::ustring object_uri, - boost::optional engine_base, + Glib::ustring engine_base, boost::optional symbol, boost::optional data) { @@ -74,7 +74,7 @@ Parser::parse_document( else cout << "Parsing " << object_uri << " from " << document_uri << endl; - return parse(world, target, model, document_uri, object_uri, engine_base, symbol, data);; + return parse(world, target, model, document_uri, engine_base, object_uri, symbol, data);; } @@ -84,8 +84,8 @@ Parser::parse_string( Ingen::Shared::CommonInterface* target, const Glib::ustring& str, const Glib::ustring& base_uri, + Glib::ustring engine_base, boost::optional object_uri, - boost::optional engine_base, boost::optional symbol, boost::optional data) { @@ -96,10 +96,11 @@ Parser::parse_string( else cout << "Parsing all objects found in string (base " << base_uri << ")" << endl; - bool ret = parse(world, target, model, base_uri, object_uri, engine_base, symbol, data); + bool ret = parse(world, target, model, base_uri, engine_base, object_uri, symbol, data); if (ret) { const Glib::ustring subject = Glib::ustring("<") + base_uri + Glib::ustring(">"); - parse_connections(world, target, model, base_uri, subject, (engine_base ? (string)engine_base.get() : "/")); + parse_connections(world, target, model, base_uri, subject, + Path((engine_base == "") ? "/" : engine_base)); } return ret; @@ -112,13 +113,16 @@ Parser::parse( Ingen::Shared::CommonInterface* target, Redland::Model& model, Glib::ustring base_uri, + Glib::ustring engine_base, boost::optional object_uri, - boost::optional engine_base, boost::optional symbol, boost::optional data) { const Redland::Node::Type res = Redland::Node::RESOURCE; Glib::ustring query_str; + if (object_uri && object_uri.get()[0] == '/') + object_uri = object_uri.get().substr(1); + if (object_uri) query_str = Glib::ustring("SELECT DISTINCT ?class WHERE { <") + object_uri.get() + "> a ?class . }"; else @@ -132,8 +136,13 @@ Parser::parse( const Redland::Node in_port_class(*world->rdf_world, res, NS_INGEN "InputPort"); const Redland::Node out_port_class(*world->rdf_world, res, NS_INGEN "OutputPort"); - const Redland::Node subject_uri(*world->rdf_world, res, - (object_uri ? object_uri.get() : "http://example.org")); + string subject_str = ((object_uri && object_uri.get() != "") ? object_uri.get() : base_uri); + if (subject_str[0] == '/') + subject_str = subject_str.substr(1); + if (subject_str == "") + subject_str = base_uri; + + const Redland::Node subject_uri(*world->rdf_world, res, subject_str); bool ret = false; @@ -141,7 +150,9 @@ Parser::parse( const Redland::Node subject = (object_uri ? subject_uri : (*i)["subject"]); const Redland::Node rdf_class = (*i)["class"]; if (!object_uri) { - std::string path_str = "/" + uri_relative_to_base(base_uri, subject.to_c_string()); + std::string path_str = uri_relative_to_base(base_uri, subject.to_c_string()); + if (path_str[0] != '/') + path_str = string("/").append(path_str); if (Path(path_str).parent() != "/") continue; } @@ -150,12 +161,13 @@ Parser::parse( rdf_class == in_port_class || rdf_class == out_port_class) { Raul::Path path("/"); if (base_uri != subject.to_c_string()) { - string path_str = string("/") + (string)uri_relative_to_base( - base_uri, subject.to_c_string()); + string path_str = (string)uri_relative_to_base(base_uri, subject.to_c_string()); + if (path_str[0] != '/') + path_str = string("/").append(path_str); if (Path::is_valid(path_str)) { path = path_str; } else { - cerr << "[Parser] ERROR: Invalid path " << path << endl; + cerr << "[Parser] ERROR: Invalid path '" << path << "'" << endl; continue; } } @@ -164,8 +176,8 @@ Parser::parse( continue; if (rdf_class == patch_class) { - ret = parse_patch(world, target, model, base_uri, subject.to_c_string(), - engine_base.get(), data); + ret = parse_patch(world, target, model, base_uri, engine_base, + subject.to_c_string(), data); if (ret) target->set_variable(path, "ingen:document", Atom(base_uri.c_str())); } else if (rdf_class == node_class) { @@ -193,8 +205,8 @@ Parser::parse_patch( Ingen::Shared::CommonInterface* target, Redland::Model& model, const Glib::ustring& base_uri, - const Glib::ustring& object_uri, Glib::ustring engine_base, + const Glib::ustring& object_uri, boost::optional data=boost::optional()) { std::set created; @@ -222,6 +234,7 @@ Parser::parse_patch( if (results.size() == 0) { cerr << "[Parser] ERROR: No polyphony found!" << endl; + cerr << "Query was:" << endl << query.string() << endl; return false; } @@ -237,10 +250,12 @@ Parser::parse_patch( patch_path = "/"; else if (engine_base[engine_base.length()-1] == '/') patch_path = Path(engine_base + symbol); - else + else if (Path::is_valid(engine_base)) patch_path = (Path)engine_base; + else + cerr << "WARNING: Illegal engine base path '" << engine_base << "', loading patch to root" << endl; - if (patch_path != "/") + //if (patch_path != "/") target->new_patch(patch_path, patch_poly); /* Plugin nodes */ diff --git a/src/libs/serialisation/Parser.hpp b/src/libs/serialisation/Parser.hpp index 2e088f51..7b8a35eb 100644 --- a/src/libs/serialisation/Parser.hpp +++ b/src/libs/serialisation/Parser.hpp @@ -44,8 +44,8 @@ public: Ingen::Shared::World* world, Shared::CommonInterface* target, const Glib::ustring& document_uri, + Glib::ustring engine_base, Glib::ustring object_uri, - boost::optional engine_base=boost::optional(), boost::optional symbol=boost::optional(), boost::optional data=boost::optional()); @@ -54,8 +54,8 @@ public: Shared::CommonInterface* target, const Glib::ustring& str, const Glib::ustring& base_uri, + Glib::ustring engine_base, boost::optional object_uri=boost::optional(), - boost::optional engine_base=boost::optional(), boost::optional symbol=boost::optional(), boost::optional data=boost::optional()); @@ -68,8 +68,8 @@ private: Shared::CommonInterface* target, Redland::Model& model, Glib::ustring base_uri, + Glib::ustring engine_base, boost::optional object_uri=boost::optional(), - boost::optional engine_base=boost::optional(), boost::optional symbol=boost::optional(), boost::optional data=boost::optional()); @@ -78,8 +78,8 @@ private: Ingen::Shared::CommonInterface* target, Redland::Model& model, const Glib::ustring& base_uri, - const Glib::ustring& object_uri, Glib::ustring engine_base, + const Glib::ustring& object_uri, boost::optional data); bool parse_node( -- cgit v1.2.1