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  virtual bool BindParameter(int index, const char *stringValue);
150 
151  virtual bool BindParameter(int index, const char *stringValue, size_t length);
152 //BTX
153  virtual bool BindParameter(int index, const vtkStdString &string);
154 //ETX
155  virtual bool BindParameter(int index, vtkVariant var);
157 
159  virtual bool BindParameter(int index, const void *data, size_t length);
161  virtual bool ClearParameterBindings();
162 
163 //BTX
165 
171  virtual vtkStdString EscapeString( vtkStdString s, bool addSurroundingQuotes = true );
172 //ETX
174 
181  char* EscapeString( const char* src, bool addSurroundingQuotes );
182 
183 protected:
184  vtkSQLQuery();
185  ~vtkSQLQuery();
186 
190  void SetDatabase(vtkSQLDatabase* db);
191 
192  char* Query;
194  bool Active;
195 
196 private:
197  vtkSQLQuery(const vtkSQLQuery &); // Not implemented.
198  void operator=(const vtkSQLQuery &); // Not implemented.
199 };
200 
201 #endif // __vtkSQLQuery_h
202