Few issues with compilation and layout

This commit is contained in:
BeniS 2013-03-05 17:47:43 +13:00
parent 15ee7962f1
commit 9305053e34
2 changed files with 245 additions and 244 deletions

View File

@ -31,7 +31,12 @@
class Database : public LuaObject
{
public:
public:
friend class DBTransaction;
Database(): m_connected(false) {}
virtual ~Database() { m_connected = false; }
/**
* Database connector.
*
@ -126,9 +131,7 @@ class Database : public LuaObject
*/
bool isConnected() { return m_connected; }
friend class DBTransaction;
protected:
protected:
/**
* Database set connected.
*
@ -141,19 +144,19 @@ class Database : public LuaObject
DBResultPtr verifyResult(DBResultPtr result);
Database(): m_connected(false) {}
virtual ~Database() { m_connected = false; }
ticks_t m_use;
bool m_connected;
private:
private:
static DatabasePtr m_instance;
};
class DBResult : public LuaObject
{
public:
public:
DBResult() {}
virtual ~DBResult() {}
/** Get the Integer value of a field in database
*\returns The Integer value of the selected field and row
*\param s The name of the field
@ -191,10 +194,6 @@ class DBResult : public LuaObject
*\returns integer value of row amount, 0 if result is empty.
*/
virtual int getRowCount() { return 0; }
protected:
DBResult() {}
virtual ~DBResult() {}
};
/**
@ -204,15 +203,15 @@ class DBResult : public LuaObject
*/
class DBQuery : public std::stringstream, public LuaObject
{
friend class Database;
public:
friend class Database;
public:
DBQuery() { databaseLock.lock(); }
~DBQuery() { databaseLock.unlock(); }
void set(std::string& query) { str(query); }
void append(char query) { putback(query); }
protected:
protected:
static boost::recursive_mutex databaseLock;
};
@ -223,13 +222,13 @@ class DBQuery : public std::stringstream, public LuaObject
*/
class DBInsert
{
public:
public:
/**
* Associates with given database handler.
*
* @param DatabasePtr database wrapper
*/
DBInsert(DatabasePtr db): m_db(db), m_rows(0) {}
DBInsert(const DatabasePtr& db): m_db(db), m_rows(0) {}
~DBInsert() {}
/**
@ -258,7 +257,7 @@ class DBInsert
*/
bool execute();
protected:
protected:
DatabasePtr m_db;
uint32 m_rows;
@ -268,7 +267,7 @@ class DBInsert
class DBTransaction
{
public:
public:
DBTransaction(DatabasePtr database)
{
m_db = database;
@ -296,7 +295,7 @@ class DBTransaction
return m_db->commit();
}
private:
private:
DatabasePtr m_db;
enum TransactionStates_t
{

View File

@ -35,7 +35,7 @@
class DatabaseMySQL : public Database
{
public:
public:
DatabaseMySQL();
virtual ~DatabaseMySQL();
@ -55,7 +55,7 @@ class DatabaseMySQL : public Database
virtual uint64 getLastInsertedRowID();
virtual Fw::DatabaseEngine getDatabaseEngine() {return Fw::DatabaseMySQL;}
protected:
protected:
bool handleError();
bool internalExecuteQuery(const std::string &query);
@ -64,8 +64,13 @@ class DatabaseMySQL : public Database
class MySQLResult : public DBResult
{
friend class DatabaseMySQL;
public:
friend class DatabaseMySQL;
public:
MySQLResult(MYSQL_RES* result);
virtual ~MySQLResult();
virtual int32 getDataInt(const std::string& s);
virtual int64 getDataLong(const std::string& s);
virtual std::string getDataString(const std::string& s);
@ -75,10 +80,7 @@ class MySQLResult : public DBResult
virtual bool next();
virtual int getRowCount() { return mysql_num_rows(m_result); }
protected:
MySQLResult(MYSQL_RES* result);
virtual ~MySQLResult();
protected:
typedef std::map<const std::string, uint32> RowNames_t;
RowNames_t m_names;