Update of /cvsroot/gcblue/gcb_wx/include/database
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2303/include/database
Modified Files:
tcDBObjSerializerSql.h tcSqlReader.h
Log Message:
Index: tcDBObjSerializerSql.h
===================================================================
RCS file: /cvsroot/gcblue/gcb_wx/include/database/tcDBObjSerializerSql.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** tcDBObjSerializerSql.h 8 Aug 2004 00:31:32 -0000 1.1
--- tcDBObjSerializerSql.h 9 Aug 2004 02:35:13 -0000 1.2
***************
*** 32,35 ****
--- 32,36 ----
#include <string>
#include "sqlite/sqlite_plus.h"
+ #include "database/tcSqlReader.h"
#include <wx/wx.h>
***************
*** 68,82 ****
{
! // check if the table exists, abort if it doesn't
! string countStr =
! sqlConn.executescalar("select count(*) from sqlite_master where name='%s';",
! tableName.c_str());
! if (countStr == "0")
{
! fprintf(stderr, "tcDBObjSerializerSql<T>::Load() table (%s) not found\n",
! tableName.c_str());
return false;
}
--- 69,125 ----
{
! try
! {
! // check if the table exists, abort if it doesn't
! string countStr =
! sqlConn.executescalar("select count(*) from sqlite_master where name='%s';",
! tableName.c_str());
! if (countStr == "0")
! {
! wxString message = wxString::Format(
! "tcDBObjSerializerSql<T>::Load() table (%s) not found\n",
! tableName.c_str());
+ wxMessageBox(message.GetData(), "Error", wxICON_ERROR);
+ return false;
+ }
! }
! catch (exception& ex)
{
! wxMessageBox(ex.what(), "Error", wxICON_ERROR);
! return false;
! }
!
!
!
! try
! {
! sqlite::reader tableInfo = sqlConn.executereader(
! "pragma table_info(%s);", tableName.c_str() );
!
! sqlite::reader tableData = sqlConn.executereader(
! "select * from %s;", tableName.c_str());
!
! tcSqlReader sqlReader(tableInfo, tableData);
!
! while (sqlReader.Read())
! {
! tnPoolIndex key;
! T* obj = new T;
! obj->ReadSql(sqlReader);
!
! database->mcObjectData.AddElement(obj, key); // add to database, key gets new key val
! obj->mnKey = key; // set key val of object (may not be necessary anymore)
! }
!
! tableInfo.close();
! tableData.close();
!
! }
! catch (exception& ex)
! {
! wxMessageBox(ex.what(), "Error", wxICON_ERROR);
return false;
}
Index: tcSqlReader.h
===================================================================
RCS file: /cvsroot/gcblue/gcb_wx/include/database/tcSqlReader.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** tcSqlReader.h 8 Aug 2004 00:31:32 -0000 1.1
--- tcSqlReader.h 9 Aug 2004 02:35:14 -0000 1.2
***************
*** 54,59 ****
--- 54,64 ----
public:
double GetDouble(std::string& field);
+ double GetDouble(const char* fmt, ...);
+
int GetInt(std::string& field);
+ int GetInt(const char* fmt, ...);
+
std::string GetString(std::string& field);
+ std::string GetString(const char* fmt, ...);
bool Read();
***************
*** 64,67 ****
--- 69,73 ----
std::map<std::string, unsigned int> columnLookup;
sqlite::reader& data;
+ char buffer[128]; ///< internal buffer for formatting column names, watch overrun!
void BuildColumnLookup(sqlite::reader& tableInfo);
|