mysqlpp::SQLStream Class Reference

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

#include <sqlstream.h>

Collaboration diagram for mysqlpp::SQLStream:

Collaboration graph
[legend]
List of all members.

Public Member Functions

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

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

Create a new stream object attached to a connection.

Parameters:
c connection used for escaping text
pstr an optional initial string

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

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:
escaped character buffer to hold escaped version; must point to at least (length * 2 + 1) bytes
original pointer to the character buffer to escape
length number of characters to escape
Return values:
number of 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.

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:
ps pointer to C++ string to hold escaped version; if original is 0, also holds the original data to be escaped
original if given, pointer to the character buffer to escape instead of contents of *ps
length if both this and original are given, number of characters to escape instead of ps->length()
Return values:
number of 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.


The documentation for this class was generated from the following files:
Generated on Thu Jun 3 11:59:12 2010 for MySQL++ by  doxygen 1.4.7