summaryrefslogtreecommitdiffstats
path: root/src/serialisation/Parser.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-11-09 01:32:38 +0000
committerDavid Robillard <d@drobilla.net>2008-11-09 01:32:38 +0000
commit5d1f579900182f283a1c21ad4e59daf7f035e219 (patch)
treee73066002177cf48a31eef91712aa74839dfc555 /src/serialisation/Parser.cpp
parent23bb407a4f0db71eb15cbf8bbb8e82e02088a998 (diff)
downloadingen-5d1f579900182f283a1c21ad4e59daf7f035e219.tar.gz
ingen-5d1f579900182f283a1c21ad4e59daf7f035e219.tar.bz2
ingen-5d1f579900182f283a1c21ad4e59daf7f035e219.zip
Move patch to /patch via HTTP to give a place for RESTful access to other things.
Implement HTTP access to plugins. Work towards client being able to use HTTP to connect. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@1712 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/serialisation/Parser.cpp')
-rw-r--r--src/serialisation/Parser.cpp57
1 files changed, 38 insertions, 19 deletions
diff --git a/src/serialisation/Parser.cpp b/src/serialisation/Parser.cpp
index 3945c379..b9f52652 100644
--- a/src/serialisation/Parser.cpp
+++ b/src/serialisation/Parser.cpp
@@ -42,12 +42,15 @@ namespace Serialisation {
Glib::ustring
Parser::uri_relative_to_base(Glib::ustring base, const Glib::ustring uri)
{
+ //cout << "BASE: " << base << endl;
base = base.substr(0, base.find_last_of("/")+1);
+ //cout << uri << " RELATIVE TO " << base << endl;
Glib::ustring ret;
- if (uri.length() > base.length() && uri.substr(0, base.length()) == base)
+ if (uri.length() >= base.length() && uri.substr(0, base.length()) == base)
ret = uri.substr(base.length());
else
ret = uri;
+ //cout << " => " << ret << endl;
return ret;
}
@@ -126,13 +129,18 @@ Parser::parse(
else
query_str = Glib::ustring("SELECT DISTINCT ?subject ?class WHERE { ?subject a ?class . }");
+ cout << "QUERY: " << query_str << endl;
+
Redland::Query query(*world->rdf_world, query_str);
Redland::Query::Results results = query.run(*world->rdf_world, model, base_uri);
const Redland::Node patch_class(*world->rdf_world, res, NS_INGEN "Patch");
const Redland::Node node_class(*world->rdf_world, res, NS_INGEN "Node");
+ const Redland::Node internal_class(*world->rdf_world, res, NS_INGEN "Internal");
+ const Redland::Node ladspa_class(*world->rdf_world, res, NS_INGEN "LADSPAPlugin");
const Redland::Node in_port_class(*world->rdf_world, res, NS_LV2 "InputPort");
const Redland::Node out_port_class(*world->rdf_world, res, NS_LV2 "OutputPort");
+ const Redland::Node lv2_class(*world->rdf_world, res, NS_LV2 "Plugin");
string subject_str = ((object_uri && object_uri.get() != "") ? object_uri.get() : base_uri);
if (subject_str[0] == '/')
@@ -143,39 +151,43 @@ Parser::parse(
const Redland::Node subject_uri(*world->rdf_world, res, subject_str);
bool ret = false;
+ std::string path_str;
for (Redland::Query::Results::iterator i = results.begin(); i != results.end(); ++i) {
const Redland::Node& subject = (object_uri ? subject_uri : (*i)["subject"]);
const Redland::Node& rdf_class = (*i)["class"];
+ //cout << "SUBJECT: " << subject.to_c_string() << endl;
if (!object_uri) {
- std::string path_str = uri_relative_to_base(base_uri, subject.to_c_string());
+ path_str = uri_relative_to_base(base_uri, subject.to_c_string());
+ //cout << "BASE: " << base_uri.c_str() << endl;
+ //cout << "PATH: " << path_str.c_str() << endl;
if (path_str[0] != '/')
path_str = string("/").append(path_str);
- if (Path(path_str).parent() != "/")
+ if (!Path::is_valid(path_str)) {
+ //cerr << "INVALID PATH: " << path_str << endl;
+ } else if (Path(path_str).parent() != "/") {
continue;
+ }
}
- if (rdf_class == patch_class || rdf_class == node_class ||
- rdf_class == in_port_class || rdf_class == out_port_class) {
- Raul::Path path("/");
- if (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;
- continue;
- }
- }
+ const bool is_plugin = (rdf_class == ladspa_class)
+ || (rdf_class == lv2_class)
+ || (rdf_class == internal_class);
+
+ const bool is_object = (rdf_class == patch_class)
+ || (rdf_class == node_class)
+ || (rdf_class == in_port_class)
+ || (rdf_class == out_port_class);
+
+ if (is_object) {
+ Raul::Path path(path_str == "" ? "/" : path_str);
if (path.parent() != "/")
continue;
if (rdf_class == patch_class) {
ret = parse_patch(world, target, model, base_uri, engine_base,
- subject.to_c_string(), data);
+ path_str, data);
if (ret)
target->set_variable(path, "ingen:document", Atom(base_uri.c_str()));
} else if (rdf_class == node_class) {
@@ -184,11 +196,18 @@ Parser::parse(
} else if (rdf_class == in_port_class || rdf_class == out_port_class) {
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) {
cerr << "Failed to parse object " << object_uri << endl;
return ret;
}
+ } else if (is_plugin) {
+ if (path_str.length() > 0) {
+ const string uri = path_str.substr(1);
+ cout << "PLUGIN: " << uri << endl;
+ } else {
+ cout << "ERROR: Plugin with no URI parsed, ignoring" << endl;
+ }
}
}