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 struct sqlite3_stmt;
54 
55 class VTKIOSQL_EXPORT vtkSQLiteQuery : public vtkSQLQuery
56 {
57 
58  friend class vtkSQLiteDatabase;
59 
60 public:
61  vtkTypeMacro(vtkSQLiteQuery, vtkSQLQuery);
62  void PrintSelf(ostream& os, vtkIndent indent);
63  static vtkSQLiteQuery *New();
64 
69  bool SetQuery(const char *query);
70 
76  bool Execute();
77 
82 
86  const char* GetFieldName(int i);
87 
91  int GetFieldType(int i);
92 
96  bool NextRow();
97 
101  bool HasError();
102 
104 
111 
116 
120  const char* GetLastErrorText();
121 
131  bool BindParameter(int index, unsigned char value);
132  bool BindParameter(int index, signed char value);
133  bool BindParameter(int index, unsigned short value);
134  bool BindParameter(int index, short value);
135  bool BindParameter(int index, unsigned int value);
136 
137  bool BindParameter(int index, int value);
138 
139  bool BindParameter(int index, unsigned long value);
140  bool BindParameter(int index, long value);
141  bool BindParameter(int index, unsigned long long value);
142  bool BindParameter(int index, long long value);
143 
144  bool BindParameter(int index, float value);
145  bool BindParameter(int index, double value);
149  bool BindParameter(int index, const char *stringValue);
153  bool BindParameter(int index, const char *stringValue, size_t length);
154 
155  bool BindParameter(int index, const vtkStdString &string);
156 
159 
164  bool BindParameter(int index, const void *data, size_t length);
167 
168 protected:
171 
172  vtkSetStringMacro(LastErrorText);
173 
174 private:
175  vtkSQLiteQuery(const vtkSQLiteQuery &) VTK_DELETE_FUNCTION;
176  void operator=(const vtkSQLiteQuery &) VTK_DELETE_FUNCTION;
177 
178  sqlite3_stmt *Statement;
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 
vtkSQLiteQuery::NextRow
bool NextRow()
Advance row, return false if past end.
vtkSQLiteQuery::vtkSQLiteQuery
vtkSQLiteQuery()
vtkSQLiteQuery::SetQuery
bool SetQuery(const char *query)
Set the SQL query string.
vtkSQLiteQuery::GetFieldName
const char * GetFieldName(int i)
Return the name of the specified query field.
vtkSQLiteQuery::~vtkSQLiteQuery
~vtkSQLiteQuery()
vtkX3D::value
@ value
Definition: vtkX3D.h:220
vtkIdType
int vtkIdType
Definition: vtkType.h:287
vtkSQLiteQuery::BindParameter
bool BindParameter(int index, const vtkStdString &string)
vtkX3D::data
@ data
Definition: vtkX3D.h:315
vtkSQLiteQuery::New
static vtkSQLiteQuery * New()
vtkSQLiteQuery::BeginTransaction
bool BeginTransaction()
Begin, abort (roll back), or commit a transaction.
vtkSQLiteQuery::BindParameter
bool BindParameter(int index, int value)
vtkSQLiteQuery::BindParameter
bool BindParameter(int index, long long value)
vtkSQLiteQuery::RollbackTransaction
bool RollbackTransaction()
vtkSQLiteQuery::Execute
bool Execute()
Execute the query.
vtkSQLiteDatabase::vtkSQLiteQuery
friend class vtkSQLiteQuery
Definition: vtkSQLiteDatabase.h:66
vtkX3D::length
@ length
Definition: vtkX3D.h:393
vtkVariantArray
An array holding vtkVariants.
Definition: vtkVariantArray.h:47
vtkSQLiteQuery::BindParameter
bool BindParameter(int index, signed char value)
vtkSQLiteQuery::BindParameter
bool BindParameter(int index, short value)
vtkSQLQuery::BindParameter
virtual bool BindParameter(int index, unsigned char value)
Bind a parameter to a placeholder in a query.
vtkSQLiteQuery::BindParameter
bool BindParameter(int index, unsigned long value)
vtkSQLiteQuery::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
vtkSQLiteQuery::BindParameter
bool BindParameter(int index, const void *data, size_t length)
Bind a blob value.
vtkSQLiteQuery::BindParameter
bool BindParameter(int index, unsigned char value)
Bind a parameter to a placeholder in a query.
vtkSQLiteQuery::BindParameter
bool BindParameter(int index, float value)
vtkSQLiteQuery::BindParameter
bool BindParameter(int index, long value)
vtkSQLiteDatabase
maintain a connection to an SQLite database
Definition: vtkSQLiteDatabase.h:64
vtkSQLiteQuery::BindParameter
bool BindParameter(int index, vtkVariant value)
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:40
vtkSQLiteQuery::HasError
bool HasError()
Return true if there is an error on the current query.
vtkSQLiteQuery::BindParameter
bool BindParameter(int index, unsigned int value)
vtkVariant
A atomic type representing the union of many types.
Definition: vtkVariant.h:76
vtkSQLiteQuery::BindParameter
bool BindParameter(int index, const char *stringValue)
Bind a string value – string must be null-terminated.
vtkSQLiteQuery::GetFieldType
int GetFieldType(int i)
Return the type of the field, using the constants defined in vtkType.h.
vtkSQLiteQuery::BindParameter
bool BindParameter(int index, unsigned long long value)
vtkSQLiteQuery::GetNumberOfFields
int GetNumberOfFields()
The number of fields in the query result.
vtkSQLiteQuery::ClearParameterBindings
bool ClearParameterBindings()
Reset all parameter bindings to NULL.
vtkSQLiteQuery::CommitTransaction
bool CommitTransaction()
vtkSQLQuery.h
vtkStdString
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:49
vtkSQLQuery
executes an sql query and retrieves results
Definition: vtkSQLQuery.h:75
vtkSQLiteQuery::BindParameter
bool BindParameter(int index, const char *stringValue, size_t length)
Bind a string value by specifying an array and a size.
vtkX3D::index
@ index
Definition: vtkX3D.h:246
vtkSQLiteQuery::GetLastErrorText
const char * GetLastErrorText()
Get the last error text from the query.
vtkSQLiteQuery::BindParameter
bool BindParameter(int index, unsigned short value)
vtkSQLiteQuery::BindParameter
bool BindParameter(int index, double value)
vtkSQLiteQuery::DataValue
vtkVariant DataValue(vtkIdType c)
Return data in current row, field c.
vtkSQLiteQuery
vtkSQLQuery implementation for SQLite databases
Definition: vtkSQLiteQuery.h:56