VTK  9.4.20241013
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
54VTK_ABI_NAMESPACE_BEGIN
55class vtkSQLDatabase;
56class vtkVariant;
57class vtkVariantArray;
58
59class VTKIOSQL_EXPORT vtkSQLQuery : public vtkRowQuery
60{
61public:
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);
174
185 virtual vtkStdString EscapeString(vtkStdString s, bool addSurroundingQuotes = true);
186
196 char* EscapeString(const char* src, bool addSurroundingQuotes);
197
198protected:
200 ~vtkSQLQuery() override;
201
209
210 char* Query;
212 bool Active;
213
214private:
215 vtkSQLQuery(const vtkSQLQuery&) = delete;
216 void operator=(const vtkSQLQuery&) = delete;
217};
218
219VTK_ABI_NAMESPACE_END
220#endif // vtkSQLQuery_h
a simple class to control print indentation
Definition vtkIndent.h:108
abstract interface for queries that return row-oriented results.
Definition vtkRowQuery.h:48
maintain a connection to an sql database
executes an sql query and retrieves results
Definition vtkSQLQuery.h:60
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:95
virtual bool BindParameter(int index, const void *data, size_t length)
Bind a blob value.
virtual bool BeginTransaction()
Begin, commit, or roll back a transaction.
Definition vtkSQLQuery.h:94
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)
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)
bool Execute() override=0
Execute the query.
virtual bool BindParameter(int index, vtkVariant var)
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
~vtkSQLQuery() override
virtual bool BindParameter(int index, short value)
virtual bool BindParameter(int index, const char *stringValue)
Bind a string value – string must be null-terminated.
virtual bool ClearParameterBindings()
Reset all parameter bindings to nullptr.
char * EscapeString(const char *src, bool addSurroundingQuotes)
Escape a string for inclusion into an SQL query.
bool IsActive() override
Return true if the query is active (i.e.
Definition vtkSQLQuery.h:80
vtkSQLDatabase * Database
virtual bool RollbackTransaction()
Definition vtkSQLQuery.h:96
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 const char * GetQuery()
The query string to be executed.
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.
An array holding vtkVariants.
A type representing the union of many types.
Definition vtkVariant.h:162