MySQL++  3.2.5
sqlstream.h
Go to the documentation of this file.
1 
4 /***********************************************************************
5  Copyright (c) 2008 by AboveNet, Inc. Others may also hold copyrights
6  on code in this file. See the CREDITS file in the top directory of
7  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_SQLSTREAM_H)
28 #define MYSQLPP_SQLSTREAM_H
29 
30 #include "common.h"
31 
32 #include <sstream>
33 
34 namespace mysqlpp {
35 
36 #if !defined(DOXYGEN_IGNORE)
37 // Make Doxygen ignore this
38 class MYSQLPP_EXPORT Connection;
39 #endif
40 
44 
45 class MYSQLPP_EXPORT SQLStream :
46 public std::ostringstream
47 {
48 public:
53  SQLStream(Connection* c, const char* pstr = 0);
54 
58  SQLStream(const SQLStream& s);
59 
74  size_t escape_string(std::string* ps, const char* original = 0,
75  size_t length = 0) const;
76 
98  size_t escape_string(char* escaped, const char* original,
99  size_t length) const;
100 
102  SQLStream& operator=(const SQLStream& rhs);
103 
105  Connection* conn_;
106 };
107 
108 
112 inline std::ostream& operator <<(std::ostream& os, SQLStream& s)
113 {
114  return os << s.str();
115 }
116 
117 
118 } // end namespace mysqlpp
119 
120 #endif // !defined(MYSQLPP_SQLSTREAM_H)
121 
mysqlpp::DBDriver::escape_string_no_conn
static size_t escape_string_no_conn(char *to, const char *from, size_t length)
SQL-escapes the given string without reference to the character set of a database server.
Definition: dbdriver.h:310
dbdriver.h
Declares the DBDriver class.
mysqlpp::Connection::driver
DBDriver * driver()
Returns a reference to the current database driver.
Definition: connection.h:211
mysqlpp::SQLStream::SQLStream
SQLStream(Connection *c, const char *pstr=0)
Create a new stream object attached to a connection.
Definition: sqlstream.cpp:58
connection.h
Declares the Connection class.
common.h
This file includes top-level definitions for use both internal to the library, and outside it....
mysqlpp::SQLStream::operator=
SQLStream & operator=(const SQLStream &rhs)
Assigns contents of another SQLStream to this one.
Definition: sqlstream.cpp:108
mysqlpp::DBDriver::escape_string
size_t escape_string(char *to, const char *from, size_t length)
Return a SQL-escaped version of the given character buffer.
Definition: dbdriver.h:255
mysqlpp::SQLStream::escape_string
size_t escape_string(std::string *ps, const char *original=0, size_t length=0) const
Return a SQL-escaped version of a character buffer.
Definition: sqlstream.cpp:76
sqlstream.h
Defines a class for building quoted and escaped SQL text.
mysqlpp::SQLStream::conn_
Connection * conn_
Connection to send queries through.
Definition: sqlstream.h:147