1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
|
/*=========================================================================
Program: Visualization Toolkit
Module: $RCSfile: vtkSQLiteDatabase.h,v $
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
/*----------------------------------------------------------------------------
Copyright (c) Sandia Corporation
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
----------------------------------------------------------------------------*/
// .NAME vtkSQLiteDatabase - maintain a connection to an SQLite database
//
// .SECTION Description
//
// SQLite (http://www.sqlite.org) is a public-domain SQL database
// written in C++. It's small, fast, and can be easily embedded
// inside other applications. Its databases are stored in files.
//
// This class provides a VTK interface to SQLite. You do not need to
// download any external libraries: we include a copy of SQLite 3.3.16
// in VTK/Utilities/vtksqlite.
//
// If you want to open a database that stays in memory and never gets
// written to disk, pass in the filename ':memory:'.
//
// .SECTION Thanks
// Thanks to Andrew Wilson from Sandia National Laboratories for implementing
// this class.
//
// .SECTION See Also
// vtkSQLiteQuery
#ifndef __vtkSQLiteDatabase_h
#define __vtkSQLiteDatabase_h
#include "vtkSQLDatabase.h"
class vtkSQLQuery;
class vtkSQLiteQuery;
class vtkStringArray;
struct vtk_sqlite3;
class VTK_IO_EXPORT vtkSQLiteDatabase : public vtkSQLDatabase
{
//BTX
friend class vtkSQLiteQuery;
//ETX
public:
vtkTypeRevisionMacro(vtkSQLiteDatabase, vtkSQLDatabase);
void PrintSelf(ostream& os, vtkIndent indent);
static vtkSQLiteDatabase *New();
// Description:
// Set/get the name of the file containing the database. SQLite works
// entirely on files and does not have a notion of network
// connections.
vtkSetStringMacro(FileName);
vtkGetStringMacro(FileName);
// Description:
// Open a new connection to the database. You need to set the
// filename before calling this function. Returns true if the
// database was opened successfully; false otherwise.
bool Open();
// Description:
// Close the connection to the database.
void Close();
// Description:
// Return whether the database has an open connection
bool IsOpen();
// Description:
// Return an empty query on this database.
vtkSQLQuery* GetQueryInstance();
// Description:
// Get the last error text from the database
const char* GetLastErrorText();
// Description:
// Get the list of tables from the database
vtkStringArray* GetTables();
// Description:
// Get the list of fields for a particular table
vtkStringArray* GetRecord(const char *table);
// Description:
// Return whether a feature is supported by the database.
bool IsSupported(int feature);
protected:
vtkSQLiteDatabase();
~vtkSQLiteDatabase();
private:
vtk_sqlite3 *SQLiteInstance;
char *FileName;
char *LastErrorText;
vtkSetStringMacro(LastErrorText);
vtkSQLiteDatabase(const vtkSQLiteDatabase &); // Not implemented.
void operator=(const vtkSQLiteDatabase &); // Not implemented.
};
#endif // __vtkSQLiteDatabase_h
|