connection類--初步修改

#ifndef CONNECTION_HPP
#define CONNECTION_HPP
#include <mysql/mysql.h>
#include <string>
#include <map>
#include <vector>
#include "sqlerror.hpp"

namespace sqlpp
{
  class Connection
  {
  public:
    Connection();
    Connection(const std::string& database, const std::string& server, const std::string& user, const std::string& password);
    Connection(const char* database, const char* server, const char* user, const char* password);
    virtual ~Connection();

    void connect()throw(sqlerror);
    void connect(const std::string& database, const std::string& server, const std::string& user, const std::string& password)throw(sqlerror);
    void connect(const char* database, const char* server, const char* user, const char* password)throw(sqlerror);
    bool is_open(void)throw();
    void close(void)throw();

    std::string   get_client_info(void) throw(sqlerror);
    unsigned long get_client_version(void) throw(sqlerror);
    std::string   get_host_info(void) throw(sqlerror);
    unsigned int  get_protocol_version(void) throw(sqlerror);
    std::string   get_server_info(void) throw(sqlerror);
    unsigned long get_server_version(void) throw(sqlerror);

    MYSQL* get_mysql_handle(void)throw();   
    unsigned long exceute(const std::string& cmd)throw(sqlerror);
    const std::string& get_user(void)const throw();
    const std::string& get_database(void)const throw();
    const std::string& get_server(void)const throw();
    const std::string& get_password(void)const throw();

    void set_user(const std::string& user)throw();
    void set_database(const std::string& database)throw();
    void set_server(const std::string& server)throw();
    void set_password(const std::string& password)throw();
    void check_exception(void) throw(sqlerror);  

protected:
  private:
    //forbid copy construct
    Connection(const Connection& rh);
    //forbid assign
    const Connection& operator=(const Connection& rh);

    std::string _user;
    std::string _database;
    std::string _password;
    std::string _server;
    
    bool _is_open;
    MYSQL _mysql;
  };
};
#endif

發佈了66 篇原創文章 · 獲贊 0 · 訪問量 9萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章