Use .c_str() instead of .data() to access null terminated char array of std::string. Use boost::filesystem::path when opening the log files (#99).
This commit is contained in:
@@ -108,7 +108,7 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, boost:
|
|||||||
//QSqlDatabase * test = myGui->getMyLog()->getMySqliteLogDb();
|
//QSqlDatabase * test = myGui->getMyLog()->getMySqliteLogDb();
|
||||||
|
|
||||||
// if(!mySqliteLogDb->open()) {
|
// if(!mySqliteLogDb->open()) {
|
||||||
// QMessageBox::critical(0, tr("ERROR"),mySqliteLogDb->lastError().text().toUtf8().data(), QMessageBox::Cancel);
|
// QMessageBox::critical(0, tr("ERROR"),mySqliteLogDb->lastError().text().toUtf8().c_str(), QMessageBox::Cancel);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ Replay::Replay() : replaySqliteLogDb(0)
|
|||||||
// *replaySqliteLogDb = QSqlDatabase::addDatabase("QSQLITE");
|
// *replaySqliteLogDb = QSqlDatabase::addDatabase("QSQLITE");
|
||||||
//replaySqliteLogDb->setDatabaseName(myLogDir->absolutePath()+"/pokerth-log-"+currentTime.toString("yyyy-MM-dd_hh.mm.ss")+".pdb");
|
//replaySqliteLogDb->setDatabaseName(myLogDir->absolutePath()+"/pokerth-log-"+currentTime.toString("yyyy-MM-dd_hh.mm.ss")+".pdb");
|
||||||
//if(!mySqliteLogDb->open()) {
|
//if(!mySqliteLogDb->open()) {
|
||||||
// QMessageBox::critical(0, tr("ERROR"),mySqliteLogDb->lastError().text().toUtf8().data(), QMessageBox::Cancel);
|
// QMessageBox::critical(0, tr("ERROR"),mySqliteLogDb->lastError().text().toUtf8().c_str(), QMessageBox::Cancel);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-7
@@ -25,8 +25,10 @@
|
|||||||
#include <sqlite3.h>
|
#include <sqlite3.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
|
#include <boost/filesystem.hpp>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
using namespace boost::filesystem;
|
||||||
|
|
||||||
Log::Log(ConfigFile *c) : mySqliteLogDb(0), myConfig(c), uniqueGameID(0), currentHandID(0), currentRound(GAME_STATE_PREFLOP), sql("")
|
Log::Log(ConfigFile *c) : mySqliteLogDb(0), myConfig(c), uniqueGameID(0), currentHandID(0), currentRound(GAME_STATE_PREFLOP), sql("")
|
||||||
{
|
{
|
||||||
@@ -66,11 +68,11 @@ Log::init()
|
|||||||
strftime(curDate,11,"%Y-%m-%d",z);
|
strftime(curDate,11,"%Y-%m-%d",z);
|
||||||
strftime(curTime,9,"%H:%M:%S",z);
|
strftime(curTime,9,"%H:%M:%S",z);
|
||||||
|
|
||||||
string mySqliteLogFileName = boost::lexical_cast<string>((myConfig->readConfigString("LogDir")).c_str());
|
path mySqliteLogFileName(myConfig->readConfigString("LogDir"));
|
||||||
mySqliteLogFileName += "/pokerth-log-" + boost::lexical_cast<string>(curDateTime) + ".pdb";
|
mySqliteLogFileName /= string("pokerth-log-") + curDateTime + ".pdb";
|
||||||
|
|
||||||
// open sqlite-db
|
// open sqlite-db
|
||||||
sqlite3_open(mySqliteLogFileName.data(), &mySqliteLogDb);
|
sqlite3_open(mySqliteLogFileName.directory_string().c_str(), &mySqliteLogDb);
|
||||||
if( mySqliteLogDb != 0 ) {
|
if( mySqliteLogDb != 0 ) {
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
@@ -313,8 +315,8 @@ Log::logPlayerAction(string playerName, PlayerActionLog action, int amount)
|
|||||||
string sql_select = "SELECT Seat FROM Player WHERE UniqueGameID=" + boost::lexical_cast<std::string>(uniqueGameID);
|
string sql_select = "SELECT Seat FROM Player WHERE UniqueGameID=" + boost::lexical_cast<std::string>(uniqueGameID);
|
||||||
sql_select += " AND ";
|
sql_select += " AND ";
|
||||||
sql_select += "Player=\"" + playerName +"\"";
|
sql_select += "Player=\"" + playerName +"\"";
|
||||||
if(sqlite3_get_table(mySqliteLogDb,sql_select.data(),&result_Player,&nRow_Player,&nCol_Player,&errmsg) != SQLITE_OK) {
|
if(sqlite3_get_table(mySqliteLogDb,sql_select.c_str(),&result_Player,&nRow_Player,&nCol_Player,&errmsg) != SQLITE_OK) {
|
||||||
cout << "Error in statement: " << sql_select.data() << "[" << errmsg << "]." << endl;
|
cout << "Error in statement: " << sql_select.c_str() << "[" << errmsg << "]." << endl;
|
||||||
} else {
|
} else {
|
||||||
if(nRow_Player == 1) {
|
if(nRow_Player == 1) {
|
||||||
logPlayerAction(boost::lexical_cast<int>(result_Player[1]), action, amount);
|
logPlayerAction(boost::lexical_cast<int>(result_Player[1]), action, amount);
|
||||||
@@ -658,8 +660,8 @@ Log::exec_transaction()
|
|||||||
string sql_transaction = "BEGIN;" + sql + "COMMIT;";
|
string sql_transaction = "BEGIN;" + sql + "COMMIT;";
|
||||||
sql = "";
|
sql = "";
|
||||||
|
|
||||||
if(sqlite3_exec(mySqliteLogDb, sql_transaction.data(), 0, 0, &errmsg) != SQLITE_OK) {
|
if(sqlite3_exec(mySqliteLogDb, sql_transaction.c_str(), 0, 0, &errmsg) != SQLITE_OK) {
|
||||||
cout << "Error in statement: " << sql_transaction.data() << "[" << errmsg << "]." << endl;
|
cout << "Error in statement: " << sql_transaction.c_str() << "[" << errmsg << "]." << endl;
|
||||||
sqlite3_free(errmsg);
|
sqlite3_free(errmsg);
|
||||||
errmsg = NULL;
|
errmsg = NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -582,7 +582,7 @@ void guiLog::writeLogFileStream(string log_string, QFile *LogFile)
|
|||||||
|
|
||||||
QTextStream stream( LogFile );
|
QTextStream stream( LogFile );
|
||||||
stream.readAll();
|
stream.readAll();
|
||||||
stream << log_string.data();
|
stream << log_string.c_str();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -597,7 +597,7 @@ void guiLog::writeLog(string log_string, int modus)
|
|||||||
writeLogFileStream(log_string,myTxtLogFile);
|
writeLogFileStream(log_string,myTxtLogFile);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
tb->append(log_string.data());
|
tb->append(log_string.c_str());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
;
|
;
|
||||||
@@ -712,13 +712,13 @@ int guiLog::exportLog(QString fileStringPdb,int modus)
|
|||||||
|
|
||||||
// open sqlite log-db
|
// open sqlite log-db
|
||||||
sqlite3 *mySqliteLogDb;
|
sqlite3 *mySqliteLogDb;
|
||||||
sqlite3_open(fileStringPdb.toStdString().data(), &mySqliteLogDb);
|
sqlite3_open(fileStringPdb.toStdString().c_str(), &mySqliteLogDb);
|
||||||
if( mySqliteLogDb != 0 ) {
|
if( mySqliteLogDb != 0 ) {
|
||||||
|
|
||||||
// read session
|
// read session
|
||||||
sql = "SELECT * FROM Session";
|
sql = "SELECT * FROM Session";
|
||||||
if(sqlite3_get_table(mySqliteLogDb,sql.data(),&results.result_Session,&nRow_Session,&nCol_Session,&errmsg) != SQLITE_OK) {
|
if(sqlite3_get_table(mySqliteLogDb,sql.c_str(),&results.result_Session,&nRow_Session,&nCol_Session,&errmsg) != SQLITE_OK) {
|
||||||
cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl;
|
cout << "Error in statement: " << sql.c_str() << "[" << errmsg << "]." << endl;
|
||||||
cleanUp(results, mySqliteLogDb);
|
cleanUp(results, mySqliteLogDb);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -795,8 +795,8 @@ int guiLog::exportLog(QString fileStringPdb,int modus)
|
|||||||
|
|
||||||
// read game
|
// read game
|
||||||
sql = "SELECT * FROM Game";
|
sql = "SELECT * FROM Game";
|
||||||
if(sqlite3_get_table(mySqliteLogDb,sql.data(),&results.result_Game,&nRow_Game,&nCol_Game,&errmsg) != SQLITE_OK) {
|
if(sqlite3_get_table(mySqliteLogDb,sql.c_str(),&results.result_Game,&nRow_Game,&nCol_Game,&errmsg) != SQLITE_OK) {
|
||||||
cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl;
|
cout << "Error in statement: " << sql.c_str() << "[" << errmsg << "]." << endl;
|
||||||
cleanUp(results, mySqliteLogDb);
|
cleanUp(results, mySqliteLogDb);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -836,8 +836,8 @@ int guiLog::exportLog(QString fileStringPdb,int modus)
|
|||||||
sql = "SELECT Player,Seat FROM Player WHERE UniqueGameID=";
|
sql = "SELECT Player,Seat FROM Player WHERE UniqueGameID=";
|
||||||
sql += boost::lexical_cast<std::string>(uniqueGameID);
|
sql += boost::lexical_cast<std::string>(uniqueGameID);
|
||||||
sql += " ORDER BY Seat;";
|
sql += " ORDER BY Seat;";
|
||||||
if(sqlite3_get_table(mySqliteLogDb,sql.data(),&results.result_Player,&nRow_Player,&nCol_Player,&errmsg) != SQLITE_OK) {
|
if(sqlite3_get_table(mySqliteLogDb,sql.c_str(),&results.result_Player,&nRow_Player,&nCol_Player,&errmsg) != SQLITE_OK) {
|
||||||
cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl;
|
cout << "Error in statement: " << sql.c_str() << "[" << errmsg << "]." << endl;
|
||||||
cleanUp(results, mySqliteLogDb);
|
cleanUp(results, mySqliteLogDb);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -848,8 +848,8 @@ int guiLog::exportLog(QString fileStringPdb,int modus)
|
|||||||
// read all hand id
|
// read all hand id
|
||||||
sql = "SELECT HandID FROM Hand WHERE UniqueGameID=";
|
sql = "SELECT HandID FROM Hand WHERE UniqueGameID=";
|
||||||
sql+= boost::lexical_cast<std::string>(uniqueGameID);
|
sql+= boost::lexical_cast<std::string>(uniqueGameID);
|
||||||
if(sqlite3_get_table(mySqliteLogDb,sql.data(),&results.result_Hand_ID,&nRow_Hand_ID,&nCol_Hand,&errmsg) != SQLITE_OK) {
|
if(sqlite3_get_table(mySqliteLogDb,sql.c_str(),&results.result_Hand_ID,&nRow_Hand_ID,&nCol_Hand,&errmsg) != SQLITE_OK) {
|
||||||
cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl;
|
cout << "Error in statement: " << sql.c_str() << "[" << errmsg << "]." << endl;
|
||||||
cleanUp(results, mySqliteLogDb);
|
cleanUp(results, mySqliteLogDb);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -886,8 +886,8 @@ int guiLog::exportLog(QString fileStringPdb,int modus)
|
|||||||
sql+= boost::lexical_cast<std::string>(uniqueGameID);
|
sql+= boost::lexical_cast<std::string>(uniqueGameID);
|
||||||
sql+= " AND HandID=";
|
sql+= " AND HandID=";
|
||||||
sql+= boost::lexical_cast<std::string>(results.result_Hand_ID[hand_ctr]);
|
sql+= boost::lexical_cast<std::string>(results.result_Hand_ID[hand_ctr]);
|
||||||
if(sqlite3_get_table(mySqliteLogDb,sql.data(),&results.result_Hand,&nRow_Hand,&nCol_Hand,&errmsg) != SQLITE_OK) {
|
if(sqlite3_get_table(mySqliteLogDb,sql.c_str(),&results.result_Hand,&nRow_Hand,&nCol_Hand,&errmsg) != SQLITE_OK) {
|
||||||
cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl;
|
cout << "Error in statement: " << sql.c_str() << "[" << errmsg << "]." << endl;
|
||||||
cleanUp(results, mySqliteLogDb);
|
cleanUp(results, mySqliteLogDb);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -1002,8 +1002,8 @@ int guiLog::exportLog(QString fileStringPdb,int modus)
|
|||||||
sql += boost::lexical_cast<std::string>(GAME_STATE_PREFLOP);
|
sql += boost::lexical_cast<std::string>(GAME_STATE_PREFLOP);
|
||||||
sql += " AND (Action='posts small blind' OR Action='posts big blind' OR Action='starts as dealer')";
|
sql += " AND (Action='posts small blind' OR Action='posts big blind' OR Action='starts as dealer')";
|
||||||
|
|
||||||
if(sqlite3_get_table(mySqliteLogDb,sql.data(),&results.result_Action,&nRow_Action,&nCol_Action,&errmsg) != SQLITE_OK) {
|
if(sqlite3_get_table(mySqliteLogDb,sql.c_str(),&results.result_Action,&nRow_Action,&nCol_Action,&errmsg) != SQLITE_OK) {
|
||||||
cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl;
|
cout << "Error in statement: " << sql.c_str() << "[" << errmsg << "]." << endl;
|
||||||
cleanUp(results, mySqliteLogDb);
|
cleanUp(results, mySqliteLogDb);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -1049,8 +1049,8 @@ int guiLog::exportLog(QString fileStringPdb,int modus)
|
|||||||
sql += boost::lexical_cast<std::string>(results.result_Hand_ID[hand_ctr]);
|
sql += boost::lexical_cast<std::string>(results.result_Hand_ID[hand_ctr]);
|
||||||
sql += " AND BeRo=0 AND Action='posts small blind'";
|
sql += " AND BeRo=0 AND Action='posts small blind'";
|
||||||
|
|
||||||
if(sqlite3_get_table(mySqliteLogDb,sql.data(),&results.result_Action,&nRow_Action,&nCol_Action,&errmsg) != SQLITE_OK) {
|
if(sqlite3_get_table(mySqliteLogDb,sql.c_str(),&results.result_Action,&nRow_Action,&nCol_Action,&errmsg) != SQLITE_OK) {
|
||||||
cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl;
|
cout << "Error in statement: " << sql.c_str() << "[" << errmsg << "]." << endl;
|
||||||
cleanUp(results, mySqliteLogDb);
|
cleanUp(results, mySqliteLogDb);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -1073,8 +1073,8 @@ int guiLog::exportLog(QString fileStringPdb,int modus)
|
|||||||
sql += boost::lexical_cast<std::string>(results.result_Hand_ID[hand_ctr]);
|
sql += boost::lexical_cast<std::string>(results.result_Hand_ID[hand_ctr]);
|
||||||
sql += " AND BeRo=0 AND Action='posts big blind'";
|
sql += " AND BeRo=0 AND Action='posts big blind'";
|
||||||
|
|
||||||
if(sqlite3_get_table(mySqliteLogDb,sql.data(),&results.result_Action,&nRow_Action,&nCol_Action,&errmsg) != SQLITE_OK) {
|
if(sqlite3_get_table(mySqliteLogDb,sql.c_str(),&results.result_Action,&nRow_Action,&nCol_Action,&errmsg) != SQLITE_OK) {
|
||||||
cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl;
|
cout << "Error in statement: " << sql.c_str() << "[" << errmsg << "]." << endl;
|
||||||
cleanUp(results, mySqliteLogDb);
|
cleanUp(results, mySqliteLogDb);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -1097,8 +1097,8 @@ int guiLog::exportLog(QString fileStringPdb,int modus)
|
|||||||
sql += boost::lexical_cast<std::string>(results.result_Hand_ID[hand_ctr]);
|
sql += boost::lexical_cast<std::string>(results.result_Hand_ID[hand_ctr]);
|
||||||
sql += " AND BeRo=0 AND Action='starts as dealer'";
|
sql += " AND BeRo=0 AND Action='starts as dealer'";
|
||||||
|
|
||||||
if(sqlite3_get_table(mySqliteLogDb,sql.data(),&results.result_Action,&nRow_Action,&nCol_Action,&errmsg) != SQLITE_OK) {
|
if(sqlite3_get_table(mySqliteLogDb,sql.c_str(),&results.result_Action,&nRow_Action,&nCol_Action,&errmsg) != SQLITE_OK) {
|
||||||
cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl;
|
cout << "Error in statement: " << sql.c_str() << "[" << errmsg << "]." << endl;
|
||||||
cleanUp(results, mySqliteLogDb);
|
cleanUp(results, mySqliteLogDb);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -1218,8 +1218,8 @@ int guiLog::exportLog(QString fileStringPdb,int modus)
|
|||||||
sql += boost::lexical_cast<std::string>(round_ctr);
|
sql += boost::lexical_cast<std::string>(round_ctr);
|
||||||
sql += " AND Action<>'starts as dealer' AND Action<>'posts big blind' AND Action<>'posts small blind'";
|
sql += " AND Action<>'starts as dealer' AND Action<>'posts big blind' AND Action<>'posts small blind'";
|
||||||
|
|
||||||
if(sqlite3_get_table(mySqliteLogDb,sql.data(),&results.result_Action,&nRow_Action,&nCol_Action,&errmsg) != SQLITE_OK) {
|
if(sqlite3_get_table(mySqliteLogDb,sql.c_str(),&results.result_Action,&nRow_Action,&nCol_Action,&errmsg) != SQLITE_OK) {
|
||||||
cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl;
|
cout << "Error in statement: " << sql.c_str() << "[" << errmsg << "]." << endl;
|
||||||
cleanUp(results, mySqliteLogDb);
|
cleanUp(results, mySqliteLogDb);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -1445,7 +1445,7 @@ int guiLog::convertCardStringToInt(string val, string col)
|
|||||||
|
|
||||||
int tmp;
|
int tmp;
|
||||||
|
|
||||||
switch(*col.data()) {
|
switch(*col.c_str()) {
|
||||||
case 'd':
|
case 'd':
|
||||||
tmp = 0;
|
tmp = 0;
|
||||||
break;
|
break;
|
||||||
@@ -1462,7 +1462,7 @@ int guiLog::convertCardStringToInt(string val, string col)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(*val.data()) {
|
switch(*val.c_str()) {
|
||||||
case '2':
|
case '2':
|
||||||
tmp += 0;
|
tmp += 0;
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user