VTK
vtkSQLQuery.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkSQLQuery.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 /*-------------------------------------------------------------------------
16  Copyright 2008 Sandia Corporation.
17  Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
18  the U.S. Government retains certain rights in this software.
19 -------------------------------------------------------------------------*/
62 #ifndef __vtkSQLQuery_h
63 #define __vtkSQLQuery_h
64 
65 #include "vtkRowQuery.h"
66 #include "vtkStdString.h" // for EscapeString()
67 
68 class vtkSQLDatabase;
69 class vtkVariant;
70 class vtkVariantArray;
71 
73 {
74 public:
75  vtkTypeMacro(vtkSQLQuery, vtkRowQuery);
76  void PrintSelf(ostream& os, vtkIndent indent);
77 
79 
82  virtual bool SetQuery(const char *query);
83  virtual const char *GetQuery();
85 
89  bool IsActive() { return this->Active; }
90 
93  virtual bool Execute() = 0;
94 
96 
98  virtual bool BeginTransaction() { return true; }
99  virtual bool CommitTransaction() { return true; }
100  virtual bool RollbackTransaction() { return true; }
102 
104 
105  vtkGetObjectMacro(Database, vtkSQLDatabase);
107 
108 //BTX
129  virtual bool BindParameter(int index, unsigned char value);
130  virtual bool BindParameter(int index, unsigned short value);
131  virtual bool BindParameter(int index, unsigned int value);
132  virtual bool BindParameter(int index, unsigned long value);
133  // The C and C++ standards leave it up to each compiler to decide
134  // whether chars are signed or unsigned by default. All the other
135  // types are signed unless otherwise specified.
136  virtual bool BindParameter(int index, signed char value);
137  virtual bool BindParameter(int index, short value);
138 //ETX
139  virtual bool BindParameter(int index, int value);
140 //BTX
141  virtual bool BindParameter(int index, long value);
142  virtual bool BindParameter(int index, vtkTypeUInt64 value);
143  virtual bool BindParameter(int index, vtkTypeInt64 value);
144 //ETX
145  virtual bool BindParameter(int index, float value);
146  virtual bool BindParameter(int index, double value);
148 
149  virtual bool BindParameter(int index, const char *stringValue);
150  // Description:
151  // Bind a string value by specifying an array and a size
152  virtual bool BindParameter(int index, const char *stringValue, size_t length);
153 //BTX
154  virtual bool BindParameter(int index, const vtkStdString &string);
155 //ETX
156  virtual bool BindParameter(int index, vtkVariant var);
157  // Description:
158  // Bind a blob value. Not all databases support blobs as a data
159  // type. Check vtkSQLDatabase::IsSupported(VTK_SQL_FEATURE_BLOB) to
160  // make sure.
161  virtual bool BindParameter(int index, const void *data, size_t length);
162  // Description:
163  // Reset all parameter bindings to NULL.
164  virtual bool ClearParameterBindings();
166 
167 //BTX
169 
175  virtual vtkStdString EscapeString( vtkStdString s, bool addSurroundingQuotes = true );
176 //ETX
178 
185  char* EscapeString( const char* src, bool addSurroundingQuotes );
186 
187 protected:
188  vtkSQLQuery();
189  ~vtkSQLQuery();
190 
194  void SetDatabase(vtkSQLDatabase* db);
195 
196  char* Query;
198  bool Active;
199 
200 private:
201  vtkSQLQuery(const vtkSQLQuery &); // Not implemented.
202  void operator=(const vtkSQLQuery &); // Not implemented.
203 };
204 
205 #endif // __vtkSQLQuery_h
206