VTK
dox/IO/vtkSQLiteQuery.h
Go to the documentation of this file.
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 
00096   vtkVariant DataValue(vtkIdType c);
00097 
00099   const char* GetLastErrorText();
00100 
00102 
00107   using vtkSQLQuery::BindParameter;
00108   bool BindParameter(int index, unsigned char value);
00109   bool BindParameter(int index, signed char value);
00110   bool BindParameter(int index, unsigned short value);
00111   bool BindParameter(int index, short value);
00112   bool BindParameter(int index, unsigned int value);
00113 //ETX
00114   bool BindParameter(int index, int value);
00115 //BTX
00116   bool BindParameter(int index, unsigned long value);
00117   bool BindParameter(int index, long value);
00118   bool BindParameter(int index, vtkTypeUInt64 value);
00119   bool BindParameter(int index, vtkTypeInt64 value);
00120 //ETX
00121   bool BindParameter(int index, float value);
00122   bool BindParameter(int index, double value);
00124 
00125   bool BindParameter(int index, const char *stringValue);
00127 
00128   bool BindParameter(int index, const char *stringValue, size_t length);
00129 //BTX
00130   bool BindParameter(int index, const vtkStdString &string);
00131 //ETX
00132   bool BindParameter(int index, vtkVariant value);
00134 
00135 
00137   bool BindParameter(int index, const void *data, size_t length);
00138   bool ClearParameterBindings();
00140 
00141 protected:
00142   vtkSQLiteQuery();
00143   ~vtkSQLiteQuery();
00144 
00145   vtkSetStringMacro(LastErrorText);
00146 
00147 private:
00148   vtkSQLiteQuery(const vtkSQLiteQuery &); // Not implemented.
00149   void operator=(const vtkSQLiteQuery &); // Not implemented.
00150 
00151   vtk_sqlite3_stmt *Statement;
00152   bool InitialFetch;
00153   int InitialFetchResult;
00154   char *LastErrorText;
00155   bool TransactionInProgress;
00156 
00158 
00160   bool BindIntegerParameter(int index, int value);
00161   bool BindDoubleParameter(int index, double value);
00162   bool BindInt64Parameter(int index, vtkTypeInt64 value);
00163   bool BindStringParameter(int index, const char *data, int length);
00164   bool BindBlobParameter(int index, const void *data, int length);
00166 
00167 };
00168 
00169 #endif // __vtkSQLiteQuery_h
00170