File indexing completed on 2024-04-28 15:58:54
0001 /* This file is part of the KDE project 0002 Copyright (C) 2003-2010 Jarosław Staniek <staniek@kde.org> 0003 0004 This program is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU Library General Public 0006 License as published by the Free Software Foundation; either 0007 version 2 of the License, or (at your option) any later version. 0008 0009 This program is distributed in the hope that it will be useful, 0010 but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 Library General Public License for more details. 0013 0014 You should have received a copy of the GNU Library General Public License 0015 along with this program; see the file COPYING. If not, write to 0016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0017 * Boston, MA 02110-1301, USA. 0018 */ 0019 0020 #ifndef KDB_SQLITECURSOR_H 0021 #define KDB_SQLITECURSOR_H 0022 0023 #include <QString> 0024 0025 #include "KDbCursor.h" 0026 0027 class SqliteCursorData; 0028 class SqliteConnection; 0029 0030 /*! 0031 0032 */ 0033 class SqliteCursor : public KDbCursor 0034 { 0035 public: 0036 ~SqliteCursor() override; 0037 QVariant value(int i) override; 0038 0039 /*! [PROTOTYPE] @return internal buffer data. */ 0040 //! @todo virtual const char *** bufferData() 0041 /*! [PROTOTYPE] @return current record data or @c nullptr if there is no current records. */ 0042 const char ** recordData() const override; 0043 0044 bool drv_storeCurrentRecord(KDbRecordData* data) const override; 0045 0046 //! Implemented for KDbResultable 0047 QString serverResultName() const override; 0048 0049 protected: 0050 /*! KDbCursor will operate on @a conn, raw @a sql statement will be used to execute query. */ 0051 SqliteCursor(SqliteConnection* conn, const KDbEscapedString& sql, 0052 Options options = KDbCursor::Option::None); 0053 0054 /*! KDbCursor will operate on @a conn, @a query schema will be used to execute query. */ 0055 SqliteCursor(SqliteConnection* conn, KDbQuerySchema* query, 0056 Options options = KDbCursor::Option::None); 0057 0058 bool drv_open(const KDbEscapedString& sql) override; 0059 0060 bool drv_close() override; 0061 void drv_getNextRecord() override; 0062 0063 void drv_appendCurrentRecordToBuffer() override; 0064 void drv_bufferMovePointerNext() override; 0065 void drv_bufferMovePointerPrev() override; 0066 void drv_bufferMovePointerTo(qint64 at) override; 0067 0068 //! @todo virtual void drv_storeCurrentRecord(); 0069 0070 //PROTOTYPE: 0071 /*! Method called when cursor's buffer need to be cleared 0072 (only for buffered cursor type), eg. in close(). */ 0073 void drv_clearBuffer() override; 0074 0075 void storeResult(); 0076 0077 SqliteCursorData * const d; 0078 0079 friend class SqliteConnection; 0080 Q_DISABLE_COPY(SqliteCursor) 0081 }; 0082 0083 #endif