KDb

PostgresqlCursor.h
1 /* This file is part of the KDE project
2  Copyright (C) 2003 Adam Pigg <[email protected]>
3  Copyright (C) 2010 JarosÅ‚aw Staniek <[email protected]>
4 
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this program; see the file COPYING. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19 */
20 
21 #ifndef KDB_POSTGRESQLCURSOR_H
22 #define KDB_POSTGRESQLCURSOR_H
23 
24 #include "KDbCursor.h"
25 #include "KDbField.h"
26 
27 #include <libpq-fe.h>
28 
29 class KDbConnection;
30 class PostgresqlCursorData;
31 
32 class PostgresqlCursor: public KDbCursor
33 {
34 public:
35  explicit PostgresqlCursor(KDbConnection* conn, const KDbEscapedString& sql,
36  KDbCursor::Options options = KDbCursor::Option::None);
37  PostgresqlCursor(KDbConnection* conn, KDbQuerySchema* query,
38  KDbCursor::Options options = KDbCursor::Option::None);
39  ~PostgresqlCursor() override;
40 
41  QVariant value(int pos) override;
42  const char** recordData() const override;
43  bool drv_storeCurrentRecord(KDbRecordData* data) const override;
44  bool drv_open(const KDbEscapedString& sql) override;
45  bool drv_close() override;
46  void drv_getNextRecord() override;
47  void drv_appendCurrentRecordToBuffer() override;
48  void drv_bufferMovePointerNext() override;
49  void drv_bufferMovePointerPrev() override;
50  void drv_bufferMovePointerTo(qint64 to) override;
51 
52  void storeResultAndClear(PGresult **pgResult, ExecStatusType execStatus);
53 
54 private:
55  QVariant pValue(int pos)const;
56 
57  unsigned long m_numRows;
58  QVector<KDbField::Type> m_realTypes;
59  QVector<int> m_realLengths;
60 
61  PostgresqlCursorData * const d;
62  Q_DISABLE_COPY(PostgresqlCursor)
63 };
64 
65 #endif
Provides database cursor functionality.
Definition: KDbCursor.h:68
virtual const char ** recordData() const =0
Specialized string for escaping.
virtual void drv_bufferMovePointerTo(qint64 at)=0
virtual void drv_appendCurrentRecordToBuffer()=0
virtual bool drv_open(const KDbEscapedString &sql)=0
virtual bool drv_storeCurrentRecord(KDbRecordData *data) const =0
Structure for storing single record with type information.
Definition: KDbRecordData.h:36
KDbQuerySchema provides information about database query.
virtual void drv_bufferMovePointerPrev()=0
virtual QVariant value(int i)=0
Provides database connection, allowing queries and data modification.
Definition: KDbConnection.h:51
virtual void drv_bufferMovePointerNext()=0
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sat Jun 25 2022 06:21:34 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.