VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkSQLiteQuery.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00015 /*------------------------------------------------------------------------- 00016 Copyright 2008 Sandia Corporation. 00017 Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, 00018 the U.S. Government retains certain rights in this software. 00019 -------------------------------------------------------------------------*/ 00043 #ifndef __vtkSQLiteQuery_h 00044 #define __vtkSQLiteQuery_h 00045 00046 #include "vtkSQLQuery.h" 00047 00048 class vtkSQLiteDatabase; 00049 class vtkVariant; 00050 class vtkVariantArray; 00051 struct vtk_sqlite3_stmt; 00052 00053 class VTK_IO_EXPORT vtkSQLiteQuery : public vtkSQLQuery 00054 { 00055 //BTX 00056 friend class vtkSQLiteDatabase; 00057 //ETX 00058 00059 public: 00060 vtkTypeMacro(vtkSQLiteQuery, vtkSQLQuery); 00061 void PrintSelf(ostream& os, vtkIndent indent); 00062 static vtkSQLiteQuery *New(); 00063 00066 bool SetQuery(const char *query); 00067 00070 bool Execute(); 00071 00073 int GetNumberOfFields(); 00074 00076 const char* GetFieldName(int i); 00077 00080 int GetFieldType(int i); 00081 00083 bool NextRow(); 00084 00086 bool HasError(); 00087 00089 00090 bool BeginTransaction(); 00091 bool RollbackTransaction(); 00092 bool CommitTransaction(); 00094 00095 //BTX 00097 00098 vtkVariant DataValue(vtkIdType c); 00099 //ETX 00101 00103 const char* GetLastErrorText(); 00104 00106 00111 using vtkSQLQuery::BindParameter; 00112 bool BindParameter(int index, unsigned char value); 00113 bool BindParameter(int index, signed char value); 00114 bool BindParameter(int index, unsigned short value); 00115 bool BindParameter(int index, short value); 00116 bool BindParameter(int index, unsigned int value); 00118 //ETX 00119 bool BindParameter(int index, int value); 00120 //BTX 00121 bool BindParameter(int index, unsigned long value); 00122 bool BindParameter(int index, long value); 00123 bool BindParameter(int index, vtkTypeUInt64 value); 00124 bool BindParameter(int index, vtkTypeInt64 value); 00125 //ETX 00126 bool BindParameter(int index, float value); 00127 bool BindParameter(int index, double value); 00129 00130 bool BindParameter(int index, const char *stringValue); 00131 // Description: 00132 // Bind a string value by specifying an array and a size 00133 bool BindParameter(int index, const char *stringValue, size_t length); 00135 //BTX 00136 bool BindParameter(int index, const vtkStdString &string); 00137 bool BindParameter(int index, vtkVariant value); 00138 //ETX 00140 00142 bool BindParameter(int index, const void *data, size_t length); 00143 bool ClearParameterBindings(); 00145 00146 protected: 00147 vtkSQLiteQuery(); 00148 ~vtkSQLiteQuery(); 00149 00150 vtkSetStringMacro(LastErrorText); 00151 00152 private: 00153 vtkSQLiteQuery(const vtkSQLiteQuery &); // Not implemented. 00154 void operator=(const vtkSQLiteQuery &); // Not implemented. 00155 00156 vtk_sqlite3_stmt *Statement; 00157 bool InitialFetch; 00158 int InitialFetchResult; 00159 char *LastErrorText; 00160 bool TransactionInProgress; 00161 00163 00165 bool BindIntegerParameter(int index, int value); 00166 bool BindDoubleParameter(int index, double value); 00167 bool BindInt64Parameter(int index, vtkTypeInt64 value); 00168 bool BindStringParameter(int index, const char *data, int length); 00169 bool BindBlobParameter(int index, const void *data, int length); 00171 00172 }; 00173 00174 #endif // __vtkSQLiteQuery_h 00175