bf0e4b3714
also move the header files to ${LOCALBASE}/include/mysql++
148 lines
6.4 KiB
Plaintext
148 lines
6.4 KiB
Plaintext
$OpenBSD: patch-sqlplusint_connection1_hh,v 1.2 2004/01/06 11:16:53 wilfried Exp $
|
|
--- sqlplusint/connection1.hh.orig 2001-05-19 18:44:49.000000000 +0200
|
|
+++ sqlplusint/connection1.hh 2004-01-05 18:58:19.000000000 +0100
|
|
@@ -8,13 +8,11 @@
|
|
#define errno WSAGetLastError()
|
|
#endif
|
|
#include <mysql.h>
|
|
-#include <vector.h>
|
|
-#include <deque.h>
|
|
-#include <list.h>
|
|
-#include <slist.h>
|
|
-#include <set.h>
|
|
-#include <map.h>
|
|
-#include <multiset.h>
|
|
+#include <vector>
|
|
+#include <deque>
|
|
+#include <list>
|
|
+#include <set>
|
|
+#include <map>
|
|
#include "define_short"
|
|
#include "exceptions.hh"
|
|
#include "query1.hh"
|
|
@@ -22,21 +20,21 @@
|
|
|
|
//: The main database handle
|
|
class Connection {
|
|
- friend ResNSel;
|
|
- friend ResUse;
|
|
- friend Query;
|
|
+ friend class ResNSel;
|
|
+ friend class ResUse;
|
|
+ friend class Query;
|
|
|
|
private:
|
|
bool throw_exceptions;
|
|
MYSQL mysql;
|
|
bool is_connected;
|
|
bool locked;
|
|
- bool Success;
|
|
+ bool Success_;
|
|
|
|
public:
|
|
Connection () : throw_exceptions(true), locked(false)
|
|
{mysql_init(&mysql);} //:
|
|
- Connection (bool te) : throw_exceptions(te), is_connected(false), locked(true), Success(false) //:
|
|
+ Connection (bool te) : throw_exceptions(te), is_connected(false), locked(true), Success_(false) //:
|
|
{mysql_init(&mysql);} //:
|
|
Connection (const char *db, const char *host = "", const char *user = "",
|
|
const char *passwd = "", bool te = true); //:
|
|
@@ -52,12 +50,12 @@ public:
|
|
|
|
~Connection (); //:
|
|
void close() {mysql_close(&mysql);} //:
|
|
- string info (); //:
|
|
+ std::string info (); //:
|
|
|
|
bool connected() const {return is_connected;}
|
|
//: returns true if a successful connection was made
|
|
|
|
- bool success() {return Success;}
|
|
+ bool success() {return Success_;}
|
|
//: returns true of the last query was successful
|
|
|
|
bool connect (cchar *db = "", cchar *host = "",
|
|
@@ -74,59 +72,57 @@ public:
|
|
//:
|
|
|
|
operator bool () {return success();} //: returns success()
|
|
- string error () {return string(mysql_error(&mysql));} //: last error message()
|
|
+ std::string error () {return std::string(mysql_error(&mysql));} //: last error message()
|
|
int errnum () {return mysql_errno(&mysql);}
|
|
int refresh (unsigned int refresh_options){ return mysql_refresh (&mysql,refresh_options); }
|
|
int ping (void) { return mysql_ping(&mysql);}
|
|
int kill (unsigned long pid) { return mysql_kill (&mysql,pid);}
|
|
- string client_info () {return string(mysql_get_client_info());} //:
|
|
+ std::string client_info () {return std::string(mysql_get_client_info());} //:
|
|
|
|
- string host_info () {return string(mysql_get_host_info(&mysql));} //:
|
|
+ std::string host_info () {return std::string(mysql_get_host_info(&mysql));} //:
|
|
|
|
int proto_info () {return mysql_get_proto_info(&mysql);} //:
|
|
|
|
- string server_info () {return string(mysql_get_server_info(&mysql));} //:
|
|
+ std::string server_info () {return std::string(mysql_get_server_info(&mysql));} //:
|
|
|
|
- string stat() {return string(mysql_stat(&mysql));} //:
|
|
+ std::string stat() {return std::string(mysql_stat(&mysql));} //:
|
|
|
|
- Result store(const string &str) {return store(str, throw_exceptions);} //:
|
|
- ResUse use(const string &str) {return use(str, throw_exceptions);} //:
|
|
- ResNSel execute(const string &str) {return execute(str, throw_exceptions);} //:
|
|
- bool exec (const string &str);
|
|
- Result store(const string &str, bool te); //:
|
|
- ResUse use(const string &str, bool te); //:
|
|
- ResNSel execute(const string &str, bool te); //:
|
|
+ Result store(const std::string &str) {return store(str, throw_exceptions);} //:
|
|
+ ResUse use(const std::string &str) {return use(str, throw_exceptions);} //:
|
|
+ ResNSel execute(const std::string &str) {return execute(str, throw_exceptions);} //:
|
|
+ bool exec (const std::string &str);
|
|
+ Result store(const std::string &str, bool te); //:
|
|
+ ResUse use(const std::string &str, bool te); //:
|
|
+ ResNSel execute(const std::string &str, bool te); //:
|
|
|
|
- bool create_db (string db) {return !(execute( "CREATE DATABASE " + db ));} //:
|
|
- bool drop_db (string db) {return !(execute( "DROP DATABASE " + db ));} //:
|
|
- bool select_db (string db) {return select_db(db.c_str());} //:
|
|
+ bool create_db (std::string db) {return !(execute( "CREATE DATABASE " + db ));} //:
|
|
+ bool drop_db (std::string db) {return !(execute( "DROP DATABASE " + db ));} //:
|
|
+ bool select_db (std::string db) {return select_db(db.c_str());} //:
|
|
bool select_db (const char *db); //:
|
|
bool reload(); //:
|
|
bool shutdown (); //:
|
|
- string infoo (void) {return info ();}
|
|
+ std::string infoo (void) {return info ();}
|
|
st_mysql_options get_options (void) const {return mysql.options;}
|
|
int read_options(enum mysql_option option,const char *arg) {return mysql_options(&mysql, option,arg);}
|
|
int affected_rows() {return mysql_affected_rows((MYSQL*) &mysql);}
|
|
int insert_id () {return mysql_insert_id(&mysql);}
|
|
|
|
- template <class Sequence> void storein_sequence(Sequence &, const string &); //:
|
|
- template <class Set> void storein_set(Set &, const string &); //:
|
|
+ template <class Sequence> void storein_sequence(Sequence &, const std::string &); //:
|
|
+ template <class Set> void storein_set(Set &, const std::string &); //:
|
|
|
|
//!dummy: void storein(TYPE &con, const string &s);
|
|
//: Stores the results in TYPE.
|
|
// Stores the result in TYPE. TYPE must be some sort of STL container.
|
|
|
|
- template <class T> void storein(vector<T> &con, const string &s)
|
|
+ template <class T> void storein(std::vector<T> &con, const std::string &s)
|
|
{storein_sequence(con,s);}
|
|
- template <class T> void storein(deque<T> &con, const string &s)
|
|
+ template <class T> void storein(std::deque<T> &con, const std::string &s)
|
|
{storein_sequence(con,s);}
|
|
- template <class T> void storein(list<T> &con, const string &s)
|
|
+ template <class T> void storein(std::list<T> &con, const std::string &s)
|
|
{storein_sequence(con,s);}
|
|
- template <class T> void storein(slist<T> &con, const string &s)
|
|
- {storein_sequence(con,s);}
|
|
- template <class T> void storein(set<T> &con, const string &s)
|
|
+ template <class T> void storein(std::set<T> &con, const std::string &s)
|
|
{storein_set(con,s);}
|
|
- template <class T> void storein(multiset<T> &con, const string &s)
|
|
+ template <class T> void storein(std::multiset<T> &con, const std::string &s)
|
|
{storein_set(con,s);}
|
|
};
|
|
|