VTK
dox/IO/vtkSQLQuery.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkSQLQuery.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 -------------------------------------------------------------------------*/
00062 #ifndef __vtkSQLQuery_h
00063 #define __vtkSQLQuery_h
00064 
00065 #include "vtkRowQuery.h"
00066 #include "vtkStdString.h" // for EscapeString()
00067 
00068 class vtkSQLDatabase;
00069 class vtkVariant;
00070 class vtkVariantArray;
00071 
00072 class VTK_IO_EXPORT vtkSQLQuery : public vtkRowQuery
00073 {
00074 public:
00075   vtkTypeMacro(vtkSQLQuery, vtkRowQuery);
00076   void PrintSelf(ostream& os, vtkIndent indent);
00077 
00079 
00082   virtual bool SetQuery(const char *query);
00083   virtual const char *GetQuery();
00085 
00089   bool IsActive() { return this->Active; }
00090 
00093   virtual bool Execute() = 0;
00094 
00096 
00098   virtual bool BeginTransaction() { return true; }
00099   virtual bool CommitTransaction() { return true; }
00100   virtual bool RollbackTransaction() { return true; }
00102 
00104 
00105   vtkGetObjectMacro(Database, vtkSQLDatabase);
00107 
00108 //BTX
00129   virtual bool BindParameter(int index, unsigned char value);
00130   virtual bool BindParameter(int index, unsigned short value);
00131   virtual bool BindParameter(int index, unsigned int value);
00132   virtual bool BindParameter(int index, unsigned long value);
00133   // The C and C++ standards leave it up to each compiler to decide
00134   // whether chars are signed or unsigned by default.  All the other
00135   // types are signed unless otherwise specified.
00136   virtual bool BindParameter(int index, signed char value);
00137   virtual bool BindParameter(int index, short value);
00138 //ETX
00139   virtual bool BindParameter(int index, int value);
00140 //BTX
00141   virtual bool BindParameter(int index, long value);
00142   virtual bool BindParameter(int index, vtkTypeUInt64 value);
00143   virtual bool BindParameter(int index, vtkTypeInt64 value);
00144 //ETX
00145   virtual bool BindParameter(int index, float value);
00146   virtual bool BindParameter(int index, double value);
00148   virtual bool BindParameter(int index, const char *stringValue);
00150 
00151   virtual bool BindParameter(int index, const char *stringValue, size_t length);
00152 //BTX
00153   virtual bool BindParameter(int index, const vtkStdString &string);
00154 //ETX
00155   virtual bool BindParameter(int index, vtkVariant var);
00157 
00159   virtual bool BindParameter(int index, const void *data, size_t length);
00161   virtual bool ClearParameterBindings();
00162 
00163 //BTX
00165 
00171   virtual vtkStdString EscapeString( vtkStdString s, bool addSurroundingQuotes = true );
00172 //ETX
00174 
00181   char* EscapeString( const char* src, bool addSurroundingQuotes );
00182 
00183 protected:
00184   vtkSQLQuery();
00185   ~vtkSQLQuery();
00186 
00190   void SetDatabase(vtkSQLDatabase* db);
00191 
00192   char* Query;
00193   vtkSQLDatabase* Database;
00194   bool Active;
00195 
00196 private:
00197   vtkSQLQuery(const vtkSQLQuery &); // Not implemented.
00198   void operator=(const vtkSQLQuery &); // Not implemented.
00199 };
00200 
00201 #endif // __vtkSQLQuery_h
00202