00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00062 #ifndef __vtkSQLQuery_h
00063 #define __vtkSQLQuery_h
00064 
00065 #include "vtkRowQuery.h"
00066 #include "vtkStdString.h" 
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 
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   
00134   
00135   
00136   virtual bool BindParameter(int index, signed char value);
00137   virtual bool BindParameter(int index, short value);
00138 
00139   virtual bool BindParameter(int index, int value);
00140 
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 
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   
00151   
00152   virtual bool BindParameter(int index, const char *stringValue, size_t length);
00153 
00154   virtual bool BindParameter(int index, const vtkStdString &string);
00155 
00156   virtual bool BindParameter(int index, vtkVariant var);
00157   
00158   
00159   
00160   
00161   virtual bool BindParameter(int index, const void *data, size_t length);
00162   
00163   
00164   virtual bool ClearParameterBindings();
00166 
00167 
00169 
00175   virtual vtkStdString EscapeString( vtkStdString s, bool addSurroundingQuotes = true );
00176 
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 &); 
00202   void operator=(const vtkSQLQuery &); 
00203 };
00204 
00205 #endif // __vtkSQLQuery_h
00206