VTK: IO/ODBC/vtkODBCDatabase.h Source File

| VTK 9.3.1

vtkODBCDatabase.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
4
57 #ifndef vtkODBCDatabase_h
58 #define vtkODBCDatabase_h
59
60 #include "vtkIOODBCModule.h" // For export macro
61 #include "vtkSQLDatabase.h"
62
63 VTK_ABI_NAMESPACE_BEGIN
64 class vtkSQLQuery;
65 class vtkODBCQuery;
66 class vtkStringArray;
67 class vtkODBCInternals;
68
69 class VTKIOODBC_EXPORT vtkODBCDatabase : public vtkSQLDatabase
70 {
71
72 friend class vtkODBCQuery;
73
74 public:
75 vtkTypeMacro(vtkODBCDatabase, vtkSQLDatabase);
76 void PrintSelf(ostream& os, vtkIndent indent) override;
77 static vtkODBCDatabase* New();
78
84 bool Open(const char* password) override;
85
89 void Close() override;
90
94 bool IsOpen() override;
95
99 vtkSQLQuery* GetQueryInstance() override;
100
104 const char* GetLastErrorText() override;
105
109 vtkStringArray* GetTables() override;
110
114 vtkStringArray* GetRecord(const char* table) override;
115
119 bool IsSupported(int feature) override;
120
122
127 vtkSetStringMacro(DataSourceName);
128 vtkGetStringMacro(DataSourceName);
130
131 vtkSetMacro(ServerPort, int);
132 vtkSetStringMacro(HostName);
133 vtkSetStringMacro(UserName);
134 vtkSetStringMacro(DatabaseName);
135 vtkGetStringMacro(DatabaseName);
136 vtkSetStringMacro(Password);
137
138 bool HasError() override;
139
141
144 const char* GetDatabaseType() override { return this->DatabaseType; }
146
147 vtkStdString GetURL() override;
148
156 vtkStdString GetColumnSpecification(
157 vtkSQLDatabaseSchema* schema, int tblHandle, int colHandle) override;
158
163 vtkStdString GetIndexSpecification(
164 vtkSQLDatabaseSchema* schema, int tblHandle, int idxHandle, bool& skipped) override;
165
170 bool CreateDatabase(const char* dbName, bool dropExisting);
171
176 bool DropDatabase(const char* dbName);
177
183 bool ParseURL(const char* url) override;
184
185 protected:
186 vtkODBCDatabase();
187 ~vtkODBCDatabase() override;
188
189 vtkSetStringMacro(LastErrorText);
190
191 private:
192 vtkStringArray* Tables;
193 vtkStringArray* Record;
194
195 char* LastErrorText;
196
197 char* HostName;
198 char* UserName;
199 char* Password;
200 char* DataSourceName;
201 char* DatabaseName;
202 int ServerPort;
203
204 vtkODBCInternals* Internals;
205
206 // We want this to be private, a user of this class
207 // should not be setting this for any reason
208 vtkSetStringMacro(DatabaseType);
209
210 char* DatabaseType;
211
212 vtkODBCDatabase(const vtkODBCDatabase&) = delete;
213 void operator=(const vtkODBCDatabase&) = delete;
214 };
215
216 VTK_ABI_NAMESPACE_END
217 #endif // vtkODBCDatabase_h
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:38
vtkODBCDatabase
maintain an ODBC connection to a SQL database
Definition: vtkODBCDatabase.h:70
vtkODBCDatabase::GetColumnSpecification
vtkStdString GetColumnSpecification(vtkSQLDatabaseSchema *schema, int tblHandle, int colHandle) override
Return the SQL string with the syntax to create a column inside a "CREATE TABLE" SQL statement.
vtkODBCDatabase::DropDatabase
bool DropDatabase(const char *dbName)
Drop a database if it exists.
vtkODBCDatabase::GetTables
vtkStringArray * GetTables() override
Get the list of tables from the database.
vtkODBCDatabase::GetRecord
vtkStringArray * GetRecord(const char *table) override
Get the list of fields for a particular table.
vtkODBCDatabase::GetQueryInstance
vtkSQLQuery * GetQueryInstance() override
Return an empty query on this database.
vtkODBCDatabase::GetLastErrorText
const char * GetLastErrorText() override
Get the last error text from the database.
vtkODBCDatabase::HasError
bool HasError() override
Did the last operation generate an error.
vtkODBCDatabase::GetDatabaseType
const char * GetDatabaseType() override
String representing database type (e.g.
Definition: vtkODBCDatabase.h:144
vtkODBCDatabase::GetURL
vtkStdString GetURL() override
Get the URL of the database.
vtkODBCDatabase::Open
bool Open(const char *password) override
Open a new connection to the database.
vtkODBCDatabase::CreateDatabase
bool CreateDatabase(const char *dbName, bool dropExisting)
Create a new database, optionally dropping any existing database of the same name.
vtkODBCDatabase::~vtkODBCDatabase
~vtkODBCDatabase() override
vtkODBCDatabase::IsSupported
bool IsSupported(int feature) override
Return whether a feature is supported by the database.
vtkODBCDatabase::ParseURL
bool ParseURL(const char *url) override
This will only handle URLs of the form odbc://[user@]datsourcename[:port]/[dbname].
vtkODBCDatabase::vtkODBCDatabase
vtkODBCDatabase()
vtkODBCDatabase::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkODBCDatabase::Close
void Close() override
Close the connection to the database.
vtkODBCDatabase::IsOpen
bool IsOpen() override
Return whether the database has an open connection.
vtkODBCDatabase::New
static vtkODBCDatabase * New()
vtkODBCDatabase::GetIndexSpecification
vtkStdString GetIndexSpecification(vtkSQLDatabaseSchema *schema, int tblHandle, int idxHandle, bool &skipped) override
Return the SQL string with the syntax to create an index inside a "CREATE TABLE" SQL statement.
vtkODBCInternals
Simple class to hide ODBC structures.
Definition: vtkODBCInternals.h:26
vtkODBCQuery
vtkSQLQuery implementation for ODBC connections to databases
Definition: vtkODBCQuery.h:32
vtkODBCQuery::vtkODBCDatabase
friend class vtkODBCDatabase
Definition: vtkODBCQuery.h:34
vtkSQLDatabaseSchema
represent an SQL database schema
Definition: vtkSQLDatabaseSchema.h:50
vtkSQLDatabase
maintain a connection to an sql database
Definition: vtkSQLDatabase.h:76
vtkSQLQuery
executes an sql query and retrieves results
Definition: vtkSQLQuery.h:60
vtkStdString
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:38
vtkStringArray
a vtkAbstractArray subclass for strings
Definition: vtkStringArray.h:41
vtkX3D::url
@ url
Definition: vtkX3D.h:233
vtkSQLDatabase.h