mirror of
https://github.com/cuberite/SQLiteCpp.git
synced 2025-08-04 17:56:13 -04:00
Added a copy constructor that increments the reference counter, thanks to a patch from Mark P.
This commit is contained in:
parent
0055fcc2db
commit
554a79b64d
@ -16,10 +16,22 @@ namespace SQLite
|
|||||||
|
|
||||||
// Encapsulation of a Column in a Row of the result.
|
// Encapsulation of a Column in a Row of the result.
|
||||||
Column::Column(sqlite3* apSQLite, sqlite3_stmt* apStmt, unsigned int* apStmtRefCount, int aIndex) throw() : // nothrow
|
Column::Column(sqlite3* apSQLite, sqlite3_stmt* apStmt, unsigned int* apStmtRefCount, int aIndex) throw() : // nothrow
|
||||||
mpSQLite(apSQLite),
|
mpSQLite (apSQLite),
|
||||||
mpStmt(apStmt),
|
mpStmt (apStmt),
|
||||||
mpStmtRefCount(apStmtRefCount),
|
mpStmtRefCount (apStmtRefCount),
|
||||||
mIndex(aIndex)
|
mIndex (aIndex)
|
||||||
|
{
|
||||||
|
// Increment the reference counter of the sqlite3_stmt,
|
||||||
|
// telling the Statement object not to finalize the sqlite3_stmt during the lifetime of this Column objet
|
||||||
|
(*mpStmtRefCount)++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy constructor
|
||||||
|
Column::Column(const Column& copy) throw() : // nothrow
|
||||||
|
mpSQLite (copy.mpSQLite),
|
||||||
|
mpStmt (copy.mpStmt),
|
||||||
|
mpStmtRefCount (copy.mpStmtRefCount),
|
||||||
|
mIndex (copy.mIndex)
|
||||||
{
|
{
|
||||||
// Increment the reference counter of the sqlite3_stmt,
|
// Increment the reference counter of the sqlite3_stmt,
|
||||||
// telling the Statement object not to finalize the sqlite3_stmt during the lifetime of this Column objet
|
// telling the Statement object not to finalize the sqlite3_stmt during the lifetime of this Column objet
|
||||||
|
@ -30,8 +30,11 @@ public:
|
|||||||
* @brief Compile and register the SQL query for the provided SQLite Database Connection
|
* @brief Compile and register the SQL query for the provided SQLite Database Connection
|
||||||
*/
|
*/
|
||||||
explicit Column(sqlite3* apSQLite, sqlite3_stmt* apStmt, unsigned int* apStmtRefCount, int aIndex) throw(); // nothrow
|
explicit Column(sqlite3* apSQLite, sqlite3_stmt* apStmt, unsigned int* apStmtRefCount, int aIndex) throw(); // nothrow
|
||||||
/// Basic destructor
|
/// Simple destructor
|
||||||
virtual ~Column(void) throw(); // nothrow
|
virtual ~Column(void) throw(); // nothrow
|
||||||
|
|
||||||
|
/// @brief copy constructor : only way to copy a valid instance
|
||||||
|
Column(const Column& aOther) throw(); // nothrow
|
||||||
|
|
||||||
/// Return the integer value of the column.
|
/// Return the integer value of the column.
|
||||||
int getInt (void) const throw();
|
int getInt (void) const throw();
|
||||||
@ -78,9 +81,9 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Column is copyable, but copy should not be used elsewhere than in return form getColumn
|
// Forbid default constructor and assignment operator (no implementation)
|
||||||
|
// so that there is no way of having a Column instance not initialized
|
||||||
Column(void);
|
Column(void);
|
||||||
// TODO Column(const Column&);
|
|
||||||
Column& operator=(const Column&);
|
Column& operator=(const Column&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user