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 -------------------------------------------------------------------------*/
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;
61 struct vtk_sqlite3;
62 
63 class VTKIOSQL_EXPORT vtkSQLiteDatabase : public vtkSQLDatabase
64 {
65 
66  friend class vtkSQLiteQuery;
67 
68 public:
70  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
71  static vtkSQLiteDatabase *New();
72 
73  enum {
77  CREATE
78  };
79 
81 
90  bool Open(const char* password) VTK_OVERRIDE;
91  bool Open(const char* password, int mode);
93 
97  void Close() VTK_OVERRIDE;
98 
102  bool IsOpen() VTK_OVERRIDE;
103 
107  vtkSQLQuery* GetQueryInstance() VTK_OVERRIDE;
108 
112  vtkStringArray* GetTables() VTK_OVERRIDE;
113 
117  vtkStringArray* GetRecord(const char *table) VTK_OVERRIDE;
118 
122  bool IsSupported(int feature) VTK_OVERRIDE;
123 
127  bool HasError() VTK_OVERRIDE;
128 
132  const char* GetLastErrorText() VTK_OVERRIDE;
133 
135 
138  const char* GetDatabaseType() VTK_OVERRIDE
139  {
140  return this->DatabaseType;
141  }
143 
145 
148  vtkGetStringMacro(DatabaseFileName);
149  vtkSetStringMacro(DatabaseFileName);
151 
155  vtkStdString GetURL() VTK_OVERRIDE;
156 
164  int tblHandle,
165  int colHandle ) VTK_OVERRIDE;
166 
167 protected:
169  ~vtkSQLiteDatabase() VTK_OVERRIDE;
170 
176  bool ParseURL(const char* url) VTK_OVERRIDE;
177 
178 private:
179  vtk_sqlite3 *SQLiteInstance;
180 
181  // We want this to be private, a user of this class
182  // should not be setting this for any reason
183  vtkSetStringMacro(DatabaseType);
184 
185  vtkStringArray *Tables;
186 
187  char* DatabaseType;
188  char* DatabaseFileName;
189 
190  vtkStdString TempURL;
191 
192  vtkSQLiteDatabase(const vtkSQLiteDatabase &) VTK_DELETE_FUNCTION;
193  void operator=(const vtkSQLiteDatabase &) VTK_DELETE_FUNCTION;
194 };
195 
196 #endif // vtkSQLiteDatabase_h
197 
friend class vtkSQLiteDatabase
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:40
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 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
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:39
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:74
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...