[Gcblue-commits] gcb_wx/include/database tcDBObjSerializerSql.h,NONE,1.1 tcSqlReader.h,NONE,1.1 CsvT
Status: Alpha
Brought to you by:
ddcforge
Update of /cvsroot/gcblue/gcb_wx/include/database In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21227/include/database Modified Files: CsvTranslator.h tcAirDBObject.h tcBallisticDBObject.h tcDBObjSerializer.h tcDBString.h tcDatabase.h tcDatabaseObject.h tcESMDBObject.h tcFixedDBObject.h tcFlightportDBObject.h tcGenericDBObject.h tcLauncherDBObject.h tcMissileDBObject.h tcRadarDBObject.h tcSensorDBObject.h tcWeaponDBObject.h Added Files: tcDBObjSerializerSql.h tcSqlReader.h Log Message: Index: tcGenericDBObject.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/database/tcGenericDBObject.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** tcGenericDBObject.h 6 Aug 2004 02:47:50 -0000 1.9 --- tcGenericDBObject.h 8 Aug 2004 00:31:32 -0000 1.10 *************** *** 2,6 **** ** tcGenericDBObject.h ** ! ** Copyright (C) 2003 Dewitt "Cole" Colclough (de...@tw...) ** All rights reserved. --- 2,6 ---- ** tcGenericDBObject.h ** ! ** Copyright (C) 2003 Dewitt Colclough (de...@tw...) ** All rights reserved. *************** *** 39,42 **** --- 39,43 ---- class tcFlightportDBObject; + class tcSqlReader; /** *************** *** 91,94 **** --- 92,100 ---- virtual void SerializeXml(TiXmlElement* node, bool load); ///< XML serialization static int WriteCSVHeader(CsvTranslator* csv); ///< writes column headings + + static void AddSqlColumns(std::string& columnString); + void ReadSql(tcSqlReader& entry); + void WriteSql(std::string& valueString); + tcGenericDBObject(); tcGenericDBObject(tcGenericDBObject& obj); ///< copy constructor Index: tcRadarDBObject.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/database/tcRadarDBObject.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** tcRadarDBObject.h 19 Jul 2004 00:52:26 -0000 1.8 --- tcRadarDBObject.h 8 Aug 2004 00:31:32 -0000 1.9 *************** *** 2,6 **** ** tcRadarDBObject.h ** ! ** Copyright (C) 2003 Dewitt "Cole" Colclough (de...@tw...) ** All rights reserved. --- 2,6 ---- ** tcRadarDBObject.h ** ! ** Copyright (C) 2003 Dewitt Colclough (de...@tw...) ** All rights reserved. *************** *** 33,36 **** --- 33,37 ---- namespace Database { + class tcSqlReader; class tcRadarDBObject : public tcSensorDBObject *************** *** 53,56 **** --- 54,62 ---- virtual void SerializeXml(TiXmlElement* node, bool load); ///< XML serialization static int WriteCSVHeader(CsvTranslator* csv); ///< writes column headings + + static void AddSqlColumns(std::string& columnString); + void ReadSql(tcSqlReader& entry); + void WriteSql(std::string& valueString); + tcRadarDBObject(); tcRadarDBObject(tcRadarDBObject& obj); ///< copy constructor Index: tcSensorDBObject.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/database/tcSensorDBObject.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** tcSensorDBObject.h 27 Jul 2004 00:16:23 -0000 1.5 --- tcSensorDBObject.h 8 Aug 2004 00:31:32 -0000 1.6 *************** *** 2,6 **** ** tcSensorDBObject.h ** ! ** Copyright (C) 2003 Dewitt "Cole" Colclough (de...@tw...) ** All rights reserved. --- 2,6 ---- ** tcSensorDBObject.h ** ! ** Copyright (C) 2003 Dewitt Colclough (de...@tw...) ** All rights reserved. *************** *** 33,56 **** namespace Database { ! class tcSensorDBObject : public tcDatabaseObject ! { ! public: ! float mfMaxRange_km; ///< [km] max range regardless of theoretical detectability ! float mfRefRange_km; ///< [km] range vs. 0 dBsm target or 0 dBW emitter ! float mfFieldOfView_deg; ///< [degrees] 360 is max ! float mfScanPeriod_s; ///< [s] ! virtual const char* GetClassName() {return "Sensor";} ///< returns class name of database object ! virtual void PrintToFile(tcFile& file); ! int Serialize(tcFile& file, bool mbLoad, UINT32 anVersion); ! int SerializeCSV(CsvTranslator* csv, bool mbLoad); ///< CSV serialization ! virtual void SerializeXml(TiXmlElement* node, bool load); ///< XML serialization ! static int WriteCSVHeader(CsvTranslator* csv); ///< writes column headings ! protected: ! tcSensorDBObject(); ! tcSensorDBObject(tcSensorDBObject& obj); ///< copy constructor ! virtual ~tcSensorDBObject(); ! }; } // namespace Database --- 33,63 ---- namespace Database { ! class tcSqlReader; ! class tcSensorDBObject : public tcDatabaseObject ! { ! public: ! float mfMaxRange_km; ///< [km] max range regardless of theoretical detectability ! float mfRefRange_km; ///< [km] range vs. 0 dBsm target or 0 dBW emitter ! float mfFieldOfView_deg; ///< [degrees] 360 is max ! float mfScanPeriod_s; ///< [s] ! virtual const char* GetClassName() {return "Sensor";} ///< returns class name of database object ! virtual void PrintToFile(tcFile& file); ! int Serialize(tcFile& file, bool mbLoad, UINT32 anVersion); ! int SerializeCSV(CsvTranslator* csv, bool mbLoad); ///< CSV serialization ! virtual void SerializeXml(TiXmlElement* node, bool load); ///< XML serialization ! static int WriteCSVHeader(CsvTranslator* csv); ///< writes column headings ! ! static void AddSqlColumns(std::string& columnString); ! void ReadSql(tcSqlReader& entry); ! void WriteSql(std::string& valueString); ! ! ! protected: ! tcSensorDBObject(); ! tcSensorDBObject(tcSensorDBObject& obj); ///< copy constructor ! virtual ~tcSensorDBObject(); ! }; } // namespace Database Index: tcFixedDBObject.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/database/tcFixedDBObject.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** tcFixedDBObject.h 28 Mar 2004 23:12:27 -0000 1.4 --- tcFixedDBObject.h 8 Aug 2004 00:31:32 -0000 1.5 *************** *** 2,6 **** ** tcFixedDBObject.h ** ! ** Copyright (C) 2003 Dewitt "Cole" Colclough (de...@tw...) ** All rights reserved. --- 2,6 ---- ** tcFixedDBObject.h ** ! ** Copyright (C) 2003 Dewitt Colclough (de...@tw...) ** All rights reserved. *************** *** 33,36 **** --- 33,38 ---- namespace Database { + class tcSqlReader; + class tcFixedDBObject : public tcDatabaseObject { *************** *** 43,46 **** --- 45,52 ---- static int WriteCSVHeader(CsvTranslator* csv); ///< writes column headings + static void AddSqlColumns(std::string& columnString); + void ReadSql(tcSqlReader& entry); + void WriteSql(std::string& valueString); + tcFixedDBObject(); tcFixedDBObject(tcFixedDBObject& obj); ///< copy constructor Index: tcLauncherDBObject.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/database/tcLauncherDBObject.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** tcLauncherDBObject.h 5 Aug 2004 02:22:34 -0000 1.7 --- tcLauncherDBObject.h 8 Aug 2004 00:31:32 -0000 1.8 *************** *** 33,36 **** --- 33,38 ---- namespace Database { + class tcSqlReader; + #define MAX_LAUNCHER_CONFIGURATIONS 8 // number of weapon class/capacity options supported *************** *** 51,55 **** int SerializeCSV(CsvTranslator* csv, bool mbLoad); ///< CSV serialization virtual void SerializeXml(TiXmlElement* node, bool load); ///< XML serialization ! static int WriteCSVHeader(CsvTranslator* csv); ///< writes column headings tcLauncherDBObject(); --- 53,61 ---- int SerializeCSV(CsvTranslator* csv, bool mbLoad); ///< CSV serialization virtual void SerializeXml(TiXmlElement* node, bool load); ///< XML serialization ! static int WriteCSVHeader(CsvTranslator* csv); ///< writes column headings ! ! static void AddSqlColumns(std::string& columnString); ! void ReadSql(tcSqlReader& entry); ! void WriteSql(std::string& valueString); tcLauncherDBObject(); Index: tcWeaponDBObject.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/database/tcWeaponDBObject.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** tcWeaponDBObject.h 27 Jul 2004 23:26:06 -0000 1.2 --- tcWeaponDBObject.h 8 Aug 2004 00:31:32 -0000 1.3 *************** *** 33,54 **** namespace Database { ! class tcWeaponDBObject : public tcDatabaseObject ! { ! public: ! float mfDamage; ///< damage value ! float launchSpeed_mps; ///< initial speed at launch, use zero to use plat speed ! virtual const char* GetClassName() {return "Sensor";} ///< returns class name of database object ! virtual void PrintToFile(tcFile& file); ! int Serialize(tcFile& file, bool mbLoad, UINT32 anVersion); ! int SerializeCSV(CsvTranslator* csv, bool mbLoad); ///< CSV serialization ! virtual void SerializeXml(TiXmlElement* node, bool load); ///< XML serialization ! static int WriteCSVHeader(CsvTranslator* csv); ///< writes column headings ! protected: ! tcWeaponDBObject(); ! tcWeaponDBObject(tcWeaponDBObject& obj); ///< copy constructor ! virtual ~tcWeaponDBObject(); ! }; } // namespace Database --- 33,60 ---- namespace Database { ! class tcSqlReader; ! class tcWeaponDBObject : public tcDatabaseObject ! { ! public: ! float mfDamage; ///< damage value ! float launchSpeed_mps; ///< initial speed at launch, use zero to use plat speed ! virtual const char* GetClassName() {return "Sensor";} ///< returns class name of database object ! virtual void PrintToFile(tcFile& file); ! int Serialize(tcFile& file, bool mbLoad, UINT32 anVersion); ! int SerializeCSV(CsvTranslator* csv, bool mbLoad); ///< CSV serialization ! virtual void SerializeXml(TiXmlElement* node, bool load); ///< XML serialization ! static int WriteCSVHeader(CsvTranslator* csv); ///< writes column headings ! ! static void AddSqlColumns(std::string& columnString); ! void ReadSql(tcSqlReader& entry); ! void WriteSql(std::string& valueString); ! ! protected: ! tcWeaponDBObject(); ! tcWeaponDBObject(tcWeaponDBObject& obj); ///< copy constructor ! virtual ~tcWeaponDBObject(); ! }; } // namespace Database Index: tcESMDBObject.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/database/tcESMDBObject.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** tcESMDBObject.h 28 Mar 2004 23:12:27 -0000 1.4 --- tcESMDBObject.h 8 Aug 2004 00:31:32 -0000 1.5 *************** *** 2,6 **** ** tcESMDBObject.h ** ! ** Copyright (C) 2003 Dewitt "Cole" Colclough (de...@tw...) ** All rights reserved. --- 2,6 ---- ** tcESMDBObject.h ** ! ** Copyright (C) 2003 Dewitt Colclough (de...@tw...) ** All rights reserved. *************** *** 28,35 **** #include "tcSensorDBObject.h" namespace Database { ! class tcESMDBObject : public tcSensorDBObject --- 28,36 ---- #include "tcSensorDBObject.h" + #include "database/tcSqlReader.h" namespace Database { ! class tcSqlReader; class tcESMDBObject : public tcSensorDBObject *************** *** 45,48 **** --- 46,54 ---- tcESMDBObject(tcESMDBObject& obj); ///< copy constructor virtual ~tcESMDBObject(); + + static void AddSqlColumns(std::string& columnString); + void ReadSql(tcSqlReader& entry); + void WriteSql(std::string& valueString); + }; Index: tcAirDBObject.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/database/tcAirDBObject.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** tcAirDBObject.h 28 Mar 2004 23:12:27 -0000 1.7 --- tcAirDBObject.h 8 Aug 2004 00:31:32 -0000 1.8 *************** *** 1,4 **** /* ! ** Copyright (C) 2003 Dewitt "Cole" Colclough (de...@tw...) ** All rights reserved. --- 1,4 ---- /* ! ** Copyright (C) 2003 Dewitt Colclough (de...@tw...) ** All rights reserved. *************** *** 33,36 **** --- 33,37 ---- #include "tcGenericDBObject.h" #include "tcFile.h" + #include "database/tcSqlReader.h" class TiXmlElement; *************** *** 39,42 **** --- 40,44 ---- { + /** * This class is used to support a more realistic aerodynamic model. Though *************** *** 70,73 **** --- 72,79 ---- static int WriteCSVHeader(CsvTranslator* csv); ///< writes column headings + static void AddSqlColumns(std::string& columnString); + void ReadSql(tcSqlReader& entry); + void WriteSql(std::string& valueString); + tcAirDBObject(); tcAirDBObject(tcAirDBObject& obj); ///< copy constructor Index: CsvTranslator.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/database/CsvTranslator.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CsvTranslator.h 28 Mar 2004 14:26:35 -0000 1.3 --- CsvTranslator.h 8 Aug 2004 00:31:32 -0000 1.4 *************** *** 2,6 **** ** CsvTranslator.h ** ! ** Copyright (C) 2003 Dewitt "Cole" Colclough (de...@tw...) ** All rights reserved. --- 2,6 ---- ** CsvTranslator.h ** ! ** Copyright (C) 2003 Dewitt Colclough (de...@tw...) ** All rights reserved. Index: tcDatabaseObject.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/database/tcDatabaseObject.h,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** tcDatabaseObject.h 29 Jul 2004 00:14:16 -0000 1.14 --- tcDatabaseObject.h 8 Aug 2004 00:31:32 -0000 1.15 *************** *** 1,6 **** ! /* ! ** tcDatabaseObject.h ! ** ! ** Copyright (C) 2003 Dewitt "Cole" Colclough (de...@tw...) ** All rights reserved. --- 1,6 ---- ! /** ! ** @file tcDatabaseObject.h ! */ ! /* Copyright (C) 2003-2004 Dewitt Colclough (de...@tw...) ** All rights reserved. *************** *** 45,48 **** --- 45,49 ---- class tcDatabase; class CsvTranslator; + class tcSqlReader; /************** VERSION INFO ***************/ *************** *** 139,144 **** --- 140,153 ---- int Serialize(tcFile& file, bool mbLoad, UINT32 anVersion); int SerializeCSV(CsvTranslator* csv, bool mbLoad); ///< CSV serialization + virtual void SerializeXml(TiXmlElement* node, bool load); ///< XML serialization + + static void AddSqlColumns(std::string& columnString); + void ReadSql(tcSqlReader& entry); + void WriteSql(std::string& valueString); + + static int WriteCSVHeader(CsvTranslator* csv); ///< writes column headings + tcDatabaseObject(); tcDatabaseObject(tcDatabaseObject& obj); ///< copy constructor Index: tcDBString.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/database/tcDBString.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** tcDBString.h 13 Apr 2004 00:24:37 -0000 1.4 --- tcDBString.h 8 Aug 2004 00:31:32 -0000 1.5 *************** *** 2,6 **** ** tcDBString.h ** ! ** Copyright (C) 2003 Dewitt "Cole" Colclough (de...@tw...) ** All rights reserved. --- 2,6 ---- ** tcDBString.h ** ! ** Copyright (C) 2003 Dewitt Colclough (de...@tw...) ** All rights reserved. --- NEW FILE: tcSqlReader.h --- /** ** @file tcSqlReader.h */ /* Copyright (C) 2004 Dewitt Colclough (de...@tw...) ** All rights reserved. ** ** This file is part of the Global Conflict Blue (GCB) program. ** GCB is free software; you can redistribute it and/or modify ** it under the terms of version 2 of the GNU General Public License as ** published by the Free Software Foundation. ** ** GCB is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with GCB; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _TCSQLREADER_H_ #define _TCSQLREADER_H_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include <string> #include <map> namespace sqlite { class reader; } /** * Saves/loads objects of class T from database. * Class T is any class derived from tcDatabaseObject. * Class T should be a leaf class for this to work properly. * * SQL version of serializer to work with sqlite3 and sqlite3_plus * C++ wrapper */ namespace Database { /** * Class to wrap SQL sqlite_plus::reader class for reading by * column name */ class tcSqlReader { public: double GetDouble(std::string& field); int GetInt(std::string& field); std::string GetString(std::string& field); bool Read(); tcSqlReader(sqlite::reader& tableInfo, sqlite::reader& _data); ~tcSqlReader(); private: std::map<std::string, unsigned int> columnLookup; sqlite::reader& data; void BuildColumnLookup(sqlite::reader& tableInfo); unsigned int LookupFieldIndex(std::string& field); }; } // namespace Database #endif Index: tcBallisticDBObject.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/database/tcBallisticDBObject.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** tcBallisticDBObject.h 5 Aug 2004 02:22:34 -0000 1.2 --- tcBallisticDBObject.h 8 Aug 2004 00:31:32 -0000 1.3 *************** *** 33,36 **** --- 33,38 ---- namespace Database { + class tcSqlReader; + class tcBallisticDBObject : public tcWeaponDBObject { *************** *** 46,49 **** --- 48,55 ---- static int WriteCSVHeader(CsvTranslator* csv); ///< writes column headings + static void AddSqlColumns(std::string& columnString); + void ReadSql(tcSqlReader& entry); + void WriteSql(std::string& valueString); + tcBallisticDBObject(tcBallisticDBObject& obj); ///< copy constructor tcBallisticDBObject(); Index: tcMissileDBObject.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/database/tcMissileDBObject.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** tcMissileDBObject.h 27 Jul 2004 00:16:23 -0000 1.10 --- tcMissileDBObject.h 8 Aug 2004 00:31:32 -0000 1.11 *************** *** 33,36 **** --- 33,38 ---- namespace Database { + class tcSqlReader; + /** * This isn't used currently. Notionally there will be different *************** *** 140,143 **** --- 142,150 ---- virtual void SerializeXml(TiXmlElement* node, bool load); ///< XML serialization static int WriteCSVHeader(CsvTranslator* csv); ///< writes column headings + + static void AddSqlColumns(std::string& columnString); + void ReadSql(tcSqlReader& entry); + void WriteSql(std::string& valueString); + tcMissileDBObject(); tcMissileDBObject(tcMissileDBObject& obj); ///< copy constructor --- NEW FILE: tcDBObjSerializerSql.h --- /** ** @file tcDBObjSerializerSql.h */ /* Copyright (C) 2003-2004 Dewitt Colclough (de...@tw...) ** All rights reserved. ** This file is part of the Global Conflict Blue (GCB) program. ** GCB is free software; you can redistribute it and/or modify ** it under the terms of version 2 of the GNU General Public License as ** published by the Free Software Foundation. ** GCB is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** You should have received a copy of the GNU General Public License ** along with GCB; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _DBOBJSERIALIZERSQL_H_ #define _DBOBJSERIALIZERSQL_H_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include "tcDatabase.h" #include <iostream> #include <fstream> #include <string> #include "sqlite/sqlite_plus.h" #include <wx/wx.h> #ifdef WIN32 #include <wx/msw/private.h> // for MS Windows specific definitions #endif /** * Saves/loads objects of class T from database. * Class T is any class derived from tcDatabaseObject. * Class T should be a leaf class for this to work properly. * * SQL version of serializer to work with sqlite3 and sqlite3_plus * C++ wrapper */ namespace Database { template <class T> class tcDBObjSerializerSql { public: tcDBObjSerializerSql(tcDatabase* db, sqlite::connection& con, std::string s) : database(db), sqlConn(con), tableName(s) {} bool Load(); bool Save(); private: tcDatabase* database; std::string tableName; sqlite::connection& sqlConn; }; template <class T> bool tcDBObjSerializerSql<T>::Load() { // 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; } return true; } /** * This version starts from a clean slate, first erasing the table * in the database if it exists. */ template <class T> bool tcDBObjSerializerSql<T>::Save() { try { // delete table if it exists string countStr = sqlConn.executescalar( "select count(*) from sqlite_master where name='%s';", tableName.c_str() ); if (countStr != "0") { sqlConn.executenonquery("drop table %s;", tableName.c_str()); } std::string columnString; T::AddSqlColumns(columnString); #ifdef _DEBUG fprintf(stdout, "column str: (%s)\n", columnString.c_str()); #endif sqlConn.executenonquery( "create table %s (%s);", tableName.c_str(), columnString.c_str()); } catch(exception &ex) { wxString message = wxString::Format("Database error in table %s: %s", tableName.c_str(), ex.what()); wxMessageBox(message.GetData(), "Error", wxICON_ERROR); } tnPoolIndex key; tnPoolIndex nEntries = database->mcObjectData.GetCount(); tnPoolIndex pos = database->mcObjectData.GetStartPosition(); tcDatabaseObject* dbObj; for (tnPoolIndex n=0;n<nEntries;n++) { database->mcObjectData.GetNextAssoc(pos, key, dbObj); if (T* obj = dynamic_cast<T*>(dbObj)) { try { std::string valueString; obj->WriteSql(valueString); #ifdef _DEBUG fprintf(stdout, "value str: (%s)\n", valueString.c_str()); #endif sqlConn.executenonquery( "insert into %s values (%s);", tableName.c_str(), valueString.c_str()); } catch(exception &ex) { wxString message = wxString::Format( "Error in table: %s, entry: %s, %s", tableName.c_str(), dbObj->mzClass.mz, ex.what()); wxMessageBox(message.GetData(), "Database Error", wxICON_ERROR); } } } return true; } } // namespace Database #endif Index: tcDBObjSerializer.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/database/tcDBObjSerializer.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** tcDBObjSerializer.h 28 Mar 2004 18:45:34 -0000 1.2 --- tcDBObjSerializer.h 8 Aug 2004 00:31:32 -0000 1.3 *************** *** 1,18 **** ! /* ! ** tcDBObjSerializer.h ! ** ! ** Copyright (C) 2003 Dewitt "Cole" Colclough (de...@tw...) ** All rights reserved. ! ** This file is part of the Global Conflict Blue (GCB) program. ** GCB is free software; you can redistribute it and/or modify ** it under the terms of version 2 of the GNU General Public License as ** published by the Free Software Foundation. ! ** GCB is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ! ** You should have received a copy of the GNU General Public License ** along with GCB; if not, write to the Free Software --- 1,18 ---- ! /** ! ** @file tcDBObjSerializer.h ! */ ! /* Copyright (C) 2003 Dewitt Colclough (de...@tw...) ** All rights reserved. ! ** ** This file is part of the Global Conflict Blue (GCB) program. ** GCB is free software; you can redistribute it and/or modify ** it under the terms of version 2 of the GNU General Public License as ** published by the Free Software Foundation. ! ** ** GCB is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ! ** ** You should have received a copy of the GNU General Public License ** along with GCB; if not, write to the Free Software Index: tcDatabase.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/database/tcDatabase.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** tcDatabase.h 18 Jul 2004 03:17:59 -0000 1.6 --- tcDatabase.h 8 Aug 2004 00:31:32 -0000 1.7 *************** *** 1,18 **** ! /* ! ** tcDatabase.h ! ** ! ** Copyright (C) 2003 Dewitt "Cole" Colclough (de...@tw...) ** All rights reserved. ! ** This file is part of the Global Conflict Blue (GCB) program. ** GCB is free software; you can redistribute it and/or modify ** it under the terms of version 2 of the GNU General Public License as ** published by the Free Software Foundation. ! ** GCB is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ! ** You should have received a copy of the GNU General Public License ** along with GCB; if not, write to the Free Software --- 1,18 ---- ! /** ! ** @file tcDatabase.h ! */ ! /* Copyright (C) 2003-2004 Dewitt Colclough (de...@tw...) ** All rights reserved. ! ** ** This file is part of the Global Conflict Blue (GCB) program. ** GCB is free software; you can redistribute it and/or modify ** it under the terms of version 2 of the GNU General Public License as ** published by the Free Software Foundation. ! ** ** GCB is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ! ** ** You should have received a copy of the GNU General Public License ** along with GCB; if not, write to the Free Software *************** *** 93,96 **** --- 93,97 ---- int Serialize(tcFile& file, bool mbLoad); int SerializeCSV(std::string suffix, bool mbLoad); + void SerializeSql(std::string suffix, bool mbLoad); void SerializeXml(std::string suffix, bool load); Index: tcFlightportDBObject.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/database/tcFlightportDBObject.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** tcFlightportDBObject.h 28 Mar 2004 23:12:27 -0000 1.3 --- tcFlightportDBObject.h 8 Aug 2004 00:31:32 -0000 1.4 *************** *** 1,5 **** /** @file tcFlightportDBObject.h */ /* ! ** Copyright (C) 2003 Dewitt "Cole" Colclough (de...@tw...) ** All rights reserved. --- 1,5 ---- /** @file tcFlightportDBObject.h */ /* ! ** Copyright (C) 2003 Dewitt Colclough (de...@tw...) ** All rights reserved. *************** *** 33,36 **** --- 33,38 ---- namespace Database { + class tcSqlReader; + /** * Data for flightport model. *************** *** 62,65 **** --- 64,72 ---- virtual void SerializeXml(TiXmlElement* node, bool load); ///< XML serialization static int WriteCSVHeader(CsvTranslator* csv); ///< writes column headings + + static void AddSqlColumns(std::string& columnString); + void ReadSql(tcSqlReader& entry); + void WriteSql(std::string& valueString); + tcFlightportDBObject(); tcFlightportDBObject(tcFlightportDBObject& obj); ///< copy constructor |