#ifndef CONNECTION_HPP
#define CONNECTION_HPP
#include <mysql/mysql.h>
#include <string>
#include <map>
#include <vector>
#include "sqlerror.hpp"
#include "table.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);
void download(Table& target) throw(sqlerror);
void online_start(std::map<int,std::string>& row, const std::string& cmd) throw(sqlerror);
void online_next(std::map<int,std::string>& row)throw(sqlerror);
bool online_is_eof(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();
protected:
private:
//forbid copy construct
Connection(const Connection& rh);
//forbid assign
const Connection& operator=(const Connection& rh);
void check_exception(void) throw(sqlerror);
std::string _user;
std::string _database;
std::string _password;
std::string _server;
//for online assess
unsigned int _num_fields;
MYSQL_RES* _ptr_result;
bool _is_open;
MYSQL _mysql;
};
};
#endif
#define CONNECTION_HPP
#include <mysql/mysql.h>
#include <string>
#include <map>
#include <vector>
#include "sqlerror.hpp"
#include "table.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);
void download(Table& target) throw(sqlerror);
void online_start(std::map<int,std::string>& row, const std::string& cmd) throw(sqlerror);
void online_next(std::map<int,std::string>& row)throw(sqlerror);
bool online_is_eof(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();
protected:
private:
//forbid copy construct
Connection(const Connection& rh);
//forbid assign
const Connection& operator=(const Connection& rh);
void check_exception(void) throw(sqlerror);
std::string _user;
std::string _database;
std::string _password;
std::string _server;
//for online assess
unsigned int _num_fields;
MYSQL_RES* _ptr_result;
bool _is_open;
MYSQL _mysql;
};
};
#endif