Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 6 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
BasedOnStyle: LLVM
IndentWidth: 4
ColumnLimit: 100
UseTab: Never
PointerAlignment: Left
SortIncludes: false
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# clang-format entire tree
b056da581f6bb381a113d3223786714f1bcd0d86
45 changes: 18 additions & 27 deletions db/dbHandle.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,47 +5,38 @@
#ifndef __DBHANDLE_H
#define __DBHANDLE_H "$Id: dbHandle.h,v 1.1 2007/08/28 16:09:58 dan_karrels Exp $"

#include <string>
#include <exception>
#include <string>
#include <exception>

#include "defs.h"
#include "defs.h"

#ifdef HAVE_PGSQL
#include "pgsqlDB.h"
#include "pgsqlDB.h"
#endif

namespace gnuworld
{
namespace gnuworld {

class dbHandle
#ifdef HAVE_PGSQL
: public pgsqlDB
: public pgsqlDB
#endif
{
public:
dbHandle( xClient* bot,
const std::string& dbHost,
const unsigned short int dbPort,
const std::string& dbName,
const std::string& userName,
const std::string& password )
public:
dbHandle(xClient* bot, const std::string& dbHost, const unsigned short int dbPort,
const std::string& dbName, const std::string& userName, const std::string& password)
#ifdef HAVE_PGSQL
: pgsqlDB( bot,
dbHost,
dbPort,
dbName,
userName,
password )
: pgsqlDB(bot, dbHost, dbPort, dbName, userName, password)
#endif
{}
dbHandle( xClient* bot, const std::string& connectInfo )
{
}
dbHandle(xClient* bot, const std::string& connectInfo)
#ifdef HAVE_PGSQL
: pgsqlDB( bot, connectInfo )
: pgsqlDB(bot, connectInfo)
#endif
{}
virtual ~dbHandle() {}

} ;
{
}
virtual ~dbHandle() {}
};

} // namespace gnuworld

Expand Down
36 changes: 11 additions & 25 deletions db/gnuworldDB.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,36 +21,22 @@
* $Id: gnuworldDB.cc,v 1.5 2008/01/02 23:32:17 kewlio Exp $
*/

#include <string>
#include "gnuworldDB.h"
#include <string>
#include "gnuworldDB.h"

