VTK  9.2.6
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-------------------------------------------------------------------------*/
62
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
70class vtkSQLDatabase;
71class vtkVariant;
72class vtkVariantArray;
73
74class VTKIOSQL_EXPORT vtkSQLQuery : public vtkRowQuery
75{
76public:
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
148
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);
189
200 virtual vtkStdString EscapeString(vtkStdString s, bool addSurroundingQuotes = true);
201
211 char* EscapeString(const char* src, bool addSurroundingQuotes);
212
213protected:
215 ~vtkSQLQuery() override;
216
224
225 char* Query;
227 bool Active;
228
229private:
230 vtkSQLQuery(const vtkSQLQuery&) = delete;
231 void operator=(const vtkSQLQuery&) = delete;
232};
233
234#endif // vtkSQLQuery_h
a simple class to control print indentation
Definition vtkIndent.h:40
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()
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.
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:95
vtkSQLDatabase * Database
virtual bool RollbackTransaction()
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 atomic type representing the union of many types.
Definition vtkVariant.h:70