kexi
cursor.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef KEXIDB_CURSOR_H
00021 #define KEXIDB_CURSOR_H
00022
00023 #include <qstring.h>
00024 #include <qvariant.h>
00025 #include <qptrvector.h>
00026 #include <qvaluevector.h>
00027
00028 #include <kexidb/connection.h>
00029 #include <kexidb/object.h>
00030
00031 namespace KexiDB {
00032
00033 class RowEditBuffer;
00034
00036
00066 class KEXI_DB_EXPORT Cursor: public QObject, public Object
00067 {
00068 Q_OBJECT
00069
00070 public:
00072 enum Options {
00073 NoOptions = 0,
00074 Buffered = 1
00075 };
00076
00077 virtual ~Cursor();
00078
00080 inline Connection* connection() const { return m_conn; }
00081
00084 bool open();
00085
00089 bool reopen();
00090
00091
00092
00093
00094
00095
00096
00099 virtual bool close();
00100
00103 inline QuerySchema *query() const { return m_query; }
00104
00107 inline QString rawStatement() const { return m_rawStatement; }
00108
00111 inline uint options() const { return m_options; }
00112
00114 inline bool isOpened() const { return m_opened; }
00115
00117 bool isBuffered() const;
00118
00124 void setBuffered(bool buffered);
00125
00129 bool moveFirst();
00130
00134 virtual bool moveLast();
00135
00137 virtual bool moveNext();
00138
00141 virtual bool movePrev();
00142
00144 bool eof() const;
00145
00147 bool bof() const;
00148
00154 Q_LLONG at() const;
00155
00158 inline uint fieldCount() const { return m_fieldCount; }
00159
00166 inline bool containsROWIDInfo() const { return m_containsROWIDInfo; }
00167
00174 virtual QVariant value(uint i) = 0;
00175
00177 virtual const char ** rowData() const = 0;
00178
00193 void setOrderByColumnList(const QStringList& columnNames);
00194
00196 void setOrderByColumnList(const QString& column1, const QString& column2 = QString::null,
00197 const QString& column3 = QString::null, const QString& column4 = QString::null,
00198 const QString& column5 = QString::null);
00199
00202 QueryColumnInfo::Vector orderByColumnList() const;
00203
00209 virtual void storeCurrentRow(RowData &data) const = 0;
00210
00211 bool updateRow(RowData& data, RowEditBuffer& buf, bool useROWID = false);
00212
00213 bool insertRow(RowData& data, RowEditBuffer& buf, bool getROWID = false);
00214
00215 bool deleteRow(RowData& data, bool useROWID = false);
00216
00217 bool deleteAllRows();
00218
00226 virtual int serverResult() { return 0; }
00227
00233 virtual QString serverResultName() { return QString::null; }
00234
00240 virtual QString serverErrorMsg() { return QString::null; }
00241
00243 QString debugString() const;
00244
00246 void debug() const;
00247
00248 protected:
00250 typedef enum FetchResult { FetchError=0, FetchOK=1, FetchEnd=2 };
00251
00253 Cursor(Connection* conn, const QString& statement, uint options = NoOptions );
00254
00256 Cursor(Connection* conn, QuerySchema& query, uint options = NoOptions );
00257
00258 void init();
00259
00262 bool getNextRecord();
00263
00264
00265
00266
00267
00268 virtual bool drv_open() = 0;
00269
00270 virtual bool drv_close() = 0;
00271
00272 virtual void drv_getNextRecord() = 0;
00273
00274
00287 virtual void drv_appendCurrentRecordToBuffer() = 0;
00291 virtual void drv_bufferMovePointerNext() = 0;
00293 virtual void drv_bufferMovePointerPrev() = 0;
00296 virtual void drv_bufferMovePointerTo(Q_LLONG at) = 0;
00297
00298
00299
00300
00301
00302
00303
00306 virtual void drv_clearBuffer() {}
00307
00309 void clearBuffer();
00310
00313 virtual void drv_clearServerResult() = 0;
00314
00315 QGuardedPtr<Connection> m_conn;
00316 QuerySchema *m_query;
00317
00318 QString m_rawStatement;
00319 bool m_opened : 1;
00320
00321 bool m_atLast : 1;
00322 bool m_afterLast : 1;
00323
00324 bool m_validRecord : 1;
00325 bool m_containsROWIDInfo : 1;
00326 Q_LLONG m_at;
00327 uint m_fieldCount;
00328 uint m_options;
00329
00330 char m_result;
00331
00332
00333 int m_records_in_buf;
00334 bool m_buffering_completed : 1;
00335
00336
00338 QueryColumnInfo::Vector* m_fieldsExpanded;
00339
00341 QueryColumnInfo::Vector* m_orderByColumnList;
00342
00343
00344
00345
00346 private:
00347 bool m_readAhead : 1;
00348
00349
00350 bool m_at_buffer : 1;
00351
00352
00353
00354 class Private;
00355 Private *d;
00356 };
00357
00358 }
00359
00360 #endif
00361
00362
|