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 
00149   virtual bool BindParameter(int index, const char *stringValue);
00150   // Description:
00151   // Bind a string value by specifying an array and a size
00152   virtual bool BindParameter(int index, const char *stringValue, size_t length);
00153 //BTX
00154   virtual bool BindParameter(int index, const vtkStdString &string);
00155 //ETX
00156   virtual bool BindParameter(int index, vtkVariant var);
00157   // Description:
00158   // Bind a blob value.  Not all databases support blobs as a data
00159   // type.  Check vtkSQLDatabase::IsSupported(VTK_SQL_FEATURE_BLOB) to
00160   // make sure.
00161   virtual bool BindParameter(int index, const void *data, size_t length);
00162   // Description:
00163   // Reset all parameter bindings to NULL.
00164   virtual bool ClearParameterBindings();
00166 
00167 //BTX
00169 
00175   virtual vtkStdString EscapeString( vtkStdString s, bool addSurroundingQuotes = true );
00176 //ETX
00178 
00185   char* EscapeString( const char* src, bool addSurroundingQuotes );
00186 
00187 protected:
00188   vtkSQLQuery();
00189   ~vtkSQLQuery();
00190 
00194   void SetDatabase(vtkSQLDatabase* db);
00195 
00196   char* Query;
00197   vtkSQLDatabase* Database;
00198   bool Active;
00199 
00200 private:
00201   vtkSQLQuery(const vtkSQLQuery &); // Not implemented.
00202   void operator=(const vtkSQLQuery &); // Not implemented.
00203 };
00204 
00205 #endif // __vtkSQLQuery_h
00206