Dataquay 0.8
BasicStore.h
Go to the documentation of this file.
1/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2
3/*
4 Dataquay
5
6 A C++/Qt library for simple RDF datastore management.
7 Copyright 2009-2012 Chris Cannam.
8
9 Permission is hereby granted, free of charge, to any person
10 obtaining a copy of this software and associated documentation
11 files (the "Software"), to deal in the Software without
12 restriction, including without limitation the rights to use, copy,
13 modify, merge, publish, distribute, sublicense, and/or sell copies
14 of the Software, and to permit persons to whom the Software is
15 furnished to do so, subject to the following conditions:
16
17 The above copyright notice and this permission notice shall be
18 included in all copies or substantial portions of the Software.
19
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
24 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
25 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27
28 Except as contained in this notice, the name of Chris Cannam
29 shall not be used in advertising or otherwise to promote the sale,
30 use or other dealings in this Software without prior written
31 authorization.
32*/
33
34#ifndef DATAQUAY_BASIC_STORE_H
35#define DATAQUAY_BASIC_STORE_H
36
37#include "Store.h"
38
39namespace Dataquay
40{
41
55class BasicStore : public Store
56{
57public:
60
66 void setBaseUri(Uri uri);
67
71 Uri getBaseUri() const;
72
78 void clear();
79
95 void addPrefix(QString prefix, Uri uri);
96
97 // Store interface
98
99 bool add(Triple t);
100 bool remove(Triple t);
101
102 void change(ChangeSet changes);
103 void revert(ChangeSet changes);
104
105 bool contains(Triple t) const;
107 ResultSet query(QString sparql) const;
108
110
112 Node queryOnce(QString sparql, QString bindingName) const;
113
114 Uri getUniqueUri(QString prefix) const;
116 Uri expand(QString uri) const;
117
118 void save(QString filename) const;
119 void import(QUrl url, ImportDuplicatesMode idm, QString format = "");
120 void importString(QString encodedRdf, Uri baseUri,
121 ImportDuplicatesMode idm, QString format = "");
122
124
141 static BasicStore *load(QUrl url, QString format = "");
142
155 static BasicStore *loadString(QString encodedRdf, Uri baseUri, QString format = "");
156
157private:
158 class D;
159 D *m_d;
160};
161
162}
163
164#endif
165
BasicStore is an in-memory RDF data store implementing the Store interface, providing add,...
Definition BasicStore.h:56
void change(ChangeSet changes)
Atomically apply the sequence of add/remove changes described in the given ChangeSet.
Uri getBaseUri() const
Retrieve the base URI for the store.
void addPrefix(QString prefix, Uri uri)
Add a prefix/uri pair (an XML namespace, except that this class doesn't directly deal in XML) for use...
void save(QString filename) const
Export the store to an RDF/TTL file with the given filename.
Node queryOnce(QString sparql, QString bindingName) const
Run a SPARQL query against the store and return the node of the first result for the given query bind...
void clear()
Empty the store of triples.
Triples match(Triple t) const
Return all triples matching the given wildcard triple.
Node addBlankNode()
Create and return a new blank node.
void setBaseUri(Uri uri)
Set the base URI for the store.
static BasicStore * load(QUrl url, QString format="")
Construct a new BasicStore from the RDF document at the given URL.
Node complete(Triple t) const
Given a triple in which any two nodes are specified and the other is a wildcard node of type Nothing,...
bool remove(Triple t)
Remove a triple from the store.
Uri expand(QString uri) const
Expand the given URI (which may use local namespaces) and prefix-expand it, returning the result as a...
Uri getUniqueUri(QString prefix) const
Get a new URI, starting with the given prefix (e.g.
void importString(QString encodedRdf, Uri baseUri, ImportDuplicatesMode idm, QString format="")
Import the RDF document encoded in the given string into the current store (in addition to its existi...
Features getSupportedFeatures() const
Retrieve the set of optional features supported by this Store implementation.
bool contains(Triple t) const
Return true if the store contains the given triple, false otherwise.
void revert(ChangeSet changes)
Atomically apply the sequence of add/remove changes described in the given ChangeSet,...
ResultSet query(QString sparql) const
Run a SPARQL query against the store and return its results.
static BasicStore * loadString(QString encodedRdf, Uri baseUri, QString format="")
Construct a new BasicStore from the RDF document encoded in the given string.
Triple matchOnce(Triple t) const
Return a triple from the store that matches the given wildcard triple, or the empty triple if none ma...
bool add(Triple t)
Add a triple to the store.
Node represents a single RDF node, with conversions to and from variant types.
Definition Node.h:65
Store is an abstract interface for Dataquay RDF data stores.
Definition Store.h:72
QSet< Feature > Features
Definition Store.h:290
ImportDuplicatesMode
ImportDuplicatesMode determines the outcome when an import operation encounters a triple in the impor...
Definition Store.h:222
Triple represents an RDF statement made up of three Node objects.
Definition Triple.h:48
A list of RDF triples.
Definition Triple.h:111
Uri represents a single URI.
Definition Uri.h:77
QList< Change > ChangeSet
A sequence of add/remove operations such as may be enacted by a transaction.
Definition Store.h:63
QList< Dictionary > ResultSet
A list of Dictionary types, used to contain a sequence of query results.
Definition Store.h:52