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) override;
79 
81 
86  virtual bool SetQuery(const char *query);
87  virtual const char *GetQuery();
89 
95  bool IsActive() override { return this->Active; }
96 
102  bool Execute() override = 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:
214  vtkSQLQuery();
215  ~vtkSQLQuery() override;
216 
223  void SetDatabase(vtkSQLDatabase* db);
224 
225  char* Query;
227  bool Active;
228 
229 private:
230  vtkSQLQuery(const vtkSQLQuery &) = delete;
231  void operator=(const vtkSQLQuery &) = delete;
232 };
233 
234 #endif // vtkSQLQuery_h
235 
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:40
An array holding vtkVariants.
bool IsActive() override
Return true if the query is active (i.e.
Definition: vtkSQLQuery.h:95
virtual bool CommitTransaction()
Definition: vtkSQLQuery.h:110
char * Query
Definition: vtkSQLQuery.h:225
abstract interface for queries that return row-oriented results.
Definition: vtkRowQuery.h:62
A atomic type representing the union of many types.
Definition: vtkVariant.h:71
maintain a connection to an sql database
a simple class to control print indentation
Definition: vtkIndent.h:39
virtual bool RollbackTransaction()
Definition: vtkSQLQuery.h:111
virtual bool BeginTransaction()
Begin, commit, or roll back a transaction.
Definition: vtkSQLQuery.h:109
vtkSQLDatabase * Database
Definition: vtkSQLQuery.h:226
virtual bool Execute()=0
Execute the query.
executes an sql query and retrieves results
Definition: vtkSQLQuery.h:74
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.