Few issues with compilation and layout
This commit is contained in:
parent
15ee7962f1
commit
9305053e34
|
@ -31,7 +31,12 @@
|
||||||
|
|
||||||
class Database : public LuaObject
|
class Database : public LuaObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
friend class DBTransaction;
|
||||||
|
|
||||||
|
Database(): m_connected(false) {}
|
||||||
|
virtual ~Database() { m_connected = false; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Database connector.
|
* Database connector.
|
||||||
*
|
*
|
||||||
|
@ -126,9 +131,7 @@ class Database : public LuaObject
|
||||||
*/
|
*/
|
||||||
bool isConnected() { return m_connected; }
|
bool isConnected() { return m_connected; }
|
||||||
|
|
||||||
friend class DBTransaction;
|
protected:
|
||||||
|
|
||||||
protected:
|
|
||||||
/**
|
/**
|
||||||
* Database set connected.
|
* Database set connected.
|
||||||
*
|
*
|
||||||
|
@ -141,19 +144,19 @@ class Database : public LuaObject
|
||||||
|
|
||||||
DBResultPtr verifyResult(DBResultPtr result);
|
DBResultPtr verifyResult(DBResultPtr result);
|
||||||
|
|
||||||
Database(): m_connected(false) {}
|
|
||||||
virtual ~Database() { m_connected = false; }
|
|
||||||
|
|
||||||
ticks_t m_use;
|
ticks_t m_use;
|
||||||
bool m_connected;
|
bool m_connected;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static DatabasePtr m_instance;
|
static DatabasePtr m_instance;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DBResult : public LuaObject
|
class DBResult : public LuaObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
DBResult() {}
|
||||||
|
virtual ~DBResult() {}
|
||||||
|
|
||||||
/** Get the Integer value of a field in database
|
/** Get the Integer value of a field in database
|
||||||
*\returns The Integer value of the selected field and row
|
*\returns The Integer value of the selected field and row
|
||||||
*\param s The name of the field
|
*\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.
|
*\returns integer value of row amount, 0 if result is empty.
|
||||||
*/
|
*/
|
||||||
virtual int getRowCount() { return 0; }
|
virtual int getRowCount() { return 0; }
|
||||||
|
|
||||||
protected:
|
|
||||||
DBResult() {}
|
|
||||||
virtual ~DBResult() {}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -204,15 +203,15 @@ class DBResult : public LuaObject
|
||||||
*/
|
*/
|
||||||
class DBQuery : public std::stringstream, public LuaObject
|
class DBQuery : public std::stringstream, public LuaObject
|
||||||
{
|
{
|
||||||
friend class Database;
|
friend class Database;
|
||||||
public:
|
public:
|
||||||
DBQuery() { databaseLock.lock(); }
|
DBQuery() { databaseLock.lock(); }
|
||||||
~DBQuery() { databaseLock.unlock(); }
|
~DBQuery() { databaseLock.unlock(); }
|
||||||
|
|
||||||
void set(std::string& query) { str(query); }
|
void set(std::string& query) { str(query); }
|
||||||
void append(char query) { putback(query); }
|
void append(char query) { putback(query); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static boost::recursive_mutex databaseLock;
|
static boost::recursive_mutex databaseLock;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -223,13 +222,13 @@ class DBQuery : public std::stringstream, public LuaObject
|
||||||
*/
|
*/
|
||||||
class DBInsert
|
class DBInsert
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Associates with given database handler.
|
* Associates with given database handler.
|
||||||
*
|
*
|
||||||
* @param DatabasePtr database wrapper
|
* @param DatabasePtr database wrapper
|
||||||
*/
|
*/
|
||||||
DBInsert(DatabasePtr db): m_db(db), m_rows(0) {}
|
DBInsert(const DatabasePtr& db): m_db(db), m_rows(0) {}
|
||||||
~DBInsert() {}
|
~DBInsert() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -258,7 +257,7 @@ class DBInsert
|
||||||
*/
|
*/
|
||||||
bool execute();
|
bool execute();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
DatabasePtr m_db;
|
DatabasePtr m_db;
|
||||||
|
|
||||||
uint32 m_rows;
|
uint32 m_rows;
|
||||||
|
@ -268,7 +267,7 @@ class DBInsert
|
||||||
|
|
||||||
class DBTransaction
|
class DBTransaction
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DBTransaction(DatabasePtr database)
|
DBTransaction(DatabasePtr database)
|
||||||
{
|
{
|
||||||
m_db = database;
|
m_db = database;
|
||||||
|
@ -296,7 +295,7 @@ class DBTransaction
|
||||||
return m_db->commit();
|
return m_db->commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DatabasePtr m_db;
|
DatabasePtr m_db;
|
||||||
enum TransactionStates_t
|
enum TransactionStates_t
|
||||||
{
|
{
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
|
|
||||||
class DatabaseMySQL : public Database
|
class DatabaseMySQL : public Database
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DatabaseMySQL();
|
DatabaseMySQL();
|
||||||
virtual ~DatabaseMySQL();
|
virtual ~DatabaseMySQL();
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ class DatabaseMySQL : public Database
|
||||||
virtual uint64 getLastInsertedRowID();
|
virtual uint64 getLastInsertedRowID();
|
||||||
virtual Fw::DatabaseEngine getDatabaseEngine() {return Fw::DatabaseMySQL;}
|
virtual Fw::DatabaseEngine getDatabaseEngine() {return Fw::DatabaseMySQL;}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool handleError();
|
bool handleError();
|
||||||
bool internalExecuteQuery(const std::string &query);
|
bool internalExecuteQuery(const std::string &query);
|
||||||
|
|
||||||
|
@ -64,8 +64,13 @@ class DatabaseMySQL : public Database
|
||||||
|
|
||||||
class MySQLResult : public DBResult
|
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 int32 getDataInt(const std::string& s);
|
||||||
virtual int64 getDataLong(const std::string& s);
|
virtual int64 getDataLong(const std::string& s);
|
||||||
virtual std::string getDataString(const std::string& s);
|
virtual std::string getDataString(const std::string& s);
|
||||||
|
@ -75,10 +80,7 @@ class MySQLResult : public DBResult
|
||||||
virtual bool next();
|
virtual bool next();
|
||||||
virtual int getRowCount() { return mysql_num_rows(m_result); }
|
virtual int getRowCount() { return mysql_num_rows(m_result); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
MySQLResult(MYSQL_RES* result);
|
|
||||||
virtual ~MySQLResult();
|
|
||||||
|
|
||||||
typedef std::map<const std::string, uint32> RowNames_t;
|
typedef std::map<const std::string, uint32> RowNames_t;
|
||||||
RowNames_t m_names;
|
RowNames_t m_names;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue