- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

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:
[legend]
Collaboration diagram for mysqlpp::SQLStream:
[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...
SQLStream & | operator= (const SQLStream &rhs)
| Assigns contents of another SQLStream to this one.

## Public Attributes
Connection * | conn_
| 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 | ( | 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.

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

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.

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:

- sqlstream.h
- sqlstream.cpp