mirror of
https://github.com/cuberite/SQLiteCpp.git
synced 2025-08-04 09:46:02 -04:00
Removed the Statement registration list, adding unnecessary extra complexity
This commit is contained in:
parent
37f3bd506f
commit
da95147cfa
@ -2,7 +2,7 @@
|
||||
* @file Database.cpp
|
||||
* @brief Management of a SQLite Database Connection.
|
||||
*
|
||||
* Copyright (c) 2012 Sebastien Rombauts (sebastien dot rombauts at gmail dot com)
|
||||
* Copyright (c) 2012 Sebastien Rombauts (sebastien.rombauts@gmail.com)
|
||||
*
|
||||
* Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt
|
||||
* or copy at http://opensource.org/licenses/MIT)
|
||||
@ -31,16 +31,6 @@ Database::Database(const char* apFilename, const int aFlags /*= SQLITE_OPEN_READ
|
||||
// Close the SQLite database connection.
|
||||
Database::~Database(void) throw() // nothrow
|
||||
{
|
||||
// check for undestroyed statements
|
||||
std::vector<Statement*>::iterator iStatement;
|
||||
for (iStatement = mStatementList.begin();
|
||||
iStatement != mStatementList.end();
|
||||
iStatement++)
|
||||
{
|
||||
// TODO (*iStatement)->Finalize(); ?
|
||||
//std::cout << "Unregistered statement: " << (*iStatement)->getQuery().c_str() << " !\n";
|
||||
}
|
||||
|
||||
int ret = sqlite3_close(mpSQLite);
|
||||
if (SQLITE_OK != ret)
|
||||
{
|
||||
@ -49,23 +39,6 @@ Database::~Database(void) throw() // nothrow
|
||||
}
|
||||
}
|
||||
|
||||
// Register a Statement object (a SQLite query)
|
||||
void Database::registerStatement(Statement& aStatement) // throw(SQLite::Exception)
|
||||
{
|
||||
mStatementList.push_back(&aStatement);
|
||||
}
|
||||
|
||||
// Unregister a Statement object
|
||||
void Database::unregisterStatement(Statement& aStatement) // throw(SQLite::Exception)
|
||||
{
|
||||
TStatementList::iterator iStatement;
|
||||
iStatement = std::find(mStatementList.begin(), mStatementList.end(), &aStatement);
|
||||
if (mStatementList.end() != iStatement)
|
||||
{
|
||||
mStatementList.erase(iStatement);
|
||||
}
|
||||
}
|
||||
|
||||
// Shortcut to execute one or multiple SQL statements without results.
|
||||
int Database::exec(const char* apQueries) // throw(SQLite::Exception);
|
||||
{
|
||||
|
@ -2,7 +2,7 @@
|
||||
* @file Database.h
|
||||
* @brief Management of a SQLite Database Connection.
|
||||
*
|
||||
* Copyright (c) 2012 Sebastien Rombauts (sebastien dot rombauts at gmail dot com)
|
||||
* Copyright (c) 2012 Sebastien Rombauts (sebastien.rombauts@gmail.com)
|
||||
*
|
||||
* Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt
|
||||
* or copy at http://opensource.org/licenses/MIT)
|
||||
@ -10,8 +10,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <sqlite3.h>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include "Exception.h"
|
||||
|
||||
namespace SQLite
|
||||
@ -35,9 +33,6 @@ class Database
|
||||
{
|
||||
friend class Statement;
|
||||
|
||||
public:
|
||||
typedef std::vector<Statement*> TStatementList; /// List of statements pointers
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief Open the provided database UTF-8 filename.
|
||||
@ -62,16 +57,6 @@ public:
|
||||
*/
|
||||
virtual ~Database(void) throw(); // nothrow
|
||||
|
||||
/**
|
||||
* @brief Register a Statement object (a SQLite query)
|
||||
*/
|
||||
void registerStatement(Statement& aStatement); // throw(SQLite::Exception);
|
||||
|
||||
/**
|
||||
* @brief Unregister a Statement object
|
||||
*/
|
||||
void unregisterStatement(Statement& aStatement); // throw(SQLite::Exception);
|
||||
|
||||
/**
|
||||
* @brief Shortcut to execute one or multiple statements without results.
|
||||
*
|
||||
@ -91,14 +76,6 @@ public:
|
||||
return mFilename;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief List of registered statements
|
||||
*/
|
||||
inline const TStatementList& getStatementList(void) const
|
||||
{
|
||||
return mStatementList;
|
||||
}
|
||||
|
||||
private:
|
||||
// Database must not be copyable
|
||||
Database(void);
|
||||
@ -113,7 +90,6 @@ private:
|
||||
private:
|
||||
sqlite3* mpSQLite; //!< Pointer to SQLite Database Connection Handle
|
||||
std::string mFilename; //!< UTF-8 filename used to open the database
|
||||
TStatementList mStatementList; //!< List of SQL registered statements used with this database connexion
|
||||
};
|
||||
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
* @file Exception.h
|
||||
* @brief Encapsulation of the error message from SQLite3 on a std::runtime_error.
|
||||
*
|
||||
* Copyright (c) 2012 Sebastien Rombauts (sebastien dot rombauts at gmail dot com)
|
||||
* Copyright (c) 2012 Sebastien Rombauts (sebastien.rombauts@gmail.com)
|
||||
*
|
||||
* Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt
|
||||
* or copy at http://opensource.org/licenses/MIT)
|
||||
|
@ -2,7 +2,7 @@
|
||||
* @file SQLiteC++.h
|
||||
* @brief SQLiteC++ is a smart and simple C++ SQLite3 wrapper. This file is only "easy include" for other files.
|
||||
*
|
||||
* Copyright (c) 2012 Sebastien Rombauts (sebastien dot rombauts at gmail dot com)
|
||||
* Copyright (c) 2012 Sebastien Rombauts (sebastien.rombauts@gmail.com)
|
||||
*
|
||||
* Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt
|
||||
* or copy at http://opensource.org/licenses/MIT)
|
||||
|
@ -2,7 +2,7 @@
|
||||
* @file Statement.cpp
|
||||
* @brief A prepared SQLite Statement is a compiled SQL query ready to be executed.
|
||||
*
|
||||
* Copyright (c) 2012 Sebastien Rombauts (sebastien dot rombauts at gmail dot com)
|
||||
* Copyright (c) 2012 Sebastien Rombauts (sebastien.rombauts@gmail.com)
|
||||
*
|
||||
* Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt
|
||||
* or copy at http://opensource.org/licenses/MIT)
|
||||
@ -26,7 +26,6 @@ Statement::Statement(Database &aDatabase, const char* apQuery) : // throw(SQLite
|
||||
int ret = sqlite3_prepare_v2(mDatabase.mpSQLite, mQuery.c_str(), mQuery.size(), &mpStmt, NULL);
|
||||
check(ret);
|
||||
mColumnCount = sqlite3_column_count(mpStmt);
|
||||
mDatabase.registerStatement(*this);
|
||||
}
|
||||
|
||||
// Finalize and unregister the SQL query from the SQLite Database Connection.
|
||||
@ -39,7 +38,6 @@ Statement::~Statement(void) throw() // nothrow
|
||||
//std::cout << sqlite3_errmsg(mDatabase.mpSQLite);
|
||||
}
|
||||
mpStmt = NULL;
|
||||
mDatabase.unregisterStatement(*this);
|
||||
}
|
||||
|
||||
// Reset the statement to make it ready for a new execution
|
||||
|
@ -2,7 +2,7 @@
|
||||
* @file Statement.h
|
||||
* @brief A prepared SQLite Statement is a compiled SQL query ready to be executed.
|
||||
*
|
||||
* Copyright (c) 2012 Sebastien Rombauts (sebastien dot rombauts at gmail dot com)
|
||||
* Copyright (c) 2012 Sebastien Rombauts (sebastien.rombauts@gmail.com)
|
||||
*
|
||||
* Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt
|
||||
* or copy at http://opensource.org/licenses/MIT)
|
||||
|
@ -2,7 +2,7 @@
|
||||
* @file Transaction.cpp
|
||||
* @brief A prepared SQLite Transaction is a compiled SQL query ready to be executed.
|
||||
*
|
||||
* Copyright (c) 2012 Sebastien Rombauts (sebastien dot rombauts at gmail dot com)
|
||||
* Copyright (c) 2012 Sebastien Rombauts (sebastien.rombauts@gmail.com)
|
||||
*
|
||||
* Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt
|
||||
* or copy at http://opensource.org/licenses/MIT)
|
||||
|
@ -2,7 +2,7 @@
|
||||
* @file Transaction.h
|
||||
* @brief A Transaction is way to group multiple SQL statements into an atomic secured operation.
|
||||
*
|
||||
* Copyright (c) 2012 Sebastien Rombauts (sebastien dot rombauts at gmail dot com)
|
||||
* Copyright (c) 2012 Sebastien Rombauts (sebastien.rombauts@gmail.com)
|
||||
*
|
||||
* Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt
|
||||
* or copy at http://opensource.org/licenses/MIT)
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* Demonstrate how-to use the SQLite++ wrapper
|
||||
*
|
||||
* Copyright (c) 2012 Sebastien Rombauts (sebastien dot rombauts at gmail dot com)
|
||||
* Copyright (c) 2012 Sebastien Rombauts (sebastien.rombauts@gmail.com)
|
||||
*
|
||||
* Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt
|
||||
* or copy at http://opensource.org/licenses/MIT)
|
||||
|
Loading…
x
Reference in New Issue
Block a user