OpenASIP  2.0
SQLiteConnection.hh
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2014 Tampere University.
3 
4  This file is part of TTA-Based Codesign Environment (TCE).
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23  */
24 /**
25  * @file SQLiteConnection.hh
26  *
27  * Class definition of SQLiteConnection class.
28  *
29  * @author Pekka Jääskeläinen 2004 (pekka.jaaskelainen-no.spam-tut.fi)
30  *
31  * @note rating: red
32  */
33 
34 #ifndef TTA_SQLITE_CONNECTION_HH
35 #define TTA_SQLITE_CONNECTION_HH
36 
37 #include <string>
38 #include "sqlite3.h"
39 
40 #include "FileSystem.hh"
42 #include "Exception.hh"
43 
44 /**
45  * Implementation of RelationalDBConnection interface for SQLite library.
46  */
48 public:
49  SQLiteConnection(sqlite3* connection);
50  virtual ~SQLiteConnection();
51 
52  virtual int updateQuery(const std::string& queryString);
53  virtual void DDLQuery(const std::string& queryString);
55  const std::string& queryString, bool init = true);
56 
57  virtual void beginTransaction();
58  virtual void rollback();
59  virtual void commit();
60 
61  virtual RowID lastInsertRowID();
62 
63  virtual bool tableExistsInDB(const std::string& tableName);
64 
65  virtual int rowCountInTable(const std::string& tableName);
66 
67  void throwIfSQLiteError(int result);
68 
69  void finalizeQuery(sqlite3_stmt* statement);
70 
71  virtual int version();
72  virtual void updateVersion(int version);
73 
74 private:
75  sqlite3_stmt* compileQuery(const std::string& queryString);
76 
77  /// SQLite connection handle is saved to this
78  sqlite3* connection_;
79 
81 };
82 
83 #endif
84 
SQLiteConnection::rollback
virtual void rollback()
Definition: SQLiteConnection.cc:139
SQLiteConnection::commit
virtual void commit()
Definition: SQLiteConnection.cc:151
RelationalDBConnection
Definition: RelationalDBConnection.hh:48
SQLiteConnection::rowCountInTable
virtual int rowCountInTable(const std::string &tableName)
Definition: SQLiteConnection.cc:218
FileSystem.hh
Exception.hh
SQLiteConnection::transactionActive_
bool transactionActive_
Definition: SQLiteConnection.hh:80
SQLiteConnection::compileQuery
sqlite3_stmt * compileQuery(const std::string &queryString)
Definition: SQLiteConnection.cc:270
SQLiteConnection::DDLQuery
virtual void DDLQuery(const std::string &queryString)
Definition: SQLiteConnection.cc:98
RowID
int RowID
Type definition of row ID in relational databases.
Definition: DBTypes.hh:37
SQLiteConnection::~SQLiteConnection
virtual ~SQLiteConnection()
Definition: SQLiteConnection.cc:54
SQLiteConnection::beginTransaction
virtual void beginTransaction()
Definition: SQLiteConnection.cc:124
SQLiteConnection::version
virtual int version()
Definition: SQLiteConnection.cc:305
SQLiteConnection::query
virtual RelationalDBQueryResult * query(const std::string &queryString, bool init=true)
Definition: SQLiteConnection.cc:110
SQLiteConnection::throwIfSQLiteError
void throwIfSQLiteError(int result)
Definition: SQLiteConnection.cc:253
SQLiteConnection::updateQuery
virtual int updateQuery(const std::string &queryString)
Definition: SQLiteConnection.cc:69
RelationalDBQueryResult
Definition: RelationalDBQueryResult.hh:46
SQLiteConnection::finalizeQuery
void finalizeQuery(sqlite3_stmt *statement)
Definition: SQLiteConnection.cc:291
SQLiteConnection::lastInsertRowID
virtual RowID lastInsertRowID()
Definition: SQLiteConnection.cc:162
RelationalDBConnection.hh
SQLiteConnection::connection_
sqlite3 * connection_
SQLite connection handle is saved to this.
Definition: SQLiteConnection.hh:78
SQLiteConnection::updateVersion
virtual void updateVersion(int version)
Definition: SQLiteConnection.cc:335
SQLiteConnection::SQLiteConnection
SQLiteConnection(sqlite3 *connection)
Definition: SQLiteConnection.cc:45
SQLiteConnection::tableExistsInDB
virtual bool tableExistsInDB(const std::string &tableName)
Definition: SQLiteConnection.cc:177
SQLiteConnection
Definition: SQLiteConnection.hh:47