Commit 6c87bef8 authored by Mateusz Loskot's avatar Mateusz Loskot

Tidy up.

parent df7a8d57
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
using namespace soci; using namespace soci;
using namespace soci::details; using namespace soci::details;
// concrete factory for Empty concrete strategies // concrete factory for Empty concrete strategies
postgresql_session_backend * postgresql_backend_factory::make_session( postgresql_session_backend * postgresql_backend_factory::make_session(
std::string const & connectString) const std::string const & connectString) const
......
...@@ -25,16 +25,14 @@ ...@@ -25,16 +25,14 @@
using namespace soci; using namespace soci;
using namespace soci::details; using namespace soci::details;
postgresql_session_backend::postgresql_session_backend(std::string const& connectString)
postgresql_session_backend::postgresql_session_backend(
std::string const & connectString)
: statementCount_(0) : statementCount_(0)
{ {
PGconn * conn = PQconnectdb(connectString.c_str()); PGconn* conn = PQconnectdb(connectString.c_str());
if (conn == NULL || PQstatus(conn) != CONNECTION_OK) if (0 == conn || CONNECTION_OK != PQstatus(conn))
{ {
std::string msg = "Cannot establish connection to the database."; std::string msg = "Cannot establish connection to the database.";
if (conn != NULL) if (0 != conn)
{ {
msg += '\n'; msg += '\n';
msg += PQerrorMessage(conn); msg += PQerrorMessage(conn);
...@@ -58,15 +56,15 @@ namespace // unnamed ...@@ -58,15 +56,15 @@ namespace // unnamed
// helper function for hardoded queries // helper function for hardoded queries
void hard_exec(PGconn * conn, char const * query, char const * errMsg) void hard_exec(PGconn * conn, char const * query, char const * errMsg)
{ {
PGresult * result = PQexec(conn, query); PGresult* result = PQexec(conn, query);
if (result == NULL) if (0 == result)
{ {
throw soci_error(errMsg); throw soci_error(errMsg);
} }
ExecStatusType const status = PQresultStatus(result); ExecStatusType const status = PQresultStatus(result);
if (status != PGRES_COMMAND_OK) if (PGRES_COMMAND_OK != status)
{ {
throw soci_error(PQresultErrorMessage(result)); throw soci_error(PQresultErrorMessage(result));
} }
...@@ -93,16 +91,16 @@ void postgresql_session_backend::rollback() ...@@ -93,16 +91,16 @@ void postgresql_session_backend::rollback()
void postgresql_session_backend::clean_up() void postgresql_session_backend::clean_up()
{ {
if (conn_ != NULL) if (0 != conn_)
{ {
PQfinish(conn_); PQfinish(conn_);
conn_ = NULL; conn_ = 0;
} }
} }
std::string postgresql_session_backend::get_next_statement_name() std::string postgresql_session_backend::get_next_statement_name()
{ {
char nameBuf[20]; // arbitrary length char nameBuf[20] = { 0 }; // arbitrary length
sprintf(nameBuf, "st_%d", ++statementCount_); sprintf(nameBuf, "st_%d", ++statementCount_);
return nameBuf; return nameBuf;
} }
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
#pragma warning(disable:4512 4511) #pragma warning(disable:4512 4511)
#endif #endif
namespace soci namespace soci
{ {
......
...@@ -21,7 +21,7 @@ using namespace soci; ...@@ -21,7 +21,7 @@ using namespace soci;
using namespace soci::tests; using namespace soci::tests;
std::string connectString; std::string connectString;
backend_factory const &backEnd = postgresql; backend_factory const &backEnd = *soci::factory_postgresql();
// Postgres-specific tests // Postgres-specific tests
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
using namespace soci; using namespace soci;
using namespace soci::details; using namespace soci::details;
// concrete factory for Empty concrete strategies // concrete factory for Empty concrete strategies
sqlite3_session_backend * sqlite3_backend_factory::make_session( sqlite3_session_backend * sqlite3_backend_factory::make_session(
std::string const &connectString) const std::string const &connectString) const
......
...@@ -25,8 +25,8 @@ ...@@ -25,8 +25,8 @@
using namespace soci; using namespace soci;
using namespace soci::details; using namespace soci::details;
void sqlite3_standard_use_type_backend::bind_by_pos(int & position, void * data, void sqlite3_standard_use_type_backend::bind_by_pos(int& position, void* data,
exchange_type type, bool readOnly) exchange_type type, bool /*readOnly*/)
{ {
if (statement_.boundByName_) if (statement_.boundByName_)
{ {
...@@ -41,8 +41,8 @@ void sqlite3_standard_use_type_backend::bind_by_pos(int & position, void * data, ...@@ -41,8 +41,8 @@ void sqlite3_standard_use_type_backend::bind_by_pos(int & position, void * data,
statement_.boundByPos_ = true; statement_.boundByPos_ = true;
} }
void sqlite3_standard_use_type_backend::bind_by_name(std::string const & name, void sqlite3_standard_use_type_backend::bind_by_name(std::string const& name,
void * data, exchange_type type, bool readOnly) void* data, exchange_type type, bool /*readOnly*/)
{ {
if (statement_.boundByPos_) if (statement_.boundByPos_)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment