summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-12-02 06:26:33 +0000
committerDavid Robillard <d@drobilla.net>2008-12-02 06:26:33 +0000
commit9fc493e25fe7443c5c45aa0464af62c6f1d391c3 (patch)
tree094b61482d5b47692e44a7de3639461c55380227 /src
parentcb42d2cc4daa09c7d1db5515e39e94b9a5a43447 (diff)
downloadingen-9fc493e25fe7443c5c45aa0464af62c6f1d391c3.tar.gz
ingen-9fc493e25fe7443c5c45aa0464af62c6f1d391c3.tar.bz2
ingen-9fc493e25fe7443c5c45aa0464af62c6f1d391c3.zip
Fix loading nested patches.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@1841 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/serialisation/Parser.cpp37
-rw-r--r--src/serialisation/Parser.hpp2
2 files changed, 20 insertions, 19 deletions
diff --git a/src/serialisation/Parser.cpp b/src/serialisation/Parser.cpp
index bd30abbf..4d81b624 100644
--- a/src/serialisation/Parser.cpp
+++ b/src/serialisation/Parser.cpp
@@ -40,17 +40,20 @@ namespace Serialisation {
#define NS_LV2EV "http://lv2plug.in/ns/ext/event#"
Glib::ustring
-Parser::relative_uri(Glib::ustring base, const Glib::ustring uri)
+Parser::relative_uri(Glib::ustring base, const Glib::ustring uri, bool leading_slash)
{
- //cout << base;
base = base.substr(0, base.find_last_of("/")+1);
- //cout << " # " << uri;
Glib::ustring ret;
if (uri.length() >= base.length() && uri.substr(0, base.length()) == base)
ret = uri.substr(base.length());
else
ret = uri;
- //cout << " = " << ret << endl;
+
+ if (leading_slash && (ret == "" || ret[0] != '/'))
+ ret = "/" + ret;
+ else if (!leading_slash && ret != "" && ret[0] == '/')
+ ret = ret.substr(1);
+
return ret;
}
@@ -240,11 +243,10 @@ Parser::parse(
//cout << "CLASS: " << rdf_class.to_c_string() << endl;
if (!data_path)
- path_str = relative_uri(document_uri, subject.to_c_string());
-
- if (path_str[0] != '/')
+ path_str = relative_uri(document_uri, subject.to_c_string(), true);
+ else if (path_str == "" || path_str[0] != '/')
path_str = "/" + path_str;
-
+
if (!Path::is_valid(path_str)) {
cerr << "WARNING: Invalid path '" << path_str << "', object skipped" << endl;
continue;
@@ -427,25 +429,22 @@ Parser::parse_patch(
results = query.run(*world->rdf_world, model, base_uri);
for (Redland::Query::Results::iterator i = results.begin(); i != results.end(); ++i) {
- cout << "FIXME: SUBPATCH" << endl;
-#if 0
world->rdf_world->mutex().lock();
- const string symbol = (*i)["symbol"].to_string();
- const string subpatch = (*i)["subpatch"].to_string();
+ const string symbol = (*i)["symbol"].to_string();
+ const string subpatch = (*i)["subpatch"].to_string();
world->rdf_world->mutex().unlock();
const Path subpatch_path = patch_path.base() + symbol;
if (created.find(subpatch_path) == created.end()) {
- const string subpatch_rel = relative_uri(base_uri, subpatch);
+ /*const string subpatch_rel = relative_uri(base_uri, subpatch);
string sub_base = engine_base;
if (sub_base[sub_base.length()-1] == '/')
sub_base = sub_base.substr(sub_base.length()-1);
- sub_base.append("/").append(symbol);
+ sub_base.append("/").append(symbol);*/
created.insert(subpatch_path);
- parse_patch(world, target, model, base_uri, subpatch_rel, sub_base);
+ parse_patch(world, target, model, (*i)["subpatch"], patch_path, Symbol(symbol));
}
-#endif
}
@@ -643,16 +642,18 @@ Parser::parse_connections(
const string parent_base = (parent == "/") ? "" : parent.base().substr(1);
const Glib::ustring& base_uri = model.base_uri().to_string();
+
+ const Glib::ustring& base = base_uri.substr(0, base_uri.find_last_of("/") + 1) + parent_base;
Redland::Query::Results results = query.run(*world->rdf_world, model);
for (Redland::Query::Results::iterator i = results.begin(); i != results.end(); ++i) {
- const string src_path = parent.base() + relative_uri(base_uri, (*i)["src"].to_string());
+ const string src_path = parent.base() + relative_uri(base, (*i)["src"].to_string(), false);
if (!Path::is_valid(src_path)) {
cerr << "ERROR: Invalid path in connection: " << src_path << endl;
continue;
}
- const string dst_path = parent.base() + relative_uri(base_uri, (*i)["dst"].to_string());
+ const string dst_path = parent.base() + relative_uri(base, (*i)["dst"].to_string(), false);
if (!Path::is_valid(dst_path)) {
cerr << "ERROR: Invalid path in connection: " << dst_path << endl;
continue;
diff --git a/src/serialisation/Parser.hpp b/src/serialisation/Parser.hpp
index 0d5c4f7e..43e6579f 100644
--- a/src/serialisation/Parser.hpp
+++ b/src/serialisation/Parser.hpp
@@ -71,7 +71,7 @@ public:
private:
- Glib::ustring relative_uri(Glib::ustring base, const Glib::ustring uri);
+ Glib::ustring relative_uri(Glib::ustring base, const Glib::ustring uri, bool leading_slash);
boost::optional<Raul::Path> parse(
Ingen::Shared::World* world,