VTK  9.1.0
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-------------------------------------------------------------------------*/
57#ifndef vtkSQLQuery_h
58#define vtkSQLQuery_h
59
60#include "vtkIOSQLModule.h" // For export macro
61#include "vtkRowQuery.h"
62#include "vtkStdString.h" // for EscapeString()
63
64class vtkSQLDatabase;
65class vtkVariant;
66class vtkVariantArray;
67
68class VTKIOSQL_EXPORT vtkSQLQuery : public vtkRowQuery
69{
70public:
71 vtkTypeMacro(vtkSQLQuery, vtkRowQuery);
72 void PrintSelf(ostream& os, vtkIndent indent) override;
73
75
80 virtual bool SetQuery(const char* query);
81 virtual const char* GetQuery();
83
89 bool IsActive() override { return this->Active; }
90
96 bool Execute() override = 0;
97
103 virtual bool BeginTransaction() { return true; }
104 virtual bool CommitTransaction() { return true; }
105 virtual bool RollbackTransaction() { return true; }
106
108
111 vtkGetObjectMacro(Database, vtkSQLDatabase);
113
143 virtual bool BindParameter(int index, unsigned char value);
144 virtual bool BindParameter(int index, unsigned short value);
145 virtual bool BindParameter(int index, unsigned int value);
146 virtual bool BindParameter(int index, unsigned long value);
147 // The C and C++ standards leave it up to each compiler to decide
148 // whether chars are signed or unsigned by default. All the other
149 // types are signed unless otherwise specified.
150 virtual bool BindParameter(int index, signed char value);
151 virtual bool BindParameter(int index, short value);
152
153 virtual bool BindParameter(int index, int value);
154
155 virtual bool BindParameter(int index, long value);
156 virtual bool BindParameter(int index, unsigned long long value);
157 virtual bool BindParameter(int index, long long value);
158
159 virtual bool BindParameter(int index, float value);
160 virtual bool BindParameter(int index, double value);
164 virtual bool BindParameter(int index, const char* stringValue);
168 virtual bool BindParameter(int index, const char* stringValue, size_t length);
169
170 virtual bool BindParameter(int index, const vtkStdString& string);
171
172 virtual bool BindParameter(int index, vtkVariant var);
178 virtual bool BindParameter(int index, const void* data, size_t length);
183
194 virtual vtkStdString EscapeString(vtkStdString s, bool addSurroundingQuotes = true);
195
205 char* EscapeString(const char* src, bool addSurroundingQuotes);
206
207protected:
209 ~vtkSQLQuery() override;
210
218
219 char* Query;
221 bool Active;
222
223private:
224 vtkSQLQuery(const vtkSQLQuery&) = delete;
225 void operator=(const vtkSQLQuery&) = delete;
226};
227
228#endif // vtkSQLQuery_h
a simple class to control print indentation
Definition: vtkIndent.h:113
abstract interface for queries that return row-oriented results.
Definition: vtkRowQuery.h:63
maintain a connection to an sql database
executes an sql query and retrieves results
Definition: vtkSQLQuery.h:69
char * Query
Definition: vtkSQLQuery.h:219
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:104
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:103
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:89
vtkSQLDatabase * Database
Definition: vtkSQLQuery.h:220
virtual bool RollbackTransaction()
Definition: vtkSQLQuery.h:105
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.
Definition: vtkStdString.h:105
An array holding vtkVariants.
A atomic type representing the union of many types.
Definition: vtkVariant.h:145
@ length
Definition: vtkX3D.h:399
@ value
Definition: vtkX3D.h:226
@ index
Definition: vtkX3D.h:252
@ data
Definition: vtkX3D.h:321