VTK  9.3.1
vtkSQLQuery.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-FileCopyrightText: Copyright 2008 Sandia Corporation
3 // SPDX-License-Identifier: LicenseRef-BSD-3-Clause-Sandia-USGov
47 #ifndef vtkSQLQuery_h
48 #define vtkSQLQuery_h
49 
50 #include "vtkIOSQLModule.h" // For export macro
51 #include "vtkRowQuery.h"
52 #include "vtkStdString.h" // for EscapeString()
53 
54 VTK_ABI_NAMESPACE_BEGIN
55 class vtkSQLDatabase;
56 class vtkVariant;
57 class vtkVariantArray;
58 
59 class VTKIOSQL_EXPORT vtkSQLQuery : public vtkRowQuery
60 {
61 public:
62  vtkTypeMacro(vtkSQLQuery, vtkRowQuery);
63  void PrintSelf(ostream& os, vtkIndent indent) override;
64 
66 
71  virtual bool SetQuery(const char* query);
72  virtual const char* GetQuery();
74 
80  bool IsActive() override { return this->Active; }
81 
87  bool Execute() override = 0;
88 
94  virtual bool BeginTransaction() { return true; }
95  virtual bool CommitTransaction() { return true; }
96  virtual bool RollbackTransaction() { return true; }
97 
99 
102  vtkGetObjectMacro(Database, vtkSQLDatabase);
104 
134  virtual bool BindParameter(int index, unsigned char value);
135  virtual bool BindParameter(int index, unsigned short value);
136  virtual bool BindParameter(int index, unsigned int value);
137  virtual bool BindParameter(int index, unsigned long value);
138  // The C and C++ standards leave it up to each compiler to decide
139  // whether chars are signed or unsigned by default. All the other
140  // types are signed unless otherwise specified.
141  virtual bool BindParameter(int index, signed char value);
142  virtual bool BindParameter(int index, short value);
143 
144  virtual bool BindParameter(int index, int value);
145 
146  virtual bool BindParameter(int index, long value);
147  virtual bool BindParameter(int index, unsigned long long value);
148  virtual bool BindParameter(int index, long long value);
149 
150  virtual bool BindParameter(int index, float value);
151  virtual bool BindParameter(int index, double value);
155  virtual bool BindParameter(int index, const char* stringValue);
159  virtual bool BindParameter(int index, const char* stringValue, size_t length);
160 
161  virtual bool BindParameter(int index, const vtkStdString& string);
162 
163  virtual bool BindParameter(int index, vtkVariant var);
169  virtual bool BindParameter(int index, const void* data, size_t length);
173  virtual bool ClearParameterBindings();
174 
185  virtual vtkStdString EscapeString(vtkStdString s, bool addSurroundingQuotes = true);
186 
196  char* EscapeString(const char* src, bool addSurroundingQuotes);
197 
198 protected:
199  vtkSQLQuery();
200  ~vtkSQLQuery() override;
201 
208  void SetDatabase(vtkSQLDatabase* db);
209 
210  char* Query;
212  bool Active;
213 
214 private:
215  vtkSQLQuery(const vtkSQLQuery&) = delete;
216  void operator=(const vtkSQLQuery&) = delete;
217 };
218 
219 VTK_ABI_NAMESPACE_END
220 #endif // vtkSQLQuery_h
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:28
An array holding vtkVariants.
bool IsActive() override
Return true if the query is active (i.e.
Definition: vtkSQLQuery.h:80
virtual bool CommitTransaction()
Definition: vtkSQLQuery.h:95
char * Query
Definition: vtkSQLQuery.h:210
abstract interface for queries that return row-oriented results.
Definition: vtkRowQuery.h:47
A type representing the union of many types.
Definition: vtkVariant.h:52
maintain a connection to an sql database
a simple class to control print indentation
Definition: vtkIndent.h:28
virtual bool RollbackTransaction()
Definition: vtkSQLQuery.h:96
virtual bool BeginTransaction()
Begin, commit, or roll back a transaction.
Definition: vtkSQLQuery.h:94
vtkSQLDatabase * Database
Definition: vtkSQLQuery.h:211
virtual bool Execute()=0
Execute the query.
executes an sql query and retrieves results
Definition: vtkSQLQuery.h:59
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.