VTK
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 -------------------------------------------------------------------------*/
46 #ifndef vtkSQLiteDatabase_h
47 #define vtkSQLiteDatabase_h
48 
49 #include "vtkIOSQLModule.h" // For export macro
50 #include "vtkSQLDatabase.h"
51 
52 class vtkSQLQuery;
53 class vtkSQLiteQuery;
54 class vtkStringArray;
55 struct vtk_sqlite3;
56 
57 class VTKIOSQL_EXPORT vtkSQLiteDatabase : public vtkSQLDatabase
58 {
59 
60  friend class vtkSQLiteQuery;
61 
62 public:
64  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
65  static vtkSQLiteDatabase *New();
66 
67  enum {
71  CREATE
72  };
73 
75 
84  bool Open(const char* password) VTK_OVERRIDE;
85  bool Open(const char* password, int mode);
87 
91  void Close() VTK_OVERRIDE;
92 
96  bool IsOpen() VTK_OVERRIDE;
97 
101  vtkSQLQuery* GetQueryInstance() VTK_OVERRIDE;
102 
106  vtkStringArray* GetTables() VTK_OVERRIDE;
107 
111  vtkStringArray* GetRecord(const char *table) VTK_OVERRIDE;
112 
116  bool IsSupported(int feature) VTK_OVERRIDE;
117 
121  bool HasError() VTK_OVERRIDE;
122 
126  const char* GetLastErrorText() VTK_OVERRIDE;
127 
129 
132  const char* GetDatabaseType() VTK_OVERRIDE
133  {
134  return this->DatabaseType;
135  }
137 
139 
142  vtkGetStringMacro(DatabaseFileName);
143  vtkSetStringMacro(DatabaseFileName);
145 
149  vtkStdString GetURL() VTK_OVERRIDE;
150 
157  vtkStdString GetColumnSpecification( vtkSQLDatabaseSchema* schema,
158  int tblHandle,
159  int colHandle ) VTK_OVERRIDE;
160 
161 protected:
163  ~vtkSQLiteDatabase() VTK_OVERRIDE;
164 
170  bool ParseURL(const char* url) VTK_OVERRIDE;
171 
172 private:
173  vtk_sqlite3 *SQLiteInstance;
174 
175  // We want this to be private, a user of this class
176  // should not be setting this for any reason
177  vtkSetStringMacro(DatabaseType);
178 
179  vtkStringArray *Tables;
180 
181  char* DatabaseType;
182  char* DatabaseFileName;
183 
184  vtkStdString TempURL;
185 
186  vtkSQLiteDatabase(const vtkSQLiteDatabase &) VTK_DELETE_FUNCTION;
187  void operator=(const vtkSQLiteDatabase &) VTK_DELETE_FUNCTION;
188 };
189 
190 #endif // vtkSQLiteDatabase_h
191 
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:41
virtual bool Open(const char *password)=0
Open a new connection to the database.
maintain a connection to an SQLite database
a vtkAbstractArray subclass for strings
virtual vtkStdString GetURL()=0
Get the URL of the database.
represent an SQL database schema
const char * GetLastErrorText() override
Get the last error text from the query.
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:33
vtkGetStringMacro(ExtensionsString)
Returns a string listing all available extensions.
bool HasError() override
Return true if there is an error on the current query.
executes an sql query and retrieves results
Definition: vtkSQLQuery.h:68
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...