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 -------------------------------------------------------------------------*/
63 #ifndef vtkSQLQuery_h
64 #define vtkSQLQuery_h
65 
66 #include "vtkIOSQLModule.h" // For export macro
67 #include "vtkRowQuery.h"
68 #include "vtkStdString.h" // for EscapeString()
69 
70 class vtkSQLDatabase;
71 class vtkVariant;
72 class vtkVariantArray;
73 
74 class VTKIOSQL_EXPORT vtkSQLQuery : public vtkRowQuery
75 {
76 public:
77  vtkTypeMacro(vtkSQLQuery, vtkRowQuery);
78  void PrintSelf(ostream& os, vtkIndent indent);
79 
81 
86  virtual bool SetQuery(const char *query);
87  virtual const char *GetQuery();
89 
95  bool IsActive() { return this->Active; }
96 
102  virtual bool Execute() = 0;
103 
109  virtual bool BeginTransaction() { return true; }
110  virtual bool CommitTransaction() { return true; }
111  virtual bool RollbackTransaction() { return true; }
112 
114 
117  vtkGetObjectMacro(Database, vtkSQLDatabase);
119 
149  virtual bool BindParameter(int index, unsigned char value);
150  virtual bool BindParameter(int index, unsigned short value);
151  virtual bool BindParameter(int index, unsigned int value);
152  virtual bool BindParameter(int index, unsigned long value);
153  // The C and C++ standards leave it up to each compiler to decide
154  // whether chars are signed or unsigned by default. All the other
155  // types are signed unless otherwise specified.
156  virtual bool BindParameter(int index, signed char value);
157  virtual bool BindParameter(int index, short value);
158 
159  virtual bool BindParameter(int index, int value);
160 
161  virtual bool BindParameter(int index, long value);
162  virtual bool BindParameter(int index, unsigned long long value);
163  virtual bool BindParameter(int index, long long value);
164 
165  virtual bool BindParameter(int index, float value);
166  virtual bool BindParameter(int index, double value);
170  virtual bool BindParameter(int index, const char *stringValue);
174  virtual bool BindParameter(int index, const char *stringValue, size_t length);
175 
176  virtual bool BindParameter(int index, const vtkStdString &string);
177 
178  virtual bool BindParameter(int index, vtkVariant var);
184  virtual bool BindParameter(int index, const void *data, size_t length);
188  virtual bool ClearParameterBindings();
189 
200  virtual vtkStdString EscapeString( vtkStdString s, bool addSurroundingQuotes = true );
201 
211  char* EscapeString( const char* src, bool addSurroundingQuotes );
212 
213 protected:
216 
224 
225  char* Query;
227  bool Active;
228 
229 private:
230  vtkSQLQuery(const vtkSQLQuery &) VTK_DELETE_FUNCTION;
231  void operator=(const vtkSQLQuery &) VTK_DELETE_FUNCTION;
232 };
233 
234 #endif // vtkSQLQuery_h
235 
a simple class to control print indentation
Definition: vtkIndent.h:40
abstract interface for queries that return row-oriented results.
Definition: vtkRowQuery.h:63
maintain a connection to an sql database
executes an sql query and retrieves results
Definition: vtkSQLQuery.h:75
char * Query
Definition: vtkSQLQuery.h:225
virtual bool BindParameter(int index, unsigned char value)
Bind a parameter to a placeholder in a query.
virtual bool BindParameter(int index, const char *stringValue, size_t length)
Bind a string value by specifying an array and a size.
virtual bool BindParameter(int index, float value)
virtual bool CommitTransaction()
Definition: vtkSQLQuery.h:110
virtual bool BindParameter(int index, const void *data, size_t length)
Bind a blob value.
virtual const char * GetQuery()
virtual bool BeginTransaction()
Begin, commit, or roll back a transaction.
Definition: vtkSQLQuery.h:109
virtual bool BindParameter(int index, long long value)
virtual bool BindParameter(int index, long value)
virtual bool BindParameter(int index, int value)
virtual bool BindParameter(int index, unsigned long value)
bool IsActive()
Return true if the query is active (i.e.
Definition: vtkSQLQuery.h:95
virtual bool BindParameter(int index, signed char value)
void SetDatabase(vtkSQLDatabase *db)
Set the database associated with the query.
virtual bool BindParameter(int index, unsigned long long value)
virtual bool BindParameter(int index, vtkVariant var)
char * EscapeString(const char *src, bool addSurroundingQuotes)
Escape a string for inclusion into an SQL query.
virtual bool BindParameter(int index, short value)
virtual bool BindParameter(int index, const char *stringValue)
Bind a string value – string must be null-terminated.
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
virtual bool Execute()=0
Execute the query.
virtual bool ClearParameterBindings()
Reset all parameter bindings to NULL.
vtkSQLDatabase * Database
Definition: vtkSQLQuery.h:226
virtual bool RollbackTransaction()
Definition: vtkSQLQuery.h:111
virtual bool BindParameter(int index, const vtkStdString &string)
virtual bool SetQuery(const char *query)
The query string to be executed.
virtual bool BindParameter(int index, unsigned int value)
virtual bool BindParameter(int index, double value)
virtual bool BindParameter(int index, unsigned short value)
virtual vtkStdString EscapeString(vtkStdString s, bool addSurroundingQuotes=true)
Escape a string for inclusion into an SQL query.
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:49
An array holding vtkVariants.
A atomic type representing the union of many types.
Definition: vtkVariant.h:76
@ length
Definition: vtkX3D.h:393
@ value
Definition: vtkX3D.h:220
@ index
Definition: vtkX3D.h:246
@ data
Definition: vtkX3D.h:315