Skip to content
Snippets Groups Projects
Commit 68945c8b authored by Steven Murray's avatar Steven Murray
Browse files

Stmt::executeQuery() no longer returns a raw pointer

parent 4f2835d8
No related branches found
No related tags found
No related merge requests found
......@@ -16,10 +16,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "OcciConn.hpp"
#include "OcciRset.hpp"
#include "OcciStmt.hpp"
#include "common/exception/Exception.hpp"
#include "common/make_unique.hpp"
#include "rdbms/OcciConn.hpp"
#include "rdbms/OcciRset.hpp"
#include "rdbms/OcciStmt.hpp"
#include <cstring>
#include <iostream>
......@@ -114,11 +115,11 @@ void OcciStmt::bindString(const std::string &paramName, const std::string &param
//------------------------------------------------------------------------------
// executeQuery
//------------------------------------------------------------------------------
Rset *OcciStmt::executeQuery() {
std::unique_ptr<Rset> OcciStmt::executeQuery() {
using namespace oracle;
try {
return new OcciRset(*this, m_stmt->executeQuery());
return make_unique<OcciRset>(*this, m_stmt->executeQuery());
} catch(exception::Exception &ex) {
throw exception::Exception(std::string(__FUNCTION__) + " failed for SQL statement " + getSql() + ": " +
ex.getMessage().str());
......
......@@ -18,8 +18,8 @@
#pragma once
#include "Stmt.hpp"
#include "ParamNameToIdx.hpp"
#include "rdbms/Stmt.hpp"
#include "rdbms/ParamNameToIdx.hpp"
#include <memory>
#include <mutex>
......@@ -59,7 +59,7 @@ public:
/**
* Destructor.
*/
virtual ~OcciStmt() throw();
virtual ~OcciStmt() throw() override;
/**
* Prevent copying the object.
......@@ -69,14 +69,14 @@ public:
/**
* Idempotent close() method. The destructor calls this method.
*/
virtual void close();
virtual void close() override;
/**
* Returns the SQL statement.
*
* @return The SQL statement.
*/
virtual const std::string &getSql() const;
virtual const std::string &getSql() const override;
/**
* Binds an SQL parameter.
......@@ -84,7 +84,7 @@ public:
* @param paramName The name of the parameter.
* @param paramValue The value to be bound.
*/
virtual void bindUint64(const std::string &paramName, const uint64_t paramValue);
virtual void bindUint64(const std::string &paramName, const uint64_t paramValue) override;
/**
* Binds an SQL parameter.
......@@ -92,7 +92,7 @@ public:
* @param paramName The name of the parameter.
* @param paramValue The value to be bound.
*/
virtual void bindString(const std::string &paramName, const std::string &paramValue);
virtual void bindString(const std::string &paramName, const std::string &paramValue) override;
/**
* Executes the statement and returns the result set.
......@@ -100,12 +100,12 @@ public:
* @return The result set. Please note that it is the responsibility of the
* caller to free the memory associated with the result set.
*/
virtual Rset *executeQuery();
virtual std::unique_ptr<Rset> executeQuery() override;
/**
* Executes the statement.
*/
virtual void executeNonQuery();
virtual void executeNonQuery() override;
/**
* Returns the number of rows affected by the last execution of this
......@@ -113,7 +113,7 @@ public:
*
* @return The number of affected rows.
*/
virtual uint64_t getNbAffectedRows() const;
virtual uint64_t getNbAffectedRows() const override;
/**
* Returns the underlying OCCI result set.
......
......@@ -16,11 +16,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Sqlite.hpp"
#include "SqliteConn.hpp"
#include "SqliteRset.hpp"
#include "SqliteStmt.hpp"
#include "common/exception/Exception.hpp"
#include "common/make_unique.hpp"
#include "rdbms/Sqlite.hpp"
#include "rdbms/SqliteConn.hpp"
#include "rdbms/SqliteRset.hpp"
#include "rdbms/SqliteStmt.hpp"
#include <cstring>
#include <stdexcept>
......@@ -112,8 +113,8 @@ void SqliteStmt::bindString(const std::string &paramName, const std::string &par
//------------------------------------------------------------------------------
// executeQuery
//------------------------------------------------------------------------------
Rset *SqliteStmt::executeQuery() {
return new SqliteRset(*this);
std::unique_ptr<Rset> SqliteStmt::executeQuery() {
return make_unique<SqliteRset>(*this);
}
//------------------------------------------------------------------------------
......
......@@ -18,8 +18,8 @@
#pragma once
#include "Stmt.hpp"
#include "ParamNameToIdx.hpp"
#include "rdbms/ParamNameToIdx.hpp"
#include "rdbms/Stmt.hpp"
#include <map>
#include <memory>
......@@ -51,12 +51,12 @@ public:
/**
* Destructor.
*/
virtual ~SqliteStmt() throw();
virtual ~SqliteStmt() throw() override;
/**
* Idempotent close() method. The destructor calls this method.
*/
virtual void close();
virtual void close() override;
/**
* Returns a pointer to the underlying prepared statement.
......@@ -73,7 +73,7 @@ public:
*
* @return The SQL statement.
*/
virtual const std::string &getSql() const;
virtual const std::string &getSql() const override;
/**
* Binds an SQL parameter.
......@@ -81,7 +81,7 @@ public:
* @param paramName The name of the parameter.
* @param paramValue The value to be bound.
*/
virtual void bindUint64(const std::string &paramName, const uint64_t paramValue);
virtual void bindUint64(const std::string &paramName, const uint64_t paramValue) override;
/**
* Binds an SQL parameter.
......@@ -89,7 +89,7 @@ public:
* @param paramName The name of the parameter.
* @param paramValue The value to be bound.
*/
virtual void bindString(const std::string &paramName, const std::string &paramValue);
virtual void bindString(const std::string &paramName, const std::string &paramValue) override;
/**
* Executes the statement and returns the result set.
......@@ -97,12 +97,12 @@ public:
* @return The result set. Please note that it is the responsibility of the
* caller to free the memory associated with the result set.
*/
virtual Rset *executeQuery();
virtual std::unique_ptr<Rset> executeQuery() override;
/**
* Executes the statement.
*/
virtual void executeNonQuery();
virtual void executeNonQuery() override;
/**
* Returns the number of rows affected by the last execution of this
......@@ -110,7 +110,7 @@ public:
*
* @return The number of affected rows.
*/
virtual uint64_t getNbAffectedRows() const;
virtual uint64_t getNbAffectedRows() const override;
private:
......
......@@ -18,8 +18,9 @@
#pragma once
#include "Rset.hpp"
#include "rdbms/Rset.hpp"
#include <memory>
#include <stdint.h>
#include <string>
......@@ -71,7 +72,7 @@ public:
* @return The result set. Please note that it is the responsibility of the
* caller to free the memory associated with the result set.
*/
virtual Rset *executeQuery() = 0;
virtual std::unique_ptr<Rset> executeQuery() = 0;
/**
* Executes the statement.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment