VTK  9.3.1
vtkMySQLQuery.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
24 #ifndef vtkMySQLQuery_h
25 #define vtkMySQLQuery_h
26 
27 #include "vtkIOMySQLModule.h" // For export macro
28 #include "vtkSQLQuery.h"
29 
30 VTK_ABI_NAMESPACE_BEGIN
31 class vtkMySQLDatabase;
32 class vtkVariant;
33 class vtkVariantArray;
34 class vtkMySQLQueryInternals;
35 
36 class VTKIOMYSQL_EXPORT vtkMySQLQuery : public vtkSQLQuery
37 {
38 
39  friend class vtkMySQLDatabase;
40 
41 public:
42  vtkTypeMacro(vtkMySQLQuery, vtkSQLQuery);
43  void PrintSelf(ostream& os, vtkIndent indent) override;
44  static vtkMySQLQuery* New();
45 
50  bool SetQuery(const char* query) override;
51 
57  bool Execute() override;
58 
60 
66  bool BeginTransaction() override;
67  bool CommitTransaction() override;
68  bool RollbackTransaction() override;
70 
74  int GetNumberOfFields() override;
75 
79  const char* GetFieldName(int i) override;
80 
84  int GetFieldType(int i) override;
85 
89  bool NextRow() override;
90 
94  bool HasError() override;
95 
99  vtkVariant DataValue(vtkIdType c) override;
100 
104  const char* GetLastErrorText() override;
105 
115  bool BindParameter(int index, unsigned char value) override;
116  bool BindParameter(int index, signed char value) override;
117  bool BindParameter(int index, unsigned short value) override;
118  bool BindParameter(int index, signed short value) override;
119  bool BindParameter(int index, unsigned int value) override;
120 
121  bool BindParameter(int index, int value) override;
122 
123  bool BindParameter(int index, unsigned long value) override;
124  bool BindParameter(int index, signed long value) override;
125  bool BindParameter(int index, unsigned long long value) override;
126  bool BindParameter(int index, long long value) override;
127 
128  bool BindParameter(int index, float value) override;
129  bool BindParameter(int index, double value) override;
133  bool BindParameter(int index, const char* stringValue) override;
135 
138  bool BindParameter(int index, const char* stringValue, size_t length) override;
139  bool BindParameter(int index, const vtkStdString& string) override;
141 
143 
148  bool BindParameter(int index, const void* data, size_t length) override;
149  bool ClearParameterBindings() override;
151 
155  vtkStdString EscapeString(vtkStdString src, bool addSurroundingQuotes = true) override;
156 
157 protected:
158  vtkMySQLQuery();
159  ~vtkMySQLQuery() override;
160 
161  vtkSetStringMacro(LastErrorText);
162 
163 private:
164  vtkMySQLQuery(const vtkMySQLQuery&) = delete;
165  void operator=(const vtkMySQLQuery&) = delete;
166 
167  vtkMySQLQueryInternals* Internals;
168  bool InitialFetch;
169  char* LastErrorText;
170 };
171 
172 VTK_ABI_NAMESPACE_END
173 #endif // vtkMySQLQuery_h
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:28
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:95
int vtkIdType
Definition: vtkType.h:315
virtual vtkStdString EscapeString(vtkStdString s, bool addSurroundingQuotes=true)
Escape a string for inclusion into an SQL query.
A type representing the union of many types.
Definition: vtkVariant.h:52
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:28
virtual int GetNumberOfFields()=0
The number of fields in the query result.
virtual bool RollbackTransaction()
Definition: vtkSQLQuery.h:96
virtual bool BeginTransaction()
Begin, commit, or roll back a transaction.
Definition: vtkSQLQuery.h:94
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:59
virtual const char * GetLastErrorText()=0
Get the last error text from the query.
vtkSQLQuery implementation for MySQL databases
Definition: vtkMySQLQuery.h:36
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...