connection.h

Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 /***********************************************************************
00012  Copyright (c) 1998 by Kevin Atkinson, (c) 1999-2001 by MySQL AB, and
00013  (c) 2004-2007 by Educational Technology Resources, Inc.  Others may
00014  also hold copyrights on code in this file.  See the CREDITS.txt file
00015  in the top directory of the distribution for details.
00016 
00017  This file is part of MySQL++.
00018 
00019  MySQL++ is free software; you can redistribute it and/or modify it
00020  under the terms of the GNU Lesser General Public License as published
00021  by the Free Software Foundation; either version 2.1 of the License, or
00022  (at your option) any later version.
00023 
00024  MySQL++ is distributed in the hope that it will be useful, but WITHOUT
00025  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00026  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
00027  License for more details.
00028 
00029  You should have received a copy of the GNU Lesser General Public
00030  License along with MySQL++; if not, write to the Free Software
00031  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
00032  USA
00033 ***********************************************************************/
00034 
00035 #if !defined(MYSQLPP_CONNECTION_H)
00036 #define MYSQLPP_CONNECTION_H
00037 
00038 #include "common.h"
00039 
00040 #include "noexceptions.h"
00041 #include "options.h"
00042 
00043 #include <string>
00044 
00045 namespace mysqlpp {
00046 
00047 #if !defined(DOXYGEN_IGNORE)
00048 // Make Doxygen ignore this
00049 class MYSQLPP_EXPORT Query;
00050 class DBDriver;
00051 #endif
00052 
00058 
00059 class MYSQLPP_EXPORT Connection : public OptionalExceptions
00060 {
00061 private:
00066         typedef bool Connection::*private_bool_type;
00067 
00068 public:
00072         Connection(bool te = true);
00073 
00107         Connection(const char* db, const char* server = 0, const char* user = 0,
00108                         const char* password = 0, unsigned int port = 0);
00109 
00114         Connection(const Connection& other);
00115 
00117         virtual ~Connection();
00118 
00121         std::string client_version() const;
00122 
00131         virtual bool connect(const char* db = 0, const char* server = 0,
00132                         const char* user = 0, const char* password = 0,
00133                         unsigned int port = 0);
00134 
00138         bool connected() const;
00139 
00146         ulonglong count_rows(const std::string& table);
00147 
00153         bool create_db(const std::string& db);
00154 
00156         void disconnect();
00157 
00167         DBDriver* driver() { return driver_; }
00168 
00174         bool drop_db(const std::string& db);
00175 
00178         int errnum();
00179 
00185         const char* error() const;
00186 
00192         std::string ipc_info() const;
00193 
00199         bool kill(unsigned long tid) const;
00200 
00220         operator private_bool_type() const
00221         {
00222                 return copacetic_ ? &Connection::copacetic_ : 0;
00223         }
00224 
00227         Connection& operator=(const Connection& rhs);
00228 
00235         bool ping();
00236 
00239         int protocol_version() const;
00240 
00251         Query query(const char* qstr = 0);
00252 
00256         Query query(const std::string& qstr);
00257 
00264         bool select_db(const std::string& db);
00265 
00267         std::string server_version() const;
00268 
00292         bool set_option(Option* o);
00293 
00295         bool shutdown();
00296 
00298         std::string server_status() const;
00299 
00302         static bool thread_aware();
00303 
00306         static void thread_end();
00307 
00312         unsigned long thread_id();
00313 
00333         static bool thread_start();
00334 
00335 protected:
00339         void build_error_message(const char* core);
00340 
00344         void copy(const Connection& other);
00345 
00348         bool parse_ipc_method(const char* server, std::string& host,
00349                         unsigned int& port, std::string& socket_name);
00350 
00352         mutable std::string error_message_;     
00353 
00354 private:
00355         DBDriver* driver_;
00356         bool copacetic_;
00357 };
00358 
00359 
00360 } // end namespace mysqlpp
00361 
00362 // Not strictly required, but bring in our specialization subclasses
00363 #include "tcp_connection.h"
00364 #include "uds_connection.h"
00365 #include "wnp_connection.h"
00366 
00367 #endif // !defined(MYSQLPP_CONNECTION_H)
00368 

Generated on 10 Dec 2013 for MySQL++ by  doxygen 1.4.7