summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/JackDriver.cpp4
-rw-r--r--src/Makefile.am18
-rw-r--r--src/Namespaces.cpp37
-rw-r--r--src/RDFQuery.cpp71
4 files changed, 122 insertions, 8 deletions
diff --git a/src/JackDriver.cpp b/src/JackDriver.cpp
index 0bbc24b..cd96ab7 100644
--- a/src/JackDriver.cpp
+++ b/src/JackDriver.cpp
@@ -97,9 +97,9 @@ JackDriver::detach()
void
-JackDriver::jack_port_registration_cb(jack_port_id_t port_id, int registered, void* jack_driver)
+JackDriver::jack_port_registration_cb(jack_port_id_t /*port_id*/, int /*registered*/, void* /*jack_driver*/)
{
- /* shrug. */
+ /* whatever. */
}
diff --git a/src/Makefile.am b/src/Makefile.am
index d0cef87..1e9f60d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,16 +1,22 @@
-AM_CXXFLAGS = -I$(top_srcdir)
+AM_CXXFLAGS = -I$(top_srcdir) @RAPTOR_CFLAGS@ @RASQAL_CFLAGS@ @GLIBMM_CFLAGS@ @JACK_CFLAGS@
-libraul_la_CFLAGS = @RAPTOR_CFLAGS@
-libraul_la_LIBADD = @RAPTOR_LIBS@
+libraul_la_LIBADD = @RAPTOR_LIBS@ @RASQAL_LIBS@ @GLIBMM_LIBS@ @JACK_LIBS@
lib_LTLIBRARIES = libraul.la
libraul_la_SOURCES = \
Thread.cpp \
Path.cpp \
- RDFWriter.cpp \
- JackDriver.cpp \
- RDFQuery.cpp \
Namespaces.cpp
+if WITH_RAPTOR
+libraul_la_SOURCES += RDFWriter.cpp
+endif
+if WITH_RASQAL
+libraul_la_SOURCES += RDFQuery.cpp
+endif
+
+if WITH_JACK
+libraul_la_SOURCES += JackDriver.cpp
+endif
diff --git a/src/Namespaces.cpp b/src/Namespaces.cpp
new file mode 100644
index 0000000..d45d259
--- /dev/null
+++ b/src/Namespaces.cpp
@@ -0,0 +1,37 @@
+/* This file is part of Ingen. Copyright (C) 2006 Dave Robillard.
+ *
+ * Ingen is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "raul/Namespaces.h"
+
+
+/** Create a prefixed qname from @a uri, if possible.
+ *
+ * If @a uri can not be qualified with the namespaces currently in this
+ * Namespaces, @a uri will be returned unmodified.
+ */
+std::string
+Namespaces::qualify(std::string uri)
+{
+ for (iterator i = begin(); i != end(); ++i) {
+ size_t ns_len = i->second.length();
+
+ if (uri.substr(0, ns_len) == i->second)
+ return i->first + ":" + uri.substr(ns_len);
+ }
+
+ return uri;
+}
+
diff --git a/src/RDFQuery.cpp b/src/RDFQuery.cpp
new file mode 100644
index 0000000..f92ca89
--- /dev/null
+++ b/src/RDFQuery.cpp
@@ -0,0 +1,71 @@
+/* This file is part of Ingen. Copyright (C) 2006 Dave Robillard.
+ *
+ * Ingen is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <iostream>
+#include <cassert>
+#include <rasqal.h>
+#include "raul/RDFQuery.h"
+
+
+RDFQuery::Results
+RDFQuery::run(const Glib::ustring base_uri_str) const
+{
+ Results result;
+
+ rasqal_init();
+
+ rasqal_query *rq = rasqal_new_query("sparql", NULL);
+
+ raptor_uri* base_uri = NULL;
+ if (base_uri_str != "")
+ base_uri = raptor_new_uri((const unsigned char*)base_uri_str.c_str());
+ rasqal_query_prepare(rq, (unsigned char*)_query.c_str(), base_uri);
+
+ rasqal_query_results* results = rasqal_query_execute(rq);
+ assert(results);
+
+ while (!rasqal_query_results_finished(results)) {
+
+ Bindings bindings;
+
+ for (int i=0; i < rasqal_query_results_get_bindings_count(results); i++) {
+ const unsigned char* rname = rasqal_query_results_get_binding_name(results, i);
+ rasqal_literal* rvalue = rasqal_query_results_get_binding_value(results, i);
+ Glib::ustring name((const char*)rname);
+
+ const unsigned char* str = rasqal_literal_as_string(rvalue);
+
+ if (str) {
+ Glib::ustring value((const char*)str);
+ bindings.insert(std::make_pair(name, value));
+ }
+ }
+
+ result.push_back(bindings);
+ rasqal_query_results_next(results);
+ }
+
+ rasqal_free_query_results(results);
+ rasqal_free_query(rq);
+
+ if (base_uri)
+ raptor_free_uri(base_uri);
+
+ rasqal_finish();
+
+ return result;
+}
+