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

Tidy up.

parent df7a8d57
......@@ -25,7 +25,6 @@
using namespace soci;
using namespace soci::details;
// concrete factory for Empty concrete strategies
postgresql_session_backend * postgresql_backend_factory::make_session(
std::string const & connectString) const
......
......@@ -25,16 +25,14 @@
using namespace soci;
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)
{
PGconn * conn = PQconnectdb(connectString.c_str());
if (conn == NULL || PQstatus(conn) != CONNECTION_OK)
PGconn* conn = PQconnectdb(connectString.c_str());
if (0 == conn || CONNECTION_OK != PQstatus(conn))
{
std::string msg = "Cannot establish connection to the database.";
if (conn != NULL)
if (0 != conn)
{
msg += '\n';
msg += PQerrorMessage(conn);
......@@ -58,15 +56,15 @@ namespace // unnamed
// helper function for hardoded queries
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);
}
ExecStatusType const status = PQresultStatus(result);
if (status != PGRES_COMMAND_OK)
if (PGRES_COMMAND_OK != status)
{
throw soci_error(PQresultErrorMessage(result));
}
......@@ -93,16 +91,16 @@ void postgresql_session_backend::rollback()
void postgresql_session_backend::clean_up()
{
if (conn_ != NULL)
if (0 != conn_)
{
PQfinish(conn_);
conn_ = NULL;
conn_ = 0;
}
}
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_);
return nameBuf;
}
......
......@@ -31,7 +31,6 @@
#pragma warning(disable:4512 4511)
#endif
namespace soci
{
......
......@@ -21,7 +21,7 @@ using namespace soci;
using namespace soci::tests;
std::string connectString;
backend_factory const &backEnd = postgresql;
backend_factory const &backEnd = *soci::factory_postgresql();
// Postgres-specific tests
......
......@@ -15,7 +15,6 @@
using namespace soci;
using namespace soci::details;
// concrete factory for Empty concrete strategies
sqlite3_session_backend * sqlite3_backend_factory::make_session(
std::string const &connectString) const
......
......@@ -25,8 +25,8 @@
using namespace soci;
using namespace soci::details;
void sqlite3_standard_use_type_backend::bind_by_pos(int & position, void * data,
exchange_type type, bool readOnly)
void sqlite3_standard_use_type_backend::bind_by_pos(int& position, void* data,
exchange_type type, bool /*readOnly*/)
{
if (statement_.boundByName_)
{
......@@ -41,8 +41,8 @@ void sqlite3_standard_use_type_backend::bind_by_pos(int & position, void * data,
statement_.boundByPos_ = true;
}
void sqlite3_standard_use_type_backend::bind_by_name(std::string const & name,
void * data, exchange_type type, bool readOnly)
void sqlite3_standard_use_type_backend::bind_by_name(std::string const& name,
void* data, exchange_type type, bool /*readOnly*/)
{
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