MySQL++  3.3.0
Public Member Functions | Public Attributes | List of all members
mysqlpp::SQLStream Class Reference

A class for building SQL-formatted strings. More...

#include <sqlstream.h>

Inheritance diagram for mysqlpp::SQLStream:
Inheritance graph
[legend]
Collaboration diagram for mysqlpp::SQLStream:
Collaboration graph
[legend]

Public Member Functions

 SQLStream (Connection *c, const char *pstr=0)
 Create a new stream object attached to a connection. More...
 
 SQLStream (const SQLStream &s)
 Create a new stream object as a copy of another. More...
 
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. More...
 
size_t escape_string (char *escaped, const char *original, size_t length) const
 Return a SQL-escaped version of the given character buffer. More...
 
SQLStreamoperator= (const SQLStream &rhs)
 Assigns contents of another SQLStream to this one.
 

Public Attributes

Connectionconn_
 Connection to send queries through.
 

Detailed Description

A class for building SQL-formatted strings.

See the user manual for more details about these options.

Constructor & Destructor Documentation

◆ SQLStream() [1/2]

mysqlpp::SQLStream::SQLStream ( Connection c,
const char *  pstr = 0 
)

Create a new stream object attached to a connection.

Parameters
cconnection used for escaping text
pstran optional initial string

◆ SQLStream() [2/2]

mysqlpp::SQLStream::SQLStream ( const SQLStream s)

Create a new stream object as a copy of another.

This is a traditional copy ctor.

Member Function Documentation

◆ escape_string() [1/2]

size_t mysqlpp::SQLStream::escape_string ( char *  escaped,
const char *  original,
size_t  length 
) const

Return a SQL-escaped version of the given character buffer.

Parameters
escapedcharacter buffer to hold escaped version; must point to at least (length * 2 + 1) bytes
originalpointer to the character buffer to escape
lengthnumber of characters to escape
Return values
numberof characters placed in escaped

DBDriver provides two versions of this method and Query::escape_string() calls the appropriate one based on whether or not a database connection is available. If the connection is available, it can call the DBDriver::escape_string() method. If there is no database connection available (normally only in testing), then DBDriver provides a static version of the function that doesn't use a database connection.

See also
comments for DBDriver::escape_string(char*, const char*, size_t), DBDriver::escape_string_no_conn(char*, const char*, size_t) for further details.

References conn_, mysqlpp::Connection::driver(), mysqlpp::DBDriver::escape_string(), and mysqlpp::DBDriver::escape_string_no_conn().

◆ escape_string() [2/2]

size_t mysqlpp::SQLStream::escape_string ( std::string *  ps,
const char *  original = 0,
size_t  length = 0 
) const

Return a SQL-escaped version of a character buffer.

Parameters
pspointer to C++ string to hold escaped version; if original is 0, also holds the original data to be escaped
originalif given, pointer to the character buffer to escape instead of contents of *ps
lengthif both this and original are given, number of characters to escape instead of ps->length()
Return values
numberof characters placed in *ps
See also
comments for escape_string(char*, const char*, size_t) and DBDriver::escape_string(std::string*, const char *, size_t) for further details.

References conn_, mysqlpp::Connection::driver(), mysqlpp::DBDriver::escape_string(), and mysqlpp::DBDriver::escape_string_no_conn().


The documentation for this class was generated from the following files: