diff options
author | David Robillard <d@drobilla.net> | 2007-11-30 07:38:42 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2007-11-30 07:38:42 +0000 |
commit | e9c7107df9dd2001498cae65aa6ad898fbf7d2f7 (patch) | |
tree | 3f0d33555a7bc18a544b19aab99b9a4504446c92 /src/RDFQuery.cpp | |
parent | 9988890730832ebd0a5f5a64a74eb0a2e65c1de4 (diff) | |
download | raul-e9c7107df9dd2001498cae65aa6ad898fbf7d2f7.tar.gz raul-e9c7107df9dd2001498cae65aa6ad898fbf7d2f7.tar.bz2 raul-e9c7107df9dd2001498cae65aa6ad898fbf7d2f7.zip |
Split redland C++ wrappers out from Raul.
git-svn-id: http://svn.drobilla.net/lad/raul@927 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/RDFQuery.cpp')
-rw-r--r-- | src/RDFQuery.cpp | 89 |
1 files changed, 0 insertions, 89 deletions
diff --git a/src/RDFQuery.cpp b/src/RDFQuery.cpp deleted file mode 100644 index 41aa918..0000000 --- a/src/RDFQuery.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/* This file is part of Raul. - * Copyright (C) 2007 Dave Robillard <http://drobilla.net> - * - * Raul 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. - * - * Raul 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.hpp> -#include <raul/RDFModel.hpp> - -using namespace std; - -namespace Raul { -namespace RDF { - - -Query::Results -Query::run(World& world, Model& model, const Glib::ustring base_uri_str) const -{ - Glib::Mutex::Lock lock(world.mutex()); - - //cout << "\n**************** QUERY *******************\n"; - //cout << _query << endl; - //cout << "******************************************\n\n"; - - Results result; - - librdf_uri* base_uri = NULL; - if (base_uri_str != "") - base_uri = librdf_new_uri(world.world(), - (const unsigned char*)base_uri_str.c_str()); - - librdf_query* q = librdf_new_query(world.world(), "sparql", - NULL, (unsigned char*)_query.c_str(), base_uri); - - if (!q) { - cerr << "Unable to create query:" << endl << _query << endl; - return result; /* Return an empty Results */ - } - - librdf_query_results* results = librdf_query_execute(q, model._model); - - if (!results) { - cerr << "Failed query:" << endl << _query << endl; - return result; /* Return an empty Results */ - } - - while (!librdf_query_results_finished(results)) { - - Bindings bindings; - - for (int i=0; i < librdf_query_results_get_bindings_count(results); i++) { - const char* name = (char*)librdf_query_results_get_binding_name(results, i); - librdf_node* value = librdf_query_results_get_binding_value(results, i); - - if (name && value) - bindings.insert(std::make_pair(std::string(name), Node(world, value))); - } - - result.push_back(bindings); - librdf_query_results_next(results); - } - - librdf_free_query_results(results); - librdf_free_query(q); - - if (base_uri) - librdf_free_uri(base_uri); - - return result; -} - - -} // namespace RDF -} // namespace Raul - |