Mercurial > code
changeset 216:bb0a7d1a3f86
Driver: fix compilation on GCC
author | David Demelier <markand@malikania.fr> |
---|---|
date | Mon, 05 May 2014 21:59:04 +0200 |
parents | 5bb5712d400f |
children | 1aceace80f61 |
files | C++/Driver.cpp C++/DriverPostgres.cpp C++/DriverPostgres.h |
diffstat | 3 files changed, 8 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/C++/Driver.cpp Thu May 01 14:03:03 2014 +0200 +++ b/C++/Driver.cpp Mon May 05 21:59:04 2014 +0200 @@ -16,6 +16,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include <stdexcept> #include <sstream> #include "Driver.h"
--- a/C++/DriverPostgres.cpp Thu May 01 14:03:03 2014 +0200 +++ b/C++/DriverPostgres.cpp Mon May 05 21:59:04 2014 +0200 @@ -16,28 +16,19 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include <cerrno> +#include <cstring> #include <iostream> +#include <stdexcept> #include <sstream> #include <vector> +#include <libpq-fe.h> + #include "DriverPostgres.h" namespace { -struct PGConnDeleter { - void operator()(PGconn *conn) - { - PQfinish(conn); - } -}; - -struct PGQueryDeleter { - void operator()(PGresult *result) - { - PQclear(result); - } -}; - using PostgresResult = std::shared_ptr<PGresult>; using PostgresConn = std::shared_ptr<PGconn>; @@ -225,7 +216,6 @@ if (info != nullptr && (status == PGRES_COMMAND_OK || status == PGRES_TUPLES_OK)) { - puts("SUCESS"); timestamp = atoi(PQgetvalue(info, 0, 0)); PQclear(info); } @@ -428,7 +418,7 @@ throw std::runtime_error(error); } - m_connection = std::shared_ptr<PGconn>(conn, PGConnDeleter()); + m_connection = std::shared_ptr<PGconn>(conn, PQfinish); } DriverRequest DriverPostgresImpl::prepare(const std::string &command) @@ -454,7 +444,7 @@ throw std::runtime_error(error); } - auto result = std::shared_ptr<PGresult>(info, PGQueryDeleter()); + auto result = std::shared_ptr<PGresult>(info, PQclear); auto impl = std::make_shared<QueryPostgresImpl>(m_connection, result); return DriverQuery(impl);