From e9c7107df9dd2001498cae65aa6ad898fbf7d2f7 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 30 Nov 2007 07:38:42 +0000 Subject: Split redland C++ wrappers out from Raul. git-svn-id: http://svn.drobilla.net/lad/raul@927 a436a847-0d15-0410-975c-d299462d15a1 --- src/RDFWorld.cpp | 104 ------------------------------------------------------- 1 file changed, 104 deletions(-) delete mode 100644 src/RDFWorld.cpp (limited to 'src/RDFWorld.cpp') diff --git a/src/RDFWorld.cpp b/src/RDFWorld.cpp deleted file mode 100644 index 5420274..0000000 --- a/src/RDFWorld.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/* This file is part of Raul. - * Copyright (C) 2007 Dave Robillard - * - * 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 -#include -#include -#include - -#define U(x) ((const unsigned char*)(x)) - -using namespace std; - -namespace Raul { -namespace RDF { - - -//static const char* const RDF_LANG = "rdfxml-abbrev"; -static const char* const RDF_LANG = "turtle"; - - -/** Create an empty in-memory RDF model. - */ -World::World() - : _next_blank_id(1) -{ - _world = librdf_new_world(); - assert(_world); - librdf_world_open(_world); - - add_prefix("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#"); -} - - -World::~World() -{ - Glib::Mutex::Lock lock(_mutex); - librdf_free_world(_world); -} - - -void -World::add_prefix(const string& prefix, const string& uri) -{ - _prefixes[prefix] = uri; -} - - -/** Expands the prefix of URI, if the prefix is registered. - */ -string -World::expand_uri(const string& uri) const -{ - if (uri.find(":") == string::npos) - return uri; - - for (Namespaces::const_iterator i = _prefixes.begin(); i != _prefixes.end(); ++i) - if (uri.substr(0, i->first.length()+1) == i->first + ":") - return i->second + uri.substr(i->first.length()+1); - - return uri; -} - - -/** Opposite of expand_uri - */ -string -World::qualify(const string& uri) const -{ - return _prefixes.qualify(uri); -} - - -Node -World::blank_id(const string base_name) -{ - std::ostringstream ss; - ss << "b" << _next_blank_id++; - - if (base_name != "") - ss << "_" << base_name; - - Node result = Node(*this, Node::BLANK, ss.str()); - assert(result.to_string() == ss.str()); - return result; -} - - -} // namespace RDF -} // namespace Raul - -- cgit v1.2.1