MySQL++  3.3.0
tcp_connection.h
Go to the documentation of this file.
1 
4 /***********************************************************************
5  Copyright (c) 2007-2008 by Educational Technology Resources, Inc.
6  Others may also hold copyrights on code in this file. See the
7  CREDITS.txt file in the top directory of the distribution for details.
8 
9  This file is part of MySQL++.
10 
11  MySQL++ is free software; you can redistribute it and/or modify it
12  under the terms of the GNU Lesser General Public License as published
13  by the Free Software Foundation; either version 2.1 of the License, or
14  (at your option) any later version.
15 
16  MySQL++ is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
19  License for more details.
20 
21  You should have received a copy of the GNU Lesser General Public
22  License along with MySQL++; if not, write to the Free Software
23  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
24  USA
25 ***********************************************************************/
26 
27 #if !defined(MYSQLPP_TCP_CONNECTION_H)
28 #define MYSQLPP_TCP_CONNECTION_H
29 
30 #include "connection.h"
31 
32 namespace mysqlpp {
33 
38 
39 class MYSQLPP_EXPORT TCPConnection : public Connection
40 {
41 public:
44  Connection()
45  {
46  }
47 
62  TCPConnection(const char* addr, const char* db = 0, const char* user = 0,
63  const char* password = 0) :
64  Connection()
65  {
66  connect(addr, db, user, password);
67  }
68 
73  TCPConnection(const TCPConnection& other) :
74  Connection(other)
75  {
76  }
77 
80 
89  bool connect(const char* addr = 0, const char* db = 0,
90  const char* user = 0, const char* password = 0);
91 
119  static bool parse_address(std::string& addr, unsigned int& port,
120  std::string& error);
121 
122 private:
126  TCPConnection(bool) { }
127  TCPConnection(const char*, const char*, const char*, const char*,
128  unsigned int) { }
129 
132  bool connect(const char*, const char*, const char*, const char*,
133  unsigned int) { return false; }
134 };
135 
136 
137 } // end namespace mysqlpp
138 
139 #endif // !defined(MYSQLPP_TCP_CONNECTION_H)
140 
Manages the connection to the database server.
Definition: connection.h:60
Specialization of Connection for TCP/IP.
Definition: tcp_connection.h:40
TCPConnection(const char *addr, const char *db=0, const char *user=0, const char *password=0)
Create object and connect to database server over TCP/IP in one step.
Definition: tcp_connection.h:62
TCPConnection()
Create object without connecting it to the MySQL server.
Definition: tcp_connection.h:43
~TCPConnection()
Destroy object.
Definition: tcp_connection.h:79
TCPConnection(const TCPConnection &other)
Establish a new connection using the same parameters as an existing connection.
Definition: tcp_connection.h:73
Declares the Connection class.