o2on svn commit
o2on-****@lists*****
2008年 3月 23日 (日) 21:03:15 JST
Revision: 65 http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=o2on&view=rev&rev=65 Author: k-uehara Date: 2008-03-23 21:03:15 +0900 (Sun, 23 Mar 2008) Log Message: ----------- Firebird対応:コンパイル条件分け Modified Paths: -------------- trunk/o2on/src.o2on/O2DatDB.cpp trunk/o2on/src.o2on/O2DatDB.h Modified: trunk/o2on/src.o2on/O2DatDB.cpp =================================================================== --- trunk/o2on/src.o2on/O2DatDB.cpp 2008-03-23 00:23:33 UTC (rev 64) +++ trunk/o2on/src.o2on/O2DatDB.cpp 2008-03-23 12:03:15 UTC (rev 65) @@ -14,6 +14,7 @@ #include <process.h> #include "dataconv.h" #include "stopwatch.h" +#include <time.h> #define UPDATE_THREAD_INTERVAL_S 15 @@ -56,17 +57,34 @@ } - +#ifdef O2_DB_FIREBIRD void O2DatDB:: +log(ISC_STATUS_ARRAY &status) +{ + string errmsg; + char msg[512]; + while(isc_interprete(msg, (ISC_STATUS **)&status)){ + errmsg += msg; + errmsg += " "; + } + Logger->AddLog(O2LT_ERROR, L"FireBird", 0, 0, "%s", errmsg); +} +#else +void +O2DatDB:: log(sqlite3 *db) { Logger->AddLog(O2LT_ERROR, L"SQLite", 0, 0, sqlite3_errmsg(db)); } +#endif +#ifdef O2_DB_FIREBIRD + +#else bool O2DatDB:: bind(sqlite3 *db, sqlite3_stmt* stmt, int index, const uint64 num) @@ -168,6 +186,7 @@ cols.push_back((wchar_t*)sqlite3_column_name16(stmt, i)); } } +#endif @@ -179,7 +198,10 @@ #if TRACE_SQL_EXEC_TIME stopwatch sw("create table/index and analyze"); #endif +#ifdef O2_DB_FIREBIRD + return false; +#else sqlite3 *db = NULL; int err = sqlite3_open16(dbfilename.c_str(), &db); if (err != SQLITE_OK) @@ -232,11 +254,13 @@ log(db); if (db) sqlite3_close(db); return false; +#endif } +#ifdef O2_DB_FIREBIRD bool O2DatDB:: reindex(const char *target) @@ -244,7 +268,18 @@ #if TRACE_SQL_EXEC_TIME stopwatch sw("reindex"); #endif + return true;/// noting todo +} +#else +bool +O2DatDB:: +reindex(const char *target) +{ +#if TRACE_SQL_EXEC_TIME + stopwatch sw("reindex"); +#endif + sqlite3 *db = NULL; int err = sqlite3_open16(dbfilename.c_str(), &db); if (err != SQLITE_OK) @@ -1271,6 +1306,7 @@ if (db) sqlite3_close(db); return false; } +#endif Modified: trunk/o2on/src.o2on/O2DatDB.h =================================================================== --- trunk/o2on/src.o2on/O2DatDB.h 2008-03-23 00:23:33 UTC (rev 64) +++ trunk/o2on/src.o2on/O2DatDB.h 2008-03-23 12:03:15 UTC (rev 65) @@ -10,7 +10,11 @@ */ #pragma once +#ifdef O2_DB_FIREBIRD +#include "ibase.h" +#else #include "sqlite3.h" +#endif #include "sha.h" #include "O2Logger.h" @@ -63,6 +67,16 @@ bool UpdateThreadLoop; protected: +#ifdef O2_DB_FIREBIRD + void log(ISC_STATUS_ARRAY &status); + //bool bind(sqlite3 *db, sqlite3_stmt* stmt, int index, const uint64 num); + //bool bind(sqlite3 *db, sqlite3_stmt* stmt, int index, const wchar_t *str); + //bool bind(sqlite3 *db, sqlite3_stmt* stmt, int index, const wstring &str); + //bool bind(sqlite3 *db, sqlite3_stmt* stmt, int index, const hashT &hash); + //void get_columns(sqlite3_stmt* stmt, O2DatRec &rec); + //void get_columns(sqlite3_stmt* stmt, wstrarray &cols); + //void get_column_names(sqlite3_stmt* stmt, wstrarray &cols); +#else void log(sqlite3 *db); bool bind(sqlite3 *db, sqlite3_stmt* stmt, int index, const uint64 num); bool bind(sqlite3 *db, sqlite3_stmt* stmt, int index, const wchar_t *str); @@ -71,6 +85,7 @@ void get_columns(sqlite3_stmt* stmt, O2DatRec &rec); void get_columns(sqlite3_stmt* stmt, wstrarray &cols); void get_column_names(sqlite3_stmt* stmt, wstrarray &cols); +#endif public: O2DatDB(O2Logger *lgr, const wchar_t *filename);