src/DAL/Query.h

Go to the documentation of this file.
00001 #ifdef _WIN32
00002 #ifndef __MINGW32__
00003 #pragma warning(disable:4786)
00004 #endif
00005 #endif
00006 /*
00007  **     Query.h
00008  **
00009  **     Published / author: 2005-08-12 / grymse@alhem.net
00010  **/
00011 
00012 /*
00013 Copyright (C) 2001-2006  Anders Hedstrom
00014 
00015 This program is free software; you can redistribute it and/or
00016 modify it under the terms of the GNU General Public License
00017 as published by the Free Software Foundation; either version 2
00018 of the License, or (at your option) any later version.
00019 
00020 This program is distributed in the hope that it will be useful,
00021 but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 GNU General Public License for more details.
00024 
00025 You should have received a copy of the GNU General Public License
00026 along with this program; if not, write to the Free Software
00027 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00028 */
00029 
00030 #ifndef _QUERY_H_SQLITE
00031 #define _QUERY_H_SQLITE
00032 
00040 #include <string>
00041 #include <map>
00042 #ifdef WIN32
00043 typedef unsigned __int64 uint64_t;
00044 typedef __int64 int64_t;
00045 #else
00046 #include <stdint.h>
00047 #endif
00048 
00049 
00050 #ifdef SQLITEW_NAMESPACE
00051 namespace SQLITEW_NAMESPACE {
00052 #endif
00053 
00054 
00056 class Query
00057 {
00058 public:
00060         Query(Database& dbin);
00063         Query(Database& dbin,const std::string& sql);
00065         ~Query();
00066 
00068         bool Connected();
00070         Database& GetDatabase() const;
00072         const std::string& GetLastQuery();
00073 
00076         bool execute(const std::string& sql);
00078         sqlite3_stmt *get_result(const std::string& sql);
00081         void free_result();
00084         bool fetch_row();
00086         sqlite_int64 insert_id();
00088         long num_rows();
00090         std::string GetError();
00092         int GetErrno();
00093 
00095         const char *get_string(const std::string& sql);
00097         long get_count(const std::string& sql);
00099         double get_num(const std::string& sql);
00100 
00102         bool is_null(int x);
00103 
00105         const char *getstr(const std::string& x);
00107         const char *getstr(int x);
00109         const char *getstr();
00110 
00112         long getval(const std::string& x);
00114         long getval(int x);
00116         long getval();
00117 
00119         unsigned long getuval(const std::string& x);
00121         unsigned long getuval(int x);
00123         unsigned long getuval();
00124 
00126         int64_t getbigint(const std::string& x);
00128         int64_t getbigint(int x);
00130         int64_t getbigint();
00131 
00133         uint64_t getubigint(const std::string& x);
00135         uint64_t getubigint(int x);
00137         uint64_t getubigint();
00138 
00140         double getnum(const std::string& x);
00142         double getnum(int x);
00144         double getnum();
00145 
00146 private:
00148         Query(const Query& q) : m_db(q.GetDatabase()) {}
00150         Query& operator=(const Query& ) { return *this; }
00152         void ViewRes();
00154         void error(const std::string& );
00155         Database& m_db; 
00156         Database::OPENDB *odb; 
00157         sqlite3_stmt *res; 
00158         bool row; 
00159         short rowcount; 
00160         std::string m_tmpstr; 
00161         std::string m_last_query; 
00162         int cache_rc; 
00163         bool cache_rc_valid; 
00164         int m_row_count; 
00165         //
00166         std::map<std::string,int> m_nmap; 
00167         int m_num_cols; 
00168 };
00169 
00170 
00171 #ifdef SQLITEW_NAMESPACE
00172 } // namespace SQLITEW_NAMESPACE {
00173 #endif
00174 
00175 #endif // _QUERY_H

Generated for UnsignedByte by  doxygen 1.5.3
SourceForge.net Logo