summaryrefslogtreecommitdiffstats
path: root/src/serialisation/Parser.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-11-27 02:29:50 +0000
committerDavid Robillard <d@drobilla.net>2008-11-27 02:29:50 +0000
commitdf9fc0187cb4c472190866fe352d42a415464a6b (patch)
treecc14b20751759629668ed5efa816622ce6c77598 /src/serialisation/Parser.cpp
parentca3bd4c24b7db71b774a560dc4089321d74fee4d (diff)
downloadingen-df9fc0187cb4c472190866fe352d42a415464a6b.tar.gz
ingen-df9fc0187cb4c472190866fe352d42a415464a6b.tar.bz2
ingen-df9fc0187cb4c472190866fe352d42a415464a6b.zip
Tolate paths with '.' elements (e.g. ingen -egl ./foo.ingen.ttl).
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@1785 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/serialisation/Parser.cpp')
-rw-r--r--src/serialisation/Parser.cpp30
1 files changed, 20 insertions, 10 deletions
diff --git a/src/serialisation/Parser.cpp b/src/serialisation/Parser.cpp
index e153a9a5..f4e1f40c 100644
--- a/src/serialisation/Parser.cpp
+++ b/src/serialisation/Parser.cpp
@@ -55,6 +55,15 @@ Parser::uri_relative_to_base(Glib::ustring base, const Glib::ustring uri)
}
+static void
+normalise_uri(Glib::ustring& uri)
+{
+ size_t dotslash = string::npos;
+ while ((dotslash = uri.find("./")) != string::npos)
+ uri = uri.substr(0, dotslash) + uri.substr(dotslash + 2);
+}
+
+
/** Parse a patch from RDF into a CommonInterface (engine or client).
* @return whether or not load was successful.
*/
@@ -62,21 +71,22 @@ bool
Parser::parse_document(
Ingen::Shared::World* world,
Ingen::Shared::CommonInterface* target,
- const Glib::ustring& document_uri,
+ Glib::ustring document_uri,
Glib::ustring object_uri,
Glib::ustring engine_base,
boost::optional<Raul::Symbol> symbol,
boost::optional<GraphObject::Variables> data)
{
+ normalise_uri(document_uri);
+ normalise_uri(object_uri);
+ normalise_uri(engine_base);
+
Redland::Model model(*world->rdf_world, document_uri, document_uri);
- if (object_uri == document_uri || object_uri == "") {
- cout << "Parsing " << object_uri << " from " << document_uri << endl;
- cout << "Base: " << engine_base;
- cout << ", Symbol: " << ((bool)symbol ? symbol.get() : "_") << endl;
- } else {
- cout << "Parsing " << object_uri << " from " << document_uri << endl;
- }
+ cout << "[Parser] Parsing " << object_uri << " from " << document_uri << endl;
+ cout << "[Parser] Base: " << engine_base << endl;
+ if (symbol)
+ cout << "[Parser] Symbol: " << symbol.get() << endl;
return parse(world, target, model, document_uri, engine_base, object_uri, symbol, data);;
}
@@ -317,7 +327,7 @@ Parser::parse_patch(
/* Get polyphony from file (mandatory if not specified in parameters) */
if (patch_poly == 0) {
Redland::Query query(*world->rdf_world, Glib::ustring(
- "SELECT DISTINCT ?poly WHERE { ") + subject + " ingen:polyphony ?poly\n }");
+ "SELECT DISTINCT ?poly WHERE { ") + subject + " ingen:polyphony ?poly }");
Redland::Query::Results results = query.run(*world->rdf_world, model, base_uri);
@@ -339,7 +349,7 @@ Parser::parse_patch(
symbol = base_uri.substr(base_uri.find_last_of("/") + 1);
symbol = symbol.substr(0, symbol.find("."));
}
-
+
Path patch_path("/");
if (engine_base == "")
patch_path = "/";