VTK  9.7.20260724
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
46
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#include "vtkVariant.h" // For vtkVariant
54
55VTK_ABI_NAMESPACE_BEGIN
56class vtkSQLDatabase;
57class vtkVariant;
58class vtkVariantArray;
59
60class VTKIOSQL_EXPORT vtkSQLQuery : public vtkRowQuery
61{
62public:
63 vtkTypeMacro(vtkSQLQuery, vtkRowQuery);
64 void PrintSelf(ostream& os, vtkIndent indent) override;
65
67
72 virtual bool SetQuery(const char* query);
73 virtual const char* GetQuery();
75
81 bool IsActive() override { return this->Active; }
82
88 bool Execute() override = 0;
89
95 virtual bool BeginTransaction() { return true; }
96 virtual bool CommitTransaction() { return true; }
97 virtual bool RollbackTransaction() { return true; }
98
100
103 vtkGetObjectMacro(Database, vtkSQLDatabase);
105
134
135 virtual bool BindParameter(int index, unsigned char value);
136 virtual bool BindParameter(int index, unsigned short value);
137 virtual bool BindParameter(int index, unsigned int value);
138 virtual bool BindParameter(int index, unsigned long value);
139 // The C and C++ standards leave it up to each compiler to decide
140 // whether chars are signed or unsigned by default. All the other
141 // types are signed unless otherwise specified.
142 virtual bool BindParameter(int index, signed char value);
143 virtual bool BindParameter(int index, short value);
144
145 virtual bool BindParameter(int index, int value);
146
147 virtual bool BindParameter(int index, long value);
148 virtual bool BindParameter(int index, unsigned long long value);
149 virtual bool BindParameter(int index, long long value);
150
151 virtual bool BindParameter(int index, float value);
152 virtual bool BindParameter(int index, double value);
156 virtual bool BindParameter(int index, const char* stringValue);
160 virtual bool BindParameter(int index, const char* stringValue, size_t length);
161
162 virtual bool BindParameter(int index, const vtkStdString& string);
163
164 virtual bool BindParameter(int index, vtkVariant var);
170 virtual bool BindParameter(int index, const void* data, size_t length);
175
186 virtual vtkStdString EscapeString(vtkStdString s, bool addSurroundingQuotes = true);
187
197 char* EscapeString(const char* src, bool addSurroundingQuotes);
198
199protected:
201 ~vtkSQLQuery() override;
202
210
211 char* Query;
213 bool Active;
214
215private:
216 vtkSQLQuery(const vtkSQLQuery&) = delete;
217 void operator=(const vtkSQLQuery&) = delete;
218};
219
220VTK_ABI_NAMESPACE_END
221#endif // vtkSQLQuery_h
a simple class to control print indentation
Definition vtkIndent.h:108
maintain a connection to an sql database
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:96
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:95
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:81
vtkSQLDatabase * Database
virtual bool RollbackTransaction()
Definition vtkSQLQuery.h:97
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