summaryrefslogtreecommitdiffstats
path: root/src/dal
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2009-12-06 18:39:49 +0100
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2009-12-06 18:46:49 +0100
commitc0a5b22aa8f90c3d5de4a4b7495cf157d9a189d1 (patch)
treee3982ab486c539a88d0c3eaad37c0fdfaa1b1f8f /src/dal
parent49cd2c5d236294fa99a612dbf4833c72a7f89de8 (diff)
downloadmanaserv-c0a5b22aa8f90c3d5de4a4b7495cf157d9a189d1.tar.gz
manaserv-c0a5b22aa8f90c3d5de4a4b7495cf157d9a189d1.tar.xz
manaserv-c0a5b22aa8f90c3d5de4a4b7495cf157d9a189d1.zip
A host of code style changes
Removed pointless void in method parameter lists, fixed methods and variables that started with upper case, removed pointless 'const' for stuff passed by value, made some getters const, etc.
Diffstat (limited to 'src/dal')
-rw-r--r--src/dal/dalexcept.h47
-rw-r--r--src/dal/dataprovider.cpp12
-rw-r--r--src/dal/dataprovider.h37
-rw-r--r--src/dal/dataproviderfactory.cpp9
-rw-r--r--src/dal/dataproviderfactory.h14
-rw-r--r--src/dal/mysqldataprovider.cpp34
-rw-r--r--src/dal/mysqldataprovider.h32
-rw-r--r--src/dal/pqdataprovider.cpp23
-rw-r--r--src/dal/pqdataprovider.h30
-rw-r--r--src/dal/recordset.cpp44
-rw-r--r--src/dal/recordset.h41
-rw-r--r--src/dal/sqlitedataprovider.cpp47
-rw-r--r--src/dal/sqlitedataprovider.h35
13 files changed, 130 insertions, 275 deletions
diff --git a/src/dal/dalexcept.h b/src/dal/dalexcept.h
index 75022ec..fe0423f 100644
--- a/src/dal/dalexcept.h
+++ b/src/dal/dalexcept.h
@@ -42,28 +42,21 @@ class DbException: public std::exception
DbException(const std::string& msg)
throw()
: mMsg(msg)
- {
- // NOOP
- }
-
+ {}
/**
* Destructor.
*/
- ~DbException(void)
+ ~DbException()
throw()
- {
- // NOOP
- }
-
+ {}
/**
* Get the error message.
*
* @return the error message.
*/
- virtual const char*
- what(void) const
+ virtual const char *what() const
throw()
{
return mMsg.c_str();
@@ -84,12 +77,10 @@ class DbConnectionFailure: public DbException
/**
* Default constructor.
*/
- DbConnectionFailure(void)
+ DbConnectionFailure()
throw()
: DbException("")
- {
- // NOOP
- }
+ {}
/**
@@ -100,9 +91,7 @@ class DbConnectionFailure: public DbException
DbConnectionFailure(const std::string& msg)
throw()
: DbException(msg)
- {
- // NOOP
- }
+ {}
};
@@ -115,13 +104,10 @@ class DbDisconnectionFailure: public DbException
/**
* Default constructor.
*/
- DbDisconnectionFailure(void)
+ DbDisconnectionFailure()
throw()
: DbException("")
- {
- // NOOP
- }
-
+ {}
/**
* Constructor.
@@ -131,9 +117,7 @@ class DbDisconnectionFailure: public DbException
DbDisconnectionFailure(const std::string& msg)
throw()
: DbException(msg)
- {
- // NOOP
- }
+ {}
};
@@ -146,13 +130,10 @@ class DbSqlQueryExecFailure: public DbException
/**
* Default constructor.
*/
- DbSqlQueryExecFailure(void)
+ DbSqlQueryExecFailure()
throw()
: DbException("")
- {
- // NOOP
- }
-
+ {}
/**
* Constructor.
@@ -162,9 +143,7 @@ class DbSqlQueryExecFailure: public DbException
DbSqlQueryExecFailure(const std::string& msg)
throw()
: DbException(msg)
- {
- // NOOP
- }
+ {}
};
diff --git a/src/dal/dataprovider.cpp b/src/dal/dataprovider.cpp
index 8fd8fe0..1b819ed 100644
--- a/src/dal/dataprovider.cpp
+++ b/src/dal/dataprovider.cpp
@@ -28,30 +28,27 @@ namespace dal
/**
* Constructor.
*/
-DataProvider::DataProvider(void)
+DataProvider::DataProvider()
throw()
: mIsConnected(false),
mRecordSet()
{
- // NOOP
}
/**
* Destructor.
*/
-DataProvider::~DataProvider(void)
+DataProvider::~DataProvider()
throw()
{
- // NOOP
}
/**
* Get the connection status.
*/
-bool
-DataProvider::isConnected(void) const
+bool DataProvider::isConnected() const
throw()
{
return mIsConnected;
@@ -60,8 +57,7 @@ DataProvider::isConnected(void) const
/**
* Get the DataBase Name
*/
-std::string
-DataProvider::getDbName(void)
+std::string DataProvider::getDbName() const
{
if (!isConnected())
{
diff --git a/src/dal/dataprovider.h b/src/dal/dataprovider.h
index 90169ee..1a11176 100644
--- a/src/dal/dataprovider.h
+++ b/src/dal/dataprovider.h
@@ -59,38 +59,32 @@ class DataProvider
/**
* Constructor.
*/
- DataProvider(void)
+ DataProvider()
throw();
-
/**
* Destructor.
*/
virtual
- ~DataProvider(void)
+ ~DataProvider()
throw();
-
/**
* Get the connection status.
*
* @return true if connected.
*/
- bool
- isConnected(void) const
+ bool isConnected() const
throw();
-
/**
* Get the name of the database backend.
*
* @return the database backend name.
*/
- virtual DbBackends
- getDbBackend(void) const
+ virtual DbBackends getDbBackend() const
throw() = 0;
-
/**
* Create a connection to the database.
*
@@ -99,7 +93,7 @@ class DataProvider
*
* @exception DbConnectionFailure if unsuccessful connection.
*/
- virtual void connect(void) = 0;
+ virtual void connect() = 0;
/**
@@ -123,22 +117,19 @@ class DataProvider
*
* @exception DbDisconnectionFailure if unsuccessful disconnection.
*/
- virtual void
- disconnect(void) = 0;
+ virtual void disconnect() = 0;
/**
* Get the Database Name.
*/
- std::string
- getDbName(void);
+ std::string getDbName() const;
/**
* Starts a transaction.
*
* @exception std::runtime_error if a transaction is still open
*/
- virtual void
- beginTransaction(void)
+ virtual void beginTransaction()
throw (std::runtime_error) = 0;
/**
@@ -146,8 +137,7 @@ class DataProvider
*
* @exception std::runtime_error if no connection is currently open.
*/
- virtual void
- commitTransaction(void)
+ virtual void commitTransaction()
throw (std::runtime_error) = 0;
/**
@@ -155,8 +145,7 @@ class DataProvider
*
* @exception std::runtime_error if no connection is currently open.
*/
- virtual void
- rollbackTransaction(void)
+ virtual void rollbackTransaction()
throw (std::runtime_error) = 0;
/**
@@ -165,8 +154,7 @@ class DataProvider
*
* @return Number of rows that have changed.
*/
- virtual const unsigned int
- getModifiedRows(void) const = 0;
+ virtual unsigned getModifiedRows() const = 0;
/**
* Returns the last inserted value of an autoincrement column after an
@@ -174,8 +162,7 @@ class DataProvider
*
* @return last autoincrement value.
*/
- virtual const unsigned int
- getLastId(void) const = 0;
+ virtual unsigned getLastId() const = 0;
/**
* Prepare SQL statement
diff --git a/src/dal/dataproviderfactory.cpp b/src/dal/dataproviderfactory.cpp
index fd0c858..48d9952 100644
--- a/src/dal/dataproviderfactory.cpp
+++ b/src/dal/dataproviderfactory.cpp
@@ -41,28 +41,25 @@ namespace dal
/**
* Default constructor.
*/
-DataProviderFactory::DataProviderFactory(void)
+DataProviderFactory::DataProviderFactory()
throw()
{
- // NOOP
}
/**
* Destructor.
*/
-DataProviderFactory::~DataProviderFactory(void)
+DataProviderFactory::~DataProviderFactory()
throw()
{
- // NOOP
}
/**
* Create a data provider.
*/
-DataProvider*
-DataProviderFactory::createDataProvider(void)
+DataProvider *DataProviderFactory::createDataProvider()
{
#if defined (MYSQL_SUPPORT)
MySqlDataProvider* provider = new MySqlDataProvider;
diff --git a/src/dal/dataproviderfactory.h b/src/dal/dataproviderfactory.h
index aee96fc..ed0f7e1 100644
--- a/src/dal/dataproviderfactory.h
+++ b/src/dal/dataproviderfactory.h
@@ -40,36 +40,32 @@ class DataProviderFactory
/**
* Create a new data provider.
*/
- static DataProvider*
- createDataProvider(void);
-
+ static DataProvider *createDataProvider();
private:
/**
* Default constructor.
*/
- DataProviderFactory(void)
+ DataProviderFactory()
throw();
-
/**
* Destructor.
*/
- ~DataProviderFactory(void)
+ ~DataProviderFactory()
throw();
-
/**
* Copy constructor.
*/
- DataProviderFactory(const DataProviderFactory& rhs);
+ DataProviderFactory(const DataProviderFactory &rhs);
/**
* Assignment operator.
*/
DataProviderFactory&
- operator=(const DataProviderFactory& rhs);
+ operator=(const DataProviderFactory &rhs);
};
diff --git a/src/dal/mysqldataprovider.cpp b/src/dal/mysqldataprovider.cpp
index 13a3002..1024047 100644
--- a/src/dal/mysqldataprovider.cpp
+++ b/src/dal/mysqldataprovider.cpp
@@ -25,7 +25,6 @@
namespace dal
{
-
const std::string MySqlDataProvider::CFGPARAM_MYSQL_HOST ="mysql_hostname";
const std::string MySqlDataProvider::CFGPARAM_MYSQL_PORT ="mysql_port";
const std::string MySqlDataProvider::CFGPARAM_MYSQL_DB ="mysql_database";
@@ -41,18 +40,17 @@ const std::string MySqlDataProvider::CFGPARAM_MYSQL_PWD_DEF = "mana";
/**
* Constructor.
*/
-MySqlDataProvider::MySqlDataProvider(void)
+MySqlDataProvider::MySqlDataProvider()
throw()
: mDb(0)
{
- // NOOP
}
/**
* Destructor.
*/
-MySqlDataProvider::~MySqlDataProvider(void)
+MySqlDataProvider::~MySqlDataProvider()
throw()
{
// we are using the MySQL C API, there are no exceptions to catch.
@@ -69,8 +67,7 @@ MySqlDataProvider::~MySqlDataProvider(void)
/**
* Get the database backend name.
*/
-DbBackends
-MySqlDataProvider::getDbBackend(void) const
+DbBackends MySqlDataProvider::getDbBackend() const
throw()
{
return DB_BKEND_MYSQL;
@@ -80,8 +77,7 @@ MySqlDataProvider::getDbBackend(void) const
/**
* Create a connection to the database.
*/
-void
-MySqlDataProvider::connect()
+void MySqlDataProvider::connect()
{
if (mIsConnected) {
return;
@@ -201,8 +197,7 @@ MySqlDataProvider::execSql(const std::string& sql,
/**
* Close the connection to the database.
*/
-void
-MySqlDataProvider::disconnect(void)
+void MySqlDataProvider::disconnect()
{
if (!mIsConnected) {
return;
@@ -219,8 +214,7 @@ MySqlDataProvider::disconnect(void)
mIsConnected = false;
}
-void
-MySqlDataProvider::beginTransaction(void)
+void MySqlDataProvider::beginTransaction()
throw (std::runtime_error)
{
if (!mIsConnected)
@@ -236,8 +230,7 @@ MySqlDataProvider::beginTransaction(void)
LOG_DEBUG("SQL: started transaction");
}
-void
-MySqlDataProvider::commitTransaction(void)
+void MySqlDataProvider::commitTransaction()
throw (std::runtime_error)
{
if (!mIsConnected)
@@ -257,8 +250,7 @@ MySqlDataProvider::commitTransaction(void)
LOG_DEBUG("SQL: commited transaction");
}
-void
-MySqlDataProvider::rollbackTransaction(void)
+void MySqlDataProvider::rollbackTransaction()
throw (std::runtime_error)
{
if (!mIsConnected)
@@ -278,8 +270,7 @@ MySqlDataProvider::rollbackTransaction(void)
LOG_DEBUG("SQL: transaction rolled back");
}
-const unsigned int
-MySqlDataProvider::getModifiedRows(void) const
+unsigned MySqlDataProvider::getModifiedRows() const
{
if (!mIsConnected)
{
@@ -301,11 +292,10 @@ MySqlDataProvider::getModifiedRows(void) const
throw DbSqlQueryExecFailure(mysql_error(mDb));
}
- return (unsigned int)affected;
+ return (unsigned) affected;
}
-const unsigned int
-MySqlDataProvider::getLastId(void) const
+unsigned MySqlDataProvider::getLastId() const
{
if (!mIsConnected)
{
@@ -319,7 +309,7 @@ MySqlDataProvider::getLastId(void) const
if (lastId > UINT_MAX)
throw std::runtime_error("MySqlDataProvider::getLastId exceeded INT_MAX");
- return (unsigned int)lastId;
+ return (unsigned) lastId;
}
diff --git a/src/dal/mysqldataprovider.h b/src/dal/mysqldataprovider.h
index ef0f4cf..c3ad1ce 100644
--- a/src/dal/mysqldataprovider.h
+++ b/src/dal/mysqldataprovider.h
@@ -37,14 +37,12 @@
namespace dal
{
-
/**
* A MySQL Data Provider.
*/
class MySqlDataProvider: public DataProvider
{
public:
-
/**
* Replacement for mysql my_bool datatype used in mysql_autocommit()
* function.
@@ -57,24 +55,21 @@ class MySqlDataProvider: public DataProvider
/**
* Constructor.
*/
- MySqlDataProvider(void)
+ MySqlDataProvider()
throw();
-
/**
* Destructor.
*/
- ~MySqlDataProvider(void)
+ ~MySqlDataProvider()
throw();
-
/**
* Get the name of the database backend.
*
* @return the database backend name.
*/
- DbBackends
- getDbBackend(void) const
+ DbBackends getDbBackend() const
throw();
@@ -107,16 +102,14 @@ class MySqlDataProvider: public DataProvider
*
* @exception DbDisconnectionFailure if unsuccessful disconnection.
*/
- void
- disconnect(void);
+ void disconnect();
/**
* Starts a transaction.
*
* @exception std::runtime_error if a transaction is still open
*/
- void
- beginTransaction(void)
+ void beginTransaction()
throw (std::runtime_error);
/**
@@ -124,8 +117,7 @@ class MySqlDataProvider: public DataProvider
*
* @exception std::runtime_error if no connection is currently open.
*/
- void
- commitTransaction(void)
+ void commitTransaction()
throw (std::runtime_error);
/**
@@ -133,8 +125,7 @@ class MySqlDataProvider: public DataProvider
*
* @exception std::runtime_error if no connection is currently open.
*/
- void
- rollbackTransaction(void)
+ void rollbackTransaction()
throw (std::runtime_error);
/**
@@ -143,8 +134,7 @@ class MySqlDataProvider: public DataProvider
*
* @return Number of rows that have changed.
*/
- const unsigned int
- getModifiedRows(void) const;
+ unsigned getModifiedRows() const;
/**
* Returns the last inserted value of an autoincrement column after an
@@ -152,11 +142,9 @@ class MySqlDataProvider: public DataProvider
*
* @return last autoincrement value.
*/
- const unsigned int
- getLastId(void) const;
+ unsigned getLastId() const;
private:
-
/** defines the name of the hostname config parameter */
static const std::string CFGPARAM_MYSQL_HOST;
/** defines the name of the server port config parameter */
@@ -180,7 +168,7 @@ class MySqlDataProvider: public DataProvider
static const std::string CFGPARAM_MYSQL_PWD_DEF;
- MYSQL* mDb; /**< the handle to the database connection */
+ MYSQL *mDb; /**< the handle to the database connection */
};
diff --git a/src/dal/pqdataprovider.cpp b/src/dal/pqdataprovider.cpp
index 67e12e8..3c40cf1 100644
--- a/src/dal/pqdataprovider.cpp
+++ b/src/dal/pqdataprovider.cpp
@@ -28,18 +28,17 @@ namespace dal
/**
* Constructor
*/
-PqDataProvider::PqDataProvider(void)
+PqDataProvider::PqDataProvider()
throw()
: mDb(0)
{
- // NOOP
}
/**
* Destructor
*/
-PqDataProvider::~PqDataProvider(void)
+PqDataProvider::~PqDataProvider()
throw()
{
if (mIsConnected) {
@@ -51,8 +50,7 @@ PqDataProvider::~PqDataProvider(void)
/**
* Get the database backend name.
*/
-DbBackends
-PqDataProvider::getDbBackend(void) const
+DbBackends PqDataProvider::getDbBackend() const
throw()
{
return DB_BKEND_POSTGRESQL;
@@ -62,10 +60,9 @@ PqDataProvider::getDbBackend(void) const
/**
* Create a connection to the database.
*/
-void
-PqDataProvider::connect(const std::string& dbName,
- const std::string& userName,
- const std::string& password)
+void PqDataProvider::connect(const std::string& dbName,
+ const std::string& userName,
+ const std::string& password)
{
// Create string to pass to PQconnectdb
std::string connStr = "dbname = " + dbName + " "; // database name
@@ -94,9 +91,8 @@ PqDataProvider::connect(const std::string& dbName,
/**
* Execute a SQL query.
*/
-const RecordSet&
-PqDataProvider::execSql(const std::string& sql,
- const bool refresh)
+const RecordSet &PqDataProvider::execSql(const std::string& sql,
+ const bool refresh)
{
if (!mIsConnected) {
throw std::runtime_error("not connected to database");
@@ -145,8 +141,7 @@ PqDataProvider::execSql(const std::string& sql,
/**
* Close connection to database.
*/
-void
-PqDataProvider::disconnect(void)
+void PqDataProvider::disconnect()
{
if (!mIsConnected) {
return;
diff --git a/src/dal/pqdataprovider.h b/src/dal/pqdataprovider.h
index f4f8e88..9cbc3cb 100644
--- a/src/dal/pqdataprovider.h
+++ b/src/dal/pqdataprovider.h
@@ -21,7 +21,6 @@
#ifndef _TMWSERV_PQDATAPROVIDER_H_
#define _TMWSERV_PQDATAPROVIDER_H_
-
#include <iosfwd>
#include <libpq-fe.h>
@@ -30,7 +29,6 @@
namespace dal
{
-
/**
* A PostgreSQL Data Provider.
*/
@@ -40,27 +38,23 @@ class PqDataProvider: public DataProvider
/**
* Constructor
*/
- PqDataProvider(void)
+ PqDataProvider()
throw();
-
/**
* Destructor
*/
- ~PqDataProvider(void)
+ ~PqDataProvider()
throw();
-
/**
* Get name of the database backend
*
* @return the database backend name
*/
- DbBackends
- getDbBackend(void) const
+ DbBackends getDbBackend() const
throw();
-
/**
* Create a connection to the database.
*
@@ -70,11 +64,9 @@ class PqDataProvider: public DataProvider
*
* @exception DbConnectionFailure if unsuccessful connection.
*/
- void
- connect(const std::string& dbName,
- const std::string& userName,
- const std::string& password);
-
+ void connect(const std::string& dbName,
+ const std::string& userName,
+ const std::string& password);
/**
* Execute a SQL query.
@@ -87,19 +79,15 @@ class PqDataProvider: public DataProvider
* @exception DbSqlQueryExecFailure if unsuccessful execution.
* @exception std::runtime_error if trying to query a closed database.
*/
- const RecordSet&
- execSql(const std::string& sql,
- const bool refresh = false);
-
+ const RecordSet &execSql(const std::string& sql,
+ const bool refresh = false);
/**
* Close the connection to the database.
*
* @exception DbDisconnectionFailure if unsuccessful disconnection.
*/
- void
- disconnect(void);
-
+ void disconnect();
private:
PGconn *mDb; /**< Database connection handle */
diff --git a/src/dal/recordset.cpp b/src/dal/recordset.cpp
index 28a5816..516aa5a 100644
--- a/src/dal/recordset.cpp
+++ b/src/dal/recordset.cpp
@@ -29,45 +29,37 @@
namespace dal
{
-
/**
* Default constructor.
*/
-RecordSet::RecordSet(void)
+RecordSet::RecordSet()
throw()
{
- // NOOP
}
-
/**
* Destructor.
*/
-RecordSet::~RecordSet(void)
+RecordSet::~RecordSet()
throw()
{
- // NOOP
}
-
/**
* Remove all the Records.
*/
-void
-RecordSet::clear(void)
+void RecordSet::clear()
{
mHeaders.clear();
mRows.clear();
}
-
/**
* Check if the RecordSet is empty.
*/
-bool
-RecordSet::isEmpty(void) const
+bool RecordSet::isEmpty() const
{
- return (mRows.size() == 0);
+ return mRows.size() == 0;
}
@@ -76,20 +68,17 @@ RecordSet::isEmpty(void) const
*
* @return the number of rows.
*/
-unsigned int
-RecordSet::rows(void) const
+unsigned int RecordSet::rows() const
{
return mRows.size();
}
-
/**
* Get the number of columns.
*
* @return the number of columns.
*/
-unsigned int
-RecordSet::cols(void) const
+unsigned int RecordSet::cols() const
{
return mHeaders.size();
}
@@ -98,8 +87,7 @@ RecordSet::cols(void) const
/**
* Set the column headers.
*/
-void
-RecordSet::setColumnHeaders(const Row& headers)
+void RecordSet::setColumnHeaders(const Row &headers)
{
if (mHeaders.size() > 0) {
throw AlreadySetException();
@@ -112,8 +100,7 @@ RecordSet::setColumnHeaders(const Row& headers)
/**
* Add a new row.
*/
-void
-RecordSet::add(const Row& row)
+void RecordSet::add(const Row &row)
{
const unsigned int nCols = mHeaders.size();
@@ -136,9 +123,8 @@ RecordSet::add(const Row& row)
/**
* Operator()
*/
-const std::string&
-RecordSet::operator()(const unsigned int row,
- const unsigned int col) const
+const std::string &RecordSet::operator()(const unsigned int row,
+ const unsigned int col) const
{
if ((row >= mRows.size()) || (col >= mHeaders.size())) {
std::ostringstream os;
@@ -156,9 +142,8 @@ RecordSet::operator()(const unsigned int row,
/**
* Operator()
*/
-const std::string&
-RecordSet::operator()(const unsigned int row,
- const std::string& name) const
+const std::string &RecordSet::operator()(const unsigned int row,
+ const std::string& name) const
{
if (row >= mRows.size()) {
std::ostringstream os;
@@ -194,8 +179,7 @@ RecordSet::operator()(const unsigned int row,
/**
* Operator<<
*/
-std::ostream&
-operator<<(std::ostream& out, const RecordSet& rhs)
+std::ostream &operator<<(std::ostream &out, const RecordSet &rhs)
{
// print the field names first.
if (rhs.mHeaders.size() > 0) {
diff --git a/src/dal/recordset.h b/src/dal/recordset.h
index e236b19..124123d 100644
--- a/src/dal/recordset.h
+++ b/src/dal/recordset.h
@@ -27,7 +27,6 @@
namespace dal
{
-
/**
* Data type for a row in a RecordSet.
*/
@@ -48,50 +47,40 @@ class RecordSet
/**
* Default constructor.
*/
- RecordSet(void)
+ RecordSet()
throw();
-
/**
* Destructor.
*/
- ~RecordSet(void)
+ ~RecordSet()
throw();
-
/**
* Remove all the records.
*/
- void
- clear(void);
-
+ void clear();
/**
* Check if the RecordSet is empty.
*
* @return true if empty.
*/
- bool
- isEmpty(void) const;
-
+ bool isEmpty() const;
/**
* Get the number of rows.
*
* @return the number of rows.
*/
- unsigned int
- rows(void) const;
-
+ unsigned int rows() const;
/**
* Get the number of columns.
*
* @return the number of columns.
*/
- unsigned int
- cols(void) const;
-
+ unsigned int cols() const;
/**
* Set the column headers.
@@ -101,9 +90,7 @@ class RecordSet
* @exception AlreadySetException if the column headers
* are already set.
*/
- void
- setColumnHeaders(const Row& headers);
-
+ void setColumnHeaders(const Row &headers);
/**
* Add a new row.
@@ -118,9 +105,7 @@ class RecordSet
* @exception std::invalid_argument if the number of columns in the
* new row is not equal to the number of column headers.
*/
- void
- add(const Row& row);
-
+ void add(const Row &row);
/**
* Operator()
@@ -156,7 +141,7 @@ class RecordSet
*/
const std::string&
operator()(const unsigned int row,
- const std::string& name) const;
+ const std::string &name) const;
/**
@@ -169,21 +154,19 @@ class RecordSet
* @return the output stream for chaining.
*/
friend std::ostream&
- operator<<(std::ostream& out, const RecordSet& rhs);
-
+ operator<<(std::ostream& out, const RecordSet &rhs);
private:
/**
* Copy constructor.
*/
- RecordSet(const RecordSet& rhs);
-
+ RecordSet(const RecordSet &rhs);
/**
* Assignment operator.
*/
RecordSet&
- operator=(const RecordSet& rhs);
+ operator=(const RecordSet &rhs);
private:
diff --git a/src/dal/sqlitedataprovider.cpp b/src/dal/sqlitedataprovider.cpp
index 292b611..84562c7 100644
--- a/src/dal/sqlitedataprovider.cpp
+++ b/src/dal/sqlitedataprovider.cpp
@@ -37,18 +37,17 @@ const std::string SqLiteDataProvider::CFGPARAM_SQLITE_DB_DEF = "mana.db";
/**
* Constructor.
*/
-SqLiteDataProvider::SqLiteDataProvider(void)
+SqLiteDataProvider::SqLiteDataProvider()
throw()
: mDb(0)
{
- // NOOP
}
/**
* Destructor.
*/
-SqLiteDataProvider::~SqLiteDataProvider(void)
+SqLiteDataProvider::~SqLiteDataProvider()
throw()
{
try {
@@ -68,8 +67,7 @@ SqLiteDataProvider::~SqLiteDataProvider(void)
/**
* Get the name of the database backend.
*/
-DbBackends
-SqLiteDataProvider::getDbBackend(void) const
+DbBackends SqLiteDataProvider::getDbBackend() const
throw()
{
return DB_BKEND_SQLITE;
@@ -191,12 +189,10 @@ SqLiteDataProvider::execSql(const std::string& sql,
/**
* Close the connection to the database.
*/
-void
-SqLiteDataProvider::disconnect(void)
+void SqLiteDataProvider::disconnect()
{
- if (!isConnected()) {
+ if (!isConnected())
return;
- }
// sqlite3_close() closes the connection and deallocates the connection
// handle.
@@ -208,8 +204,7 @@ SqLiteDataProvider::disconnect(void)
mIsConnected = false;
}
-void
-SqLiteDataProvider::beginTransaction(void)
+void SqLiteDataProvider::beginTransaction()
throw (std::runtime_error)
{
if (!mIsConnected)
@@ -243,8 +238,7 @@ SqLiteDataProvider::beginTransaction(void)
}
}
-void
-SqLiteDataProvider::commitTransaction(void)
+void SqLiteDataProvider::commitTransaction()
throw (std::runtime_error)
{
if (!mIsConnected)
@@ -278,8 +272,7 @@ SqLiteDataProvider::commitTransaction(void)
}
}
-void
-SqLiteDataProvider::rollbackTransaction(void)
+void SqLiteDataProvider::rollbackTransaction()
throw (std::runtime_error)
{
if (!mIsConnected)
@@ -313,8 +306,7 @@ SqLiteDataProvider::rollbackTransaction(void)
}
}
-const unsigned int
-SqLiteDataProvider::getModifiedRows(void) const
+unsigned SqLiteDataProvider::getModifiedRows() const
{
if (!mIsConnected)
{
@@ -324,11 +316,10 @@ SqLiteDataProvider::getModifiedRows(void) const
throw std::runtime_error(error);
}
- return (unsigned int)sqlite3_changes(mDb);
+ return (unsigned) sqlite3_changes(mDb);
}
-const bool
-SqLiteDataProvider::inTransaction(void) const
+bool SqLiteDataProvider::inTransaction() const
{
if (!mIsConnected)
{
@@ -342,18 +333,10 @@ SqLiteDataProvider::inTransaction(void) const
// Autocommit mode is on by default. Autocommit mode is disabled by a BEGIN
// statement. Autocommit mode is re-enabled by a COMMIT or ROLLBACK.
const int ret = sqlite3_get_autocommit(mDb);
- if (ret == 0)
- {
- return true;
- }
- else
- {
- return false;
- }
+ return ret == 0;
}
-const unsigned int
-SqLiteDataProvider::getLastId(void) const
+unsigned SqLiteDataProvider::getLastId() const
{
if (!mIsConnected)
{
@@ -367,7 +350,7 @@ SqLiteDataProvider::getLastId(void) const
if (lastId > UINT_MAX)
throw std::runtime_error("SqLiteDataProvider::getLastId exceeded INT_MAX");
- return (unsigned int)lastId;
+ return (unsigned) lastId;
}
bool SqLiteDataProvider::prepareSql(const std::string &sql)
@@ -387,7 +370,7 @@ bool SqLiteDataProvider::prepareSql(const std::string &sql)
return true;
}
-const RecordSet& SqLiteDataProvider::processSql()
+const RecordSet &SqLiteDataProvider::processSql()
{
if (!mIsConnected) {
throw std::runtime_error("not connected to database");
diff --git a/src/dal/sqlitedataprovider.h b/src/dal/sqlitedataprovider.h
index e446c9c..e97fa7c 100644
--- a/src/dal/sqlitedataprovider.h
+++ b/src/dal/sqlitedataprovider.h
@@ -48,24 +48,21 @@ class SqLiteDataProvider: public DataProvider
/**
* Constructor.
*/
- SqLiteDataProvider(void)
+ SqLiteDataProvider()
throw();
-
/**
* Destructor.
*/
- ~SqLiteDataProvider(void)
+ ~SqLiteDataProvider()
throw();
-
/**
* Get the name of the database backend.
*
* @return the database backend name.
*/
- DbBackends
- getDbBackend(void) const
+ DbBackends getDbBackend() const
throw();
@@ -88,9 +85,8 @@ class SqLiteDataProvider: public DataProvider
* @exception DbSqlQueryExecFailure if unsuccessful execution.
* @exception std::runtime_error if trying to query a closed database.
*/
- const RecordSet&
- execSql(const std::string& sql,
- const bool refresh = false);
+ const RecordSet &execSql(const std::string& sql,
+ const bool refresh = false);
/**
@@ -98,16 +94,14 @@ class SqLiteDataProvider: public DataProvider
*
* @exception DbDisconnectionFailure if unsuccessful disconnection.
*/
- void
- disconnect(void);
+ void disconnect();
/**
* Starts a transaction.
*
* @exception std::runtime_error if a transaction is still open
*/
- void
- beginTransaction(void)
+ void beginTransaction()
throw (std::runtime_error);
/**
@@ -115,8 +109,7 @@ class SqLiteDataProvider: public DataProvider
*
* @exception std::runtime_error if no connection is currently open.
*/
- void
- commitTransaction(void)
+ void commitTransaction()
throw (std::runtime_error);
/**
@@ -124,8 +117,7 @@ class SqLiteDataProvider: public DataProvider
*
* @exception std::runtime_error if no connection is currently open.
*/
- void
- rollbackTransaction(void)
+ void rollbackTransaction()
throw (std::runtime_error);
/**
@@ -134,8 +126,7 @@ class SqLiteDataProvider: public DataProvider
*
* @return Number of rows that have changed.
*/
- const unsigned int
- getModifiedRows(void) const;
+ unsigned getModifiedRows() const;
/**
* Returns the last inserted value of an autoincrement column after an
@@ -143,8 +134,7 @@ class SqLiteDataProvider: public DataProvider
*
* @return last autoincrement value.
*/
- const unsigned int
- getLastId(void) const;
+ unsigned getLastId() const;
/**
* Prepare SQL statement
@@ -185,8 +175,7 @@ class SqLiteDataProvider: public DataProvider
*
* @return true, if a transaction is open.
*/
- const bool
- inTransaction(void) const;
+ bool inTransaction() const;
sqlite3 *mDb; /**< the handle to the database connection */
sqlite3_stmt *mStmt; /**< the prepared statement to process */