VTK
vtkMySQLQuery.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkMySQLQuery.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 =========================================================================*/
36 #ifndef vtkMySQLQuery_h
37 #define vtkMySQLQuery_h
38 
39 #include "vtkIOMySQLModule.h" // For export macro
40 #include "vtkSQLQuery.h"
41 
42 class vtkMySQLDatabase;
43 class vtkVariant;
44 class vtkVariantArray;
45 class vtkMySQLQueryInternals;
46 
47 class VTKIOMYSQL_EXPORT vtkMySQLQuery : public vtkSQLQuery
48 {
49 
50  friend class vtkMySQLDatabase;
51 
52 public:
53  vtkTypeMacro(vtkMySQLQuery, vtkSQLQuery);
54  void PrintSelf(ostream& os, vtkIndent indent) override;
55  static vtkMySQLQuery *New();
56 
61  bool SetQuery(const char *query) override;
62 
68  bool Execute() override;
69 
71 
77  bool BeginTransaction() override;
78  bool CommitTransaction() override;
79  bool RollbackTransaction() override;
81 
85  int GetNumberOfFields() override;
86 
90  const char* GetFieldName(int i) override;
91 
95  int GetFieldType(int i) override;
96 
100  bool NextRow() override;
101 
105  bool HasError() override;
106 
110  vtkVariant DataValue(vtkIdType c) override;
111 
115  const char* GetLastErrorText() override;
116 
126  bool BindParameter(int index, unsigned char value) override;
127  bool BindParameter(int index, signed char value) override;
128  bool BindParameter(int index, unsigned short value) override;
129  bool BindParameter(int index, signed short value) override;
130  bool BindParameter(int index, unsigned int value) override;
131 
132  bool BindParameter(int index, int value) override;
133 
134  bool BindParameter(int index, unsigned long value) override;
135  bool BindParameter(int index, signed long value) override;
136  bool BindParameter(int index, unsigned long long value) override;
137  bool BindParameter(int index, long long value) override;
138 
139  bool BindParameter(int index, float value) override;
140  bool BindParameter(int index, double value) override;
144  bool BindParameter(int index, const char *stringValue) override;
146 
149  bool BindParameter(int index, const char *stringValue, size_t length) override;
150  bool BindParameter(int index, const vtkStdString &string) override;
152 
154 
159  bool BindParameter(int index, const void *data, size_t length) override;
160  bool ClearParameterBindings() override;
162 
166  vtkStdString EscapeString( vtkStdString src, bool addSurroundingQuotes = true ) override;
167 
168 protected:
169  vtkMySQLQuery();
170  ~vtkMySQLQuery();
171 
172  vtkSetStringMacro(LastErrorText);
173 
174 private:
175  vtkMySQLQuery(const vtkMySQLQuery &) = delete;
176  void operator=(const vtkMySQLQuery &) = delete;
177 
178  vtkMySQLQueryInternals *Internals;
179  bool InitialFetch;
180  char *LastErrorText;
181 };
182 
183 #endif // vtkMySQLQuery_h
184 
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual bool SetQuery(const char *query)
The query string to be executed.
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:40
virtual bool NextRow()=0
Advance row, return false if past end.
An array holding vtkVariants.
bool Execute() override=0
Execute the query.
virtual const char * GetFieldName(int i)=0
Return the name of the specified query field.
virtual bool BindParameter(int index, unsigned char value)
Bind a parameter to a placeholder in a query.
virtual bool CommitTransaction()
Definition: vtkSQLQuery.h:110
int vtkIdType
Definition: vtkType.h:347
virtual vtkStdString EscapeString(vtkStdString s, bool addSurroundingQuotes=true)
Escape a string for inclusion into an SQL query.
A atomic type representing the union of many types.
Definition: vtkVariant.h:71
virtual bool HasError()=0
Returns true if an error is set, otherwise false.
maintain a connection to a MySQL database
friend class vtkMySQLQuery
a simple class to control print indentation
Definition: vtkIndent.h:39
virtual int GetNumberOfFields()=0
The number of fields in the query result.
virtual bool RollbackTransaction()
Definition: vtkSQLQuery.h:111
virtual bool BeginTransaction()
Begin, commit, or roll back a transaction.
Definition: vtkSQLQuery.h:109
virtual int GetFieldType(int i)=0
Return the type of the field, using the constants defined in vtkType.h.
virtual bool ClearParameterBindings()
Reset all parameter bindings to nullptr.
virtual vtkVariant DataValue(vtkIdType c)=0
Return data in current row, field c.
executes an sql query and retrieves results
Definition: vtkSQLQuery.h:74
virtual const char * GetLastErrorText()=0
Get the last error text from the query.
vtkSQLQuery implementation for MySQL databases
Definition: vtkMySQLQuery.h:47
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...