VTK  9.2.6
vtkSQLiteDatabase.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkSQLiteDatabase.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 -------------------------------------------------------------------------*/
52 #ifndef vtkSQLiteDatabase_h
53 #define vtkSQLiteDatabase_h
54 
55 #include "vtkIOSQLModule.h" // For export macro
56 #include "vtkSQLDatabase.h"
57 
58 class vtkSQLQuery;
59 class vtkSQLiteQuery;
60 class vtkStringArray;
62 
63 class VTKIOSQL_EXPORT vtkSQLiteDatabase : public vtkSQLDatabase
64 {
65 
66  friend class vtkSQLiteQuery;
67 
68 public:
70  void PrintSelf(ostream& os, vtkIndent indent) override;
71  static vtkSQLiteDatabase* New();
72 
73  enum
74  {
78  CREATE
79  };
80 
82 
91  bool Open(const char* password) override;
92  bool Open(const char* password, int mode);
94 
98  void Close() override;
99 
103  bool IsOpen() override;
104 
108  vtkSQLQuery* GetQueryInstance() override;
109 
113  vtkStringArray* GetTables() override;
114 
118  vtkStringArray* GetRecord(const char* table) override;
119 
123  bool IsSupported(int feature) override;
124 
128  bool HasError() override;
129 
133  const char* GetLastErrorText() override;
134 
136 
139  const char* GetDatabaseType() override { return this->DatabaseType; }
141 
143 
146  vtkGetFilePathMacro(DatabaseFileName);
147  vtkSetFilePathMacro(DatabaseFileName);
149 
153  vtkStdString GetURL() override;
154 
164  vtkSQLDatabaseSchema* schema, int tblHandle, int colHandle) override;
165 
166 protected:
168  ~vtkSQLiteDatabase() override;
169 
175  bool ParseURL(const char* url) override;
176 
177 private:
178  vtkSQLiteDatabaseInternals* Internal;
179 
180  // We want this to be private, a user of this class
181  // should not be setting this for any reason
182  vtkSetStringMacro(DatabaseType);
183 
184  vtkStringArray* Tables;
185 
186  char* DatabaseType;
187  char* DatabaseFileName;
188 
189  vtkStdString TempURL;
190 
191  vtkSQLiteDatabase(const vtkSQLiteDatabase&) = delete;
192  void operator=(const vtkSQLiteDatabase&) = delete;
193 };
194 
195 #endif // vtkSQLiteDatabase_h
friend class vtkSQLiteDatabase
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:38
virtual vtkStdString GetColumnSpecification(vtkSQLDatabaseSchema *schema, int tblHandle, int colHandle)
Return the SQL string with the syntax to create a column inside a "CREATE TABLE" SQL statement...
virtual bool IsSupported(int vtkNotUsed(feature))
Return whether a feature is supported by the database.
virtual bool Open(const char *password)=0
Open a new connection to the database.
virtual bool ParseURL(const char *url)=0
Subclasses should override this method to determine connection parameters given the URL...
maintain a connection to an SQLite database
virtual bool HasError()=0
Did the last operation generate an error.
a vtkAbstractArray subclass for strings
virtual vtkStdString GetURL()=0
Get the URL of the database.
represent an SQL database schema
virtual vtkStringArray * GetRecord(const char *table)=0
Get the list of fields for a particular table.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
maintain a connection to an sql database
vtkSQLQuery implementation for SQLite databases
virtual void Close()=0
Close the connection to the database.
a simple class to control print indentation
Definition: vtkIndent.h:39
virtual vtkSQLQuery * GetQueryInstance()=0
Return an empty query on this database.
virtual bool IsOpen()=0
Return whether the database has an open connection.
virtual const char * GetLastErrorText()=0
Get the last error text from the database I'm using const so that people do NOT use the standard vtkG...
executes an sql query and retrieves results
Definition: vtkSQLQuery.h:74
const char * GetDatabaseType() override
String representing database type (e.g.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
virtual vtkStringArray * GetTables()=0
Get the list of tables from the database.