Changeset 129 for trunk/src/sql_Query.h

Show
Ignore:
Timestamp:
11/18/09 04:40:30 (3 years ago)
Author:
mercyful
Message:

$ Build 438/Sql Alpha
+ Removed all SQLite Code and References.
+ Updated the SQL Wrapper, and all Automake files to now link in and also Detect MySql? in the configure scripts.
+ Added detection for OpenSSL, not in use yet, but will add encryption for passwords.

and anything else of intertest once everything is moved over to the SQL Backend.

This is still an interm develop update release, the MySql? backend
is still a WIP, and the Husky SMAPI Library will be removed shortly.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/sql_Query.h

    r127 r129  
    55 **     Query.h 
    66 ** 
    7  **     Published / author: 2005-08-12 / grymse@alhem.net 
     7 **     Published / author: 2001-02-15 / grymse@alhem.net 
    88 **/ 
    99 
    1010/* 
    11 Copyright (C) 2001-2006  Anders Hedstrom 
     11Copyright (C) 2001  Anders Hedstrom 
    1212 
    1313This program is made available under the terms of the GNU GPL. 
     
    3434*/ 
    3535 
    36 #ifndef _QUERY_H_SQLITE 
    37 #define _QUERY_H_SQLITE 
     36#ifndef _QUERY_H 
     37#define _QUERY_H 
    3838 
    3939#include <string> 
     
    4747 
    4848 
    49 #ifdef SQLITEW_NAMESPACE 
    50 namespace SQLITEW_NAMESPACE { 
     49#ifdef MYSQLW_NAMESPACE 
     50namespace MYSQLW_NAMESPACE { 
    5151#endif 
    5252 
    5353 
    54 /** SQL Statement execute / result. */ 
     54/** SQL Statement execute / result set helper class. */ 
    5555class Query  
    5656{ 
     
    5959        Query(Database& dbin); 
    6060        /** Constructor accepting reference to database object 
    61                 and query string to execute. */ 
     61                and query to execute. */ 
    6262        Query(Database& dbin,const std::string& sql); 
    6363        ~Query(); 
    6464 
    65         /** Check if database object is connectable. */ 
     65        /** Check to see if database object is connectable. */ 
    6666        bool Connected(); 
    6767        /** Return reference to database object. */ 
    6868        Database& GetDatabase() const; 
    69         /** Return string containing last query executed. */ 
     69        /** Return string of last query executed. */ 
    7070        const std::string& GetLastQuery(); 
    7171 
    7272        /** execute() returns true if query is successful, 
    73                 does not store result. */ 
     73                does not store result */ 
    7474        bool execute(const std::string& sql); 
     75        /** execute query and store result. */ 
     76        MYSQL_RES *get_result(const std::string& sql); 
    7577 
    76         /** Execute query and store result. */ 
    77         sqlite3_stmt *get_result(const std::string& sql); 
    78         /** Free stored result, must be called after get_result() before calling  
    79                 execute()/get_result() again. */ 
     78        /** free stored result, must be called after get_result() */ 
    8079        void free_result(); 
    8180        /** Fetch next result row. 
    8281                \return false if there was no row to fetch (end of rows) */ 
    83         bool fetch_row(); 
     82        MYSQL_ROW fetch_row(); 
    8483        /** Get id of last insert. */ 
    85         sqlite_int64 insert_id(); 
    86         /** Returns 0 if there are no rows to fetch. */ 
     84        my_ulonglong insert_id(); 
     85        /** Returns number of rows returned by last select call. */ 
    8786        long num_rows(); 
    8887        /** Number of columns in current result. */ 
     
    9493 
    9594        /** Check if column x in current row is null. */ 
     95        bool is_null(const std::string& x); 
    9696        bool is_null(int x); 
     97        bool is_null(); 
    9798 
    9899        /** Execute query and return first result as a string. */ 
     
    103104        double get_num(const std::string& sql); 
    104105 
    105         /** Return column named x as a string value. */ 
    106106        const char *getstr(const std::string& x); 
    107         /** Return column x as a string value. */ 
    108107        const char *getstr(int x); 
    109         /** Return next column as a string value - see rowcount. */ 
    110108        const char *getstr(); 
    111  
    112         /** Return column named x as a long integer. */ 
    113109        long getval(const std::string& x); 
    114         /** Return column x as a long integer. */ 
    115110        long getval(int x); 
    116         /** Return next column as a long integer - see rowcount. */ 
    117111        long getval(); 
    118  
    119         /** Return column named x as an unsigned long integer. */ 
    120112        unsigned long getuval(const std::string& x); 
    121         /** Return column x as an unsigned long integer. */ 
    122113        unsigned long getuval(int x); 
    123         /** Return next column as an unsigned long integer. */ 
    124114        unsigned long getuval(); 
    125  
    126         /** Return column named x as a 64-bit integer value. */ 
    127115        int64_t getbigint(const std::string& x); 
    128         /** Return column x as a 64-bit integer value. */ 
    129116        int64_t getbigint(int x); 
    130         /** Return next column as a 64-bit integer value. */ 
    131117        int64_t getbigint(); 
    132  
    133         /** Return column named x as an unsigned 64-bit integer value. */ 
    134118        uint64_t getubigint(const std::string& x); 
    135         /** Return column x as an unsigned 64-bit integer value. */ 
    136119        uint64_t getubigint(int x); 
    137         /** Return next column as an unsigned 64-bit integer value. */ 
    138120        uint64_t getubigint(); 
    139  
    140         /** Return column named x as a double. */ 
    141121        double getnum(const std::string& x); 
    142         /** Return column x as a double. */ 
    143122        double getnum(int x); 
    144         /** Return next column as a double. */ 
    145123        double getnum(); 
    146124 
     125        std::string safestr(const std::string& x); 
     126        char *strip(char* Oldstr); 
     127 
     128protected: 
     129        Query(Database *dbin); 
     130        Query(Database *dbin,const std::string& sql); 
    147131private: 
    148         /** Hide the copy constructor. */ 
    149132        Query(const Query& q) : m_db(q.GetDatabase()) {} 
    150         /** Hide the assignment operator. */ 
    151133        Query& operator=(const Query& ) { return *this; } 
    152         /** Print current result to stdout. */ 
    153         void ViewRes(); 
    154         /** Print error to debug class. */ 
    155134        void error(const std::string& ); 
    156         Database& m_db; ///< Reference to database object 
    157         Database::OPENDB *odb; ///< Connection pool handle 
    158         sqlite3_stmt *res; ///< Stored result 
    159         bool row; ///< true if fetch_row succeeded 
    160         short rowcount; ///< Current column pointer in result 
    161         std::string m_tmpstr; ///< Used to store result in get_string() call 
    162         std::string m_last_query; ///< Last query executed 
    163         int cache_rc; ///< Cached result after call to get_result() 
    164         bool cache_rc_valid; ///< Indicates cache_rc is valid 
    165         int m_row_count; ///< 0 if get_result() returned no rows 
    166         // 
    167         std::map<std::string,int> m_nmap; ///< map translating column names to index 
    168         int m_num_cols; ///< number of columns in result 
     135        Database& m_db; 
     136        Database::OPENDB *odb; 
     137        MYSQL_RES *res; 
     138        MYSQL_ROW row; 
     139        short rowcount; 
     140        std::string m_tmpstr; 
     141        std::string m_last_query; 
     142        std::map<std::string,int> m_nmap; 
     143        int m_num_cols; 
    169144}; 
    170145 
    171146 
    172 #ifdef SQLITEW_NAMESPACE 
    173 } // namespace SQLITEW_NAMESPACE { 
     147#ifdef MYSQLW_NAMESPACE 
     148} // namespace MYSQLW_NAMESPACE { 
    174149#endif 
    175150