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 -------------------------------------------------------------------------*/
43 #ifndef __vtkSQLiteQuery_h
44 #define __vtkSQLiteQuery_h
45 
46 #include "vtkSQLQuery.h"
47 
48 class vtkSQLiteDatabase;
49 class vtkVariant;
50 class vtkVariantArray;
51 struct sqlite3_stmt;
52 
54 {
55  //BTX
56  friend class vtkSQLiteDatabase;
57  //ETX
58 
59 public:
60  vtkTypeMacro(vtkSQLiteQuery, vtkSQLQuery);
61  void PrintSelf(ostream& os, vtkIndent indent);
62  static vtkSQLiteQuery *New();
63 
66  bool SetQuery(const char *query);
67 
70  bool Execute();
71 
73  int GetNumberOfFields();
74 
76  const char* GetFieldName(int i);
77 
80  int GetFieldType(int i);
81 
83  bool NextRow();
84 
86  bool HasError();
87 
89 
90  bool BeginTransaction();
91  bool RollbackTransaction();
92  bool CommitTransaction();
94 
97 
99  const char* GetLastErrorText();
100 
102 
108  bool BindParameter(int index, unsigned char value);
109  bool BindParameter(int index, signed char value);
110  bool BindParameter(int index, unsigned short value);
111  bool BindParameter(int index, short value);
112  bool BindParameter(int index, unsigned int value);
113 //ETX
114  bool BindParameter(int index, int value);
115 //BTX
116  bool BindParameter(int index, unsigned long value);
117  bool BindParameter(int index, long value);
118  bool BindParameter(int index, vtkTypeUInt64 value);
119  bool BindParameter(int index, vtkTypeInt64 value);
120 //ETX
121  bool BindParameter(int index, float value);
122  bool BindParameter(int index, double value);
123  // Description:
124  // Bind a string value -- string must be null-terminated
125  bool BindParameter(int index, const char *stringValue);
126  // Description:
127  // Bind a string value by specifying an array and a size
128  bool BindParameter(int index, const char *stringValue, size_t length);
129 //BTX
130  bool BindParameter(int index, const vtkStdString &string);
131 //ETX
132  bool BindParameter(int index, vtkVariant value);
133  // Description:
134  // Bind a blob value. Not all databases support blobs as a data
135  // type. Check vtkSQLDatabase::IsSupported(VTK_SQL_FEATURE_BLOB) to
136  // make sure.
137  bool BindParameter(int index, const void *data, size_t length);
138  bool ClearParameterBindings();
140 
141 protected:
142  vtkSQLiteQuery();
143  ~vtkSQLiteQuery();
144 
145  vtkSetStringMacro(LastErrorText);
146 
147 private:
148  vtkSQLiteQuery(const vtkSQLiteQuery &); // Not implemented.
149  void operator=(const vtkSQLiteQuery &); // Not implemented.
150 
151  sqlite3_stmt *Statement;
152  bool InitialFetch;
153  int InitialFetchResult;
154  char *LastErrorText;
155  bool TransactionInProgress;
156 
158 
160  bool BindIntegerParameter(int index, int value);
161  bool BindDoubleParameter(int index, double value);
162  bool BindInt64Parameter(int index, vtkTypeInt64 value);
163  bool BindStringParameter(int index, const char *data, int length);
164  bool BindBlobParameter(int index, const void *data, int length);
166 
167 };
168 
169 #endif // __vtkSQLiteQuery_h
170