src/DAL/Database.h

Go to the documentation of this file.
00001 /*
00002  **     Database.h
00003  **
00004  **     Published / author: 2005-08-12 / grymse@alhem.net
00005  **/
00006 
00007 /*
00008 Copyright (C) 2001-2006  Anders Hedstrom
00009 
00010 This program is free software; you can redistribute it and/or
00011 modify it under the terms of the GNU General Public License
00012 as published by the Free Software Foundation; either version 2
00013 of the License, or (at your option) any later version.
00014 
00015 This program is distributed in the hope that it will be useful,
00016 but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 GNU General Public License for more details.
00019 
00020 You should have received a copy of the GNU General Public License
00021 along with this program; if not, write to the Free Software
00022 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00023 */
00024 
00025 #ifndef _DATABASE_H_SQLITE
00026 #define _DATABASE_H_SQLITE
00027 
00035 #include <string>
00036 #include <list>
00037 
00038 #include <stdint.h>
00039 #include <sqlite3.h>
00040 
00041 #ifdef SQLITEW_NAMESPACE
00042 namespace SQLITEW_NAMESPACE {
00043 #endif
00044 
00045 
00047 class Database 
00048 {
00049 public:
00051         struct OPENDB {
00053                 OPENDB() : busy(false) {}
00054                 sqlite3 *db; 
00055                 bool busy; 
00056         };
00057         typedef std::list<OPENDB *> opendb_v; 
00058 
00059 public:
00061         Database(const std::string& database);
00062 
00064         virtual ~Database();
00065 
00067         bool Connected();
00068 
00084         OPENDB *grabdb();
00085         
00087         void freedb(OPENDB *odb);
00088 
00090         std::string safestr(const std::string& );
00092         std::string xmlsafestr(const std::string& );
00093 
00095         int64_t a2bigint(const std::string& );
00097         uint64_t a2ubigint(const std::string& );
00098 
00099 private:
00101         Database(const Database& );     
00103         Database& operator=(const Database& );
00104         
00106         void error(const char *format, ...);
00107 
00108         std::string database; 
00109         opendb_v m_opendbs; 
00110 };
00111 
00112 
00113 #ifdef SQLITEW_NAMESPACE
00114 } // namespace SQLITEW_NAMESPACE {
00115 #endif
00116 
00117 #endif // _DATABASE_H

Generated for UnsignedByte by  doxygen 1.5.3
SourceForge.net Logo