VTK
vtkSQLiteQuery.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkSQLiteQuery.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 /*-------------------------------------------------------------------------
16  Copyright 2008 Sandia Corporation.
17  Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
18  the U.S. Government retains certain rights in this software.
19 -------------------------------------------------------------------------*/
44 #ifndef vtkSQLiteQuery_h
45 #define vtkSQLiteQuery_h
46 
47 #include "vtkIOSQLModule.h" // For export macro
48 #include "vtkSQLQuery.h"
49 
50 class vtkSQLiteDatabase;
51 class vtkVariant;
52 class vtkVariantArray;
53 
54 class VTKIOSQL_EXPORT vtkSQLiteQuery : public vtkSQLQuery
55 {
56 
57  friend class vtkSQLiteDatabase;
58 
59 public:
60  vtkTypeMacro(vtkSQLiteQuery, vtkSQLQuery);
61  void PrintSelf(ostream& os, vtkIndent indent) override;
62  static vtkSQLiteQuery *New();
63 
68  bool SetQuery(const char *query) override;
69 
75  bool Execute() override;
76 
80  int GetNumberOfFields() override;
81 
85  const char* GetFieldName(int i) override;
86 
90  int GetFieldType(int i) override;
91 
95  bool NextRow() override;
96 
100  bool HasError() override;
101 
103 
106  bool BeginTransaction() override;
107  bool RollbackTransaction() override;
108  bool CommitTransaction() override;
110 
114  vtkVariant DataValue(vtkIdType c) override;
115 
119  const char* GetLastErrorText() override;
120 
130  bool BindParameter(int index, unsigned char value) override;
131  bool BindParameter(int index, signed char value) override;
132  bool BindParameter(int index, unsigned short value) override;
133  bool BindParameter(int index, short value) override;
134  bool BindParameter(int index, unsigned int value) override;
135 
136  bool BindParameter(int index, int value) override;
137 
138  bool BindParameter(int index, unsigned long value) override;
139  bool BindParameter(int index, long value) override;
140  bool BindParameter(int index, unsigned long long value) override;
141  bool BindParameter(int index, long long value) override;
142 
143  bool BindParameter(int index, float value) override;
144  bool BindParameter(int index, double value) override;
148  bool BindParameter(int index, const char *stringValue) override;
152  bool BindParameter(int index, const char *stringValue, size_t length) override;
153 
154  bool BindParameter(int index, const vtkStdString &string) override;
155 
156  bool BindParameter(int index, vtkVariant value) override;
158 
163  bool BindParameter(int index, const void *data, size_t length) override;
164  bool ClearParameterBindings() override;
166 
167 protected:
168  vtkSQLiteQuery();
169  ~vtkSQLiteQuery() override;
170 
171  vtkSetStringMacro(LastErrorText);
172 
173 private:
174  vtkSQLiteQuery(const vtkSQLiteQuery &) = delete;
175  void operator=(const vtkSQLiteQuery &) = delete;
176 
177  class Priv;
178  Priv* Private;
179  bool InitialFetch;
180  int InitialFetchResult;
181  char *LastErrorText;
182  bool TransactionInProgress;
183 
185 
189  bool BindIntegerParameter(int index, int value);
190  bool BindDoubleParameter(int index, double value);
191  bool BindInt64Parameter(int index, vtkTypeInt64 value);
192  bool BindStringParameter(int index, const char *data, int length);
193  bool BindBlobParameter(int index, const void *data, int length);
195 
196 };
197 
198 #endif // vtkSQLiteQuery_h
199 
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual bool SetQuery(const char *query)
The query string to be executed.
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:40
virtual bool NextRow()=0
Advance row, return false if past end.
An array holding vtkVariants.
bool Execute() override=0
Execute the query.
virtual const char * GetFieldName(int i)=0
Return the name of the specified query field.
virtual bool BindParameter(int index, unsigned char value)
Bind a parameter to a placeholder in a query.
maintain a connection to an SQLite database
virtual bool CommitTransaction()
Definition: vtkSQLQuery.h:110
int vtkIdType
Definition: vtkType.h:347
A atomic type representing the union of many types.
Definition: vtkVariant.h:71
virtual bool HasError()=0
Returns true if an error is set, otherwise false.
friend class vtkSQLiteQuery
vtkSQLQuery implementation for SQLite databases
a simple class to control print indentation
Definition: vtkIndent.h:39
virtual int GetNumberOfFields()=0
The number of fields in the query result.
virtual bool RollbackTransaction()
Definition: vtkSQLQuery.h:111
virtual bool BeginTransaction()
Begin, commit, or roll back a transaction.
Definition: vtkSQLQuery.h:109
virtual int GetFieldType(int i)=0
Return the type of the field, using the constants defined in vtkType.h.
virtual bool ClearParameterBindings()
Reset all parameter bindings to nullptr.
virtual vtkVariant DataValue(vtkIdType c)=0
Return data in current row, field c.
executes an sql query and retrieves results
Definition: vtkSQLQuery.h:74
virtual const char * GetLastErrorText()=0
Get the last error text from the query.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...