Chris@439: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@439: Chris@439: /* Chris@439: Sonic Visualiser Chris@439: An audio file viewer and annotation editor. Chris@439: Centre for Digital Music, Queen Mary, University of London. Chris@439: This file copyright 2008 QMUL. Chris@439: Chris@439: This program is free software; you can redistribute it and/or Chris@439: modify it under the terms of the GNU General Public License as Chris@439: published by the Free Software Foundation; either version 2 of the Chris@439: License, or (at your option) any later version. See the file Chris@439: COPYING included with this distribution for more information. Chris@439: */ Chris@439: Chris@439: #ifndef _SIMPLE_SPARQL_QUERY_H_ Chris@439: #define _SIMPLE_SPARQL_QUERY_H_ Chris@439: Chris@439: #include Chris@439: #include Chris@439: #include Chris@439: Chris@439: class ProgressReporter; Chris@439: Chris@439: class SimpleSPARQLQuery Chris@439: { Chris@439: public: Chris@439: enum ValueType { NoValue, URIValue, LiteralValue, BlankValue }; Chris@439: Chris@439: struct Value { Chris@439: Value() : type(NoValue), value() { } Chris@439: Value(ValueType t, QString v) : type(t), value(v) { } Chris@439: ValueType type; Chris@439: QString value; Chris@439: }; Chris@439: Chris@439: typedef std::map KeyValueMap; Chris@439: typedef std::vector ResultList; Chris@439: Chris@480: SimpleSPARQLQuery(QString fromUri, QString query); Chris@439: ~SimpleSPARQLQuery(); Chris@439: Chris@439: void setProgressReporter(ProgressReporter *reporter); Chris@439: bool wasCancelled() const; Chris@439: Chris@439: ResultList execute(); Chris@439: Chris@439: bool isOK() const; Chris@439: QString getErrorString() const; Chris@439: Chris@440: // Do a query and return the value for the given binding, from the Chris@440: // first result that has a value for it Chris@480: static Value singleResultQuery(QString fromUri, Chris@480: QString query, Chris@480: QString binding); Chris@480: Chris@480: enum ImplementationPreference { Chris@480: UseDirectParser, // rasqal (default because it's simpler if seldom used) Chris@480: UseDatastore // redland Chris@480: }; Chris@480: static void setImplementationPreference(ImplementationPreference); Chris@440: Chris@439: protected: Chris@439: class Impl; Chris@439: Impl *m_impl; Chris@439: }; Chris@439: Chris@439: #endif