namespace gnuworld
{
using std::string ;
namespace gnuworld {
using std::string;

gnuworldDB::gnuworldDB( )
{
/* dummy to prevent issues with pedantic compilers */
}
gnuworldDB::gnuworldDB() { /* dummy to prevent issues with pedantic compilers */ }

gnuworldDB::gnuworldDB( const string& _dbHost,
const unsigned short int _dbPort,
const string& _dbName,
const string& _userName,
const string& _password )
: dbHost( _dbHost ),
dbPort( _dbPort ),
dbName( _dbName ),
userName( _userName ),
password( _password )
{}
gnuworldDB::gnuworldDB(const string& _dbHost, const unsigned short int _dbPort,
const string& _dbName, const string& _userName, const string& _password)
: dbHost(_dbHost), dbPort(_dbPort), dbName(_dbName), userName(_userName), password(_password) {}

gnuworldDB::gnuworldDB( const string& /* connectInfo */ )
{
// TODO
gnuworldDB::gnuworldDB(const string& /* connectInfo */) {
// TODO
}

gnuworldDB::~gnuworldDB()
{}
gnuworldDB::~gnuworldDB() {}

} // namespace gnuworld
134 changes: 58 additions & 76 deletions db/gnuworldDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,92 +23,74 @@
#ifndef __GNUWORLDDB_H
#define __GNUWORLDDB_H "$Id: gnuworldDB.h,v 1.5 2009/07/26 18:30:37 mrbean_ Exp $"

#include <string>
#include <sstream>
#include <string>
#include <sstream>

#include <sys/types.h>
#include <sys/types.h>

namespace gnuworld
{
namespace gnuworld {

class gnuworldDB
{
protected:
std::string dbHost ;
unsigned short int dbPort ;
std::string dbName ;
std::string userName ;
std::string password ;
class gnuworldDB {
protected:
std::string dbHost;
unsigned short int dbPort;
std::string dbName;
std::string userName;
std::string password;

public:
gnuworldDB() ;
gnuworldDB( const std::string& dbHost,
const unsigned short int dbPort,
const std::string& dbName,
const std::string& userName,
const std::string& password ) ;
gnuworldDB( const std::string& connectInfo ) ;
virtual ~gnuworldDB() ;
public:
gnuworldDB();
gnuworldDB(const std::string& dbHost, const unsigned short int dbPort,
const std::string& dbName, const std::string& userName, const std::string& password);
gnuworldDB(const std::string& connectInfo);
virtual ~gnuworldDB();

/**
* The Exec method will execute an SQL command with the database.
* The "returnData" argument is false by default, and indicated
* whether or not data is expected back.
* If data is expected back, pass true to this method,
* and the return value will indicate if data was successfully
* returned.
* Otherwise, no data is expected back, and the method will
* return true if the command was successfully executed
* (with no data returned).
*/
virtual bool Exec( const std::stringstream&,
bool returnData = false ) = 0 ;
/**
* The Exec method will execute an SQL command with the database.
* The "returnData" argument is false by default, and indicated
* whether or not data is expected back.
* If data is expected back, pass true to this method,
* and the return value will indicate if data was successfully
* returned.
* Otherwise, no data is expected back, and the method will
* return true if the command was successfully executed
* (with no data returned).
*/
virtual bool Exec(const std::stringstream&, bool returnData = false) = 0;

/**
* The Exec method will execute an SQL command with the database.
* The "returnData" argument is false by default, and indicated
* whether or not data is expected back.
* If data is expected back, pass true to this method,
* and the return value will indicate if data was successfully
* returned.
* Otherwise, no data is expected back, and the method will
* return true if the command was successfully executed
* (with no data returned).
*/
virtual bool Exec( const std::string&,
bool returnData = false ) = 0 ;
virtual bool isConnected() const = 0 ;
virtual bool ConnectionBad() const
{ return !isConnected() ; }
/**
* The Exec method will execute an SQL command with the database.
* The "returnData" argument is false by default, and indicated
* whether or not data is expected back.
* If data is expected back, pass true to this method,
* and the return value will indicate if data was successfully
* returned.
* Otherwise, no data is expected back, and the method will
* return true if the command was successfully executed
* (with no data returned).
*/
virtual bool Exec(const std::string&, bool returnData = false) = 0;
virtual bool isConnected() const = 0;
virtual bool ConnectionBad() const { return !isConnected(); }

virtual unsigned int countTuples() const = 0 ;
virtual unsigned int affectedRows() const = 0 ;
virtual unsigned int Tuples() const
{ return countTuples() ; }
virtual unsigned int countTuples() const = 0;
virtual unsigned int affectedRows() const = 0;
virtual unsigned int Tuples() const { return countTuples(); }

virtual const std::string ErrorMessage() const = 0 ;
virtual const std::string GetValue( unsigned int row,
unsigned int column ) const = 0 ;
virtual const std::string GetValue( unsigned int row,
const std::string& colName )
const = 0 ;
virtual const std::string ErrorMessage() const = 0;
virtual const std::string GetValue(unsigned int row, unsigned int column) const = 0;
virtual const std::string GetValue(unsigned int row, const std::string& colName) const = 0;

virtual bool PutLine( const std::string& ) = 0 ;
virtual bool StartCopyIn( const std::string& ) = 0 ;
virtual bool StopCopyIn() = 0 ;
virtual bool PutLine(const std::string&) = 0;
virtual bool StartCopyIn(const std::string&) = 0;
virtual bool StopCopyIn() = 0;

inline const std::string& getDBHost() const
{ return dbHost ; }
inline const unsigned short int& getDBPort() const
{ return dbPort ; }
inline const std::string& getDBName() const
{ return dbName ; }
inline const std::string& getUserName() const
{ return userName ; }
inline const std::string& getPassword() const
{ return password ; }

} ;
inline const std::string& getDBHost() const { return dbHost; }
inline const unsigned short int& getDBPort() const { return dbPort; }
inline const std::string& getDBName() const { return dbName; }
inline const std::string& getUserName() const { return userName; }
inline const std::string& getPassword() const { return password; }
};

} // namespace gnuworld

Expand Down
Loading