QtSparql  0.2.6
qsparqlresult.h
1 /***************************************************************************/
45 #ifndef QSPARQLRESULT_H
46 #define QSPARQLRESULT_H
47 
48 #include <qsparqlresultrow.h>
49 #include <qsparqlquery.h>
50 
51 #include <QtCore/qvariant.h>
52 #include <QtCore/qobject.h>
53 
54 QT_BEGIN_HEADER
55 
56 QT_BEGIN_NAMESPACE
57 
58 QT_MODULE(Sparql)
59 
60 class QString;
61 class QSparqlError;
62 class QSparqlResultPrivate;
63 
64 class Q_SPARQL_EXPORT QSparqlResult : public QObject
65 {
66  Q_OBJECT
67  friend class QSparqlResultPrivate;
68  friend class QSparqlConnection;
69  friend class QSparqlConnectionPrivate;
70 
71 public:
72  enum Feature { QuerySize, ForwardOnly, Sync } ;
73  virtual ~QSparqlResult();
74 
75  // Iterating through the result set
76  int pos() const;
77  virtual bool setPos(int pos);
78  virtual bool next();
79  virtual bool previous();
80  virtual bool first();
81  virtual bool last();
82  virtual int size() const;
83  bool isValid() const; // valid = positioned on a valid row
84  // TODO: decide what should be the pos() of the result when the data has
85  // arrived; options: 1) pos() == BeforeFirstRow (like now), 2) pos() == 0
86  // (the first row), but what if there's no data? pos() == AfterLastRow ?
87 
88  // Retrieving data
89  virtual QSparqlResultRow current() const = 0;
90  // Values from the current row
91  virtual QSparqlBinding binding(int i) const = 0;
92  virtual QVariant value(int i) const = 0;
93  virtual QString stringValue(int i) const;
94 
95  // For ASK results
96  bool boolValue() const;
97 
98  // Asynchronous operations
99  virtual void waitForFinished();
100  virtual bool isFinished() const;
101 
102  bool hasError() const;
103  QSparqlError lastError() const;
104 
105  QString query() const;
106  QSparqlQuery::StatementType statementType() const;
107 
108  bool isTable() const;
109  bool isGraph() const;
110  bool isBool() const;
111 
112  virtual bool hasFeature(QSparqlResult::Feature feature) const;
113 
114 Q_SIGNALS:
115  void dataReady(int totalCount);
116  void finished();
117 
118 protected:
119  QSparqlResult();
120 
121  void setQuery(const QString & query);
122  void setStatementType(QSparqlQuery::StatementType type);
123  void setLastError(const QSparqlError& e);
124  void setBoolValue(bool v);
125 
126  void updatePos(int pos); // used by subclasses for managing the position
127 private:
128  QSparqlResultPrivate* d;
129 
130 private:
131  Q_DISABLE_COPY(QSparqlResult)
132 };
133 
134 QT_END_NAMESPACE
135 
136 QT_END_HEADER
137 
138 #endif // QSPARQLRESULT_H
QSparqlBinding
The QSparqlBinding class handles a binding between a SPARQL query variable name and the value of the ...
Definition: qsparqlbinding.h:62
QSparqlResult::binding
virtual QSparqlBinding binding(int i) const =0
QSparqlResultRow
The QSparqlResultRow class encapsulates a row in the results of a query.
Definition: qsparqlresultrow.h:64
QSparqlError
The QSparqlError class provides SPARQL error information.
Definition: qsparqlerror.h:65
QSparqlResult::current
virtual QSparqlResultRow current() const =0
QSparqlConnection
The QSparqlConnection class provides an interface for accessing an RDF store.
Definition: qsparqlconnection.h:68
QSparqlResult::Feature
Feature
Definition: qsparqlresult.h:72
QSparqlResult
The QSparqlResult class provides an abstract interface for accessing the results of an executed QSpar...
Definition: qsparqlresult.h:65
QSparqlResult::finished
void finished()
QSparqlQuery::StatementType
StatementType
Definition: qsparqlquery.h:67
QSparqlResult::dataReady
void dataReady(int totalCount)
QSparqlResult::value
virtual QVariant value(int i) const =0