annotate rdf/SimpleSPARQLQuery.h @ 480:3ffce691c9bf

* Add Redland datastore support to SimpleSPARQLQuery
author Chris Cannam
date Thu, 13 Nov 2008 14:23:23 +0000
parents 5746c559af15
children a82645e788fc
rev   line source
Chris@439 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@439 2
Chris@439 3 /*
Chris@439 4 Sonic Visualiser
Chris@439 5 An audio file viewer and annotation editor.
Chris@439 6 Centre for Digital Music, Queen Mary, University of London.
Chris@439 7 This file copyright 2008 QMUL.
Chris@439 8
Chris@439 9 This program is free software; you can redistribute it and/or
Chris@439 10 modify it under the terms of the GNU General Public License as
Chris@439 11 published by the Free Software Foundation; either version 2 of the
Chris@439 12 License, or (at your option) any later version. See the file
Chris@439 13 COPYING included with this distribution for more information.
Chris@439 14 */
Chris@439 15
Chris@439 16 #ifndef _SIMPLE_SPARQL_QUERY_H_
Chris@439 17 #define _SIMPLE_SPARQL_QUERY_H_
Chris@439 18
Chris@439 19 #include <QString>
Chris@439 20 #include <map>
Chris@439 21 #include <vector>
Chris@439 22
Chris@439 23 class ProgressReporter;
Chris@439 24
Chris@439 25 class SimpleSPARQLQuery
Chris@439 26 {
Chris@439 27 public:
Chris@439 28 enum ValueType { NoValue, URIValue, LiteralValue, BlankValue };
Chris@439 29
Chris@439 30 struct Value {
Chris@439 31 Value() : type(NoValue), value() { }
Chris@439 32 Value(ValueType t, QString v) : type(t), value(v) { }
Chris@439 33 ValueType type;
Chris@439 34 QString value;
Chris@439 35 };
Chris@439 36
Chris@439 37 typedef std::map<QString, Value> KeyValueMap;
Chris@439 38 typedef std::vector<KeyValueMap> ResultList;
Chris@439 39
Chris@480 40 SimpleSPARQLQuery(QString fromUri, QString query);
Chris@439 41 ~SimpleSPARQLQuery();
Chris@439 42
Chris@439 43 void setProgressReporter(ProgressReporter *reporter);
Chris@439 44 bool wasCancelled() const;
Chris@439 45
Chris@439 46 ResultList execute();
Chris@439 47
Chris@439 48 bool isOK() const;
Chris@439 49 QString getErrorString() const;
Chris@439 50
Chris@440 51 // Do a query and return the value for the given binding, from the
Chris@440 52 // first result that has a value for it
Chris@480 53 static Value singleResultQuery(QString fromUri,
Chris@480 54 QString query,
Chris@480 55 QString binding);
Chris@480 56
Chris@480 57 enum ImplementationPreference {
Chris@480 58 UseDirectParser, // rasqal (default because it's simpler if seldom used)
Chris@480 59 UseDatastore // redland
Chris@480 60 };
Chris@480 61 static void setImplementationPreference(ImplementationPreference);
Chris@440 62
Chris@439 63 protected:
Chris@439 64 class Impl;
Chris@439 65 Impl *m_impl;
Chris@439 66 };
Chris@439 67
Chris@439 68 #endif