Changeset 129 for trunk/src/sql_Database.h
- Timestamp:
- 11/18/09 04:40:30 (3 years ago)
- Files:
-
- 1 modified
-
trunk/src/sql_Database.h (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sql_Database.h
r127 r129 1 /* 1 /** 2 2 ** Database.h 3 3 ** 4 ** Published / author: 200 5-08-12/ grymse@alhem.net4 ** Published / author: 2001-02-15 / grymse@alhem.net 5 5 **/ 6 6 7 7 /* 8 Copyright (C) 2001 -2006Anders Hedstrom8 Copyright (C) 2001 Anders Hedstrom 9 9 10 10 This program is made available under the terms of the GNU GPL. 11 11 12 12 If you would like to use this program in a closed-source application, 13 a separate license agreement is available. For information about 13 a separate license agreement is available. For information about 14 14 the closed-source license agreement for this program, please 15 15 visit http://www.alhem.net/sqlwrapped/license.html and/or … … 31 31 */ 32 32 33 #ifndef _DATABASE_H _SQLITE34 #define _DATABASE_H _SQLITE33 #ifndef _DATABASE_H 34 #define _DATABASE_H 35 35 36 36 #ifdef _WIN32 … … 48 48 #endif 49 49 50 #include <sqlite3.h> 51 #include "sql_Database.h" 52 53 #ifdef SQLITEW_NAMESPACE 54 namespace SQLITEW_NAMESPACE { 50 #ifdef MYSQLW_NAMESPACE 51 namespace MYSQLW_NAMESPACE { 55 52 #endif 56 57 53 58 54 class IError; … … 61 57 62 58 63 /** Connection information and pool . */64 class Database 59 /** Connection information and pooling. */ 60 class Database 65 61 { 62 /** Mutex container class, used by Lock. 63 \ingroup threading */ 66 64 public: 67 /** Mutex container class, used by Lock.68 \ingroup threading */69 65 class Mutex { 70 66 public: … … 80 76 #endif 81 77 }; 78 /** Mutex helper class. */ 82 79 private: 83 /** Mutex helper class. */84 80 class Lock { 85 81 public: … … 94 90 struct OPENDB { 95 91 OPENDB() : busy(false) {} 96 sqlite3 *db;92 MYSQL mysql; 97 93 bool busy; 98 94 }; 99 95 typedef std::list<OPENDB *> opendb_v; 96 97 // Temp container for strip_escape 98 std::string d_tmpstr; 100 99 101 100 public: 102 /** Use file*/101 /** Use embedded libmysqld */ 103 102 Database(const std::string& database, 104 103 IError * = NULL); 105 104 106 /** Use file+ thread safe */105 /** Use embedded libmysqld + thread safe */ 107 106 Database(Mutex& ,const std::string& database, 108 107 IError * = NULL); 109 108 109 /** Connect to a MySQL server */ 110 Database(const std::string& host, 111 const std::string& user, 112 const std::string& password = "", 113 const std::string& database = "", 114 IError * = NULL); 115 116 /** Connect to a MySQL server + thread safe */ 117 Database(Mutex& ,const std::string& host, 118 const std::string& user, 119 const std::string& password = "", 120 const std::string& database = "", 121 IError * = NULL); 122 110 123 virtual ~Database(); 124 125 /** Callback after mysql_init */ 126 virtual void OnMyInit(OPENDB *); 111 127 112 128 /** try to establish connection with given host */ … … 115 131 void RegErrHandler(IError *); 116 132 void error(Query&,const char *format, ...); 117 void error(Query&,const std::string& );118 133 119 134 /** Request a database connection. … … 135 150 void freedb(OPENDB *odb); 136 151 137 / ** Escape string - change all ' to ''. */152 // utility 138 153 std::string safestr(const std::string& ); 139 /** Make string xml safe. */154 std::string unsafestr(const std::string& ); 140 155 std::string xmlsafestr(const std::string& ); 141 156 142 /** Convert string to 64-bit integer. */143 157 int64_t a2bigint(const std::string& ); 144 /** Convert string to unsigned 64-bit integer. */145 158 uint64_t a2ubigint(const std::string& ); 159 160 char *strip_escape(OPENDB *qodb, char* Oldstr); 146 161 147 162 private: … … 150 165 void error(const char *format, ...); 151 166 // 167 std::string host; 168 std::string user; 169 std::string password; 152 170 std::string database; 153 171 opendb_v m_opendbs; … … 158 176 }; 159 177 160 161 #ifdef SQLITEW_NAMESPACE 162 } // namespace SQLITEW_NAMESPACE { 178 #ifdef MYSQLW_NAMESPACE 179 } //namespace MYSQLW_NAMESPACE { 163 180 #endif 164 181 182 165 183 #endif // _DATABASE_H
Enthral BBS Software for *nix/bsd/osx