Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

manip.h File Reference

Declares std::ostream manipulators useful with SQL syntax. More...

#include "defs.h"
#include "datetime.h"
#include "myset.h"
#include "sql_string.h"
#include <mysql.h>
#include <iostream>

Include dependency graph for manip.h:

Include dependency graph

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Namespaces

namespace  mysqlpp

Enumerations

enum  quote_type0 { quote }
enum  quote_only_type0 { quote_only }
enum  quote_double_only_type0 { quote_double_only }
enum  escape_type0 { escape }
enum  do_nothing_type0 { do_nothing }
enum  ignore_type0 { ignore }

Functions

template<class T>
std::ostream & operator<< (escape_type1 o, const T &in)
 Inserts any type T into a stream that has an operator<< defined for it.
template<>
MYSQLPP_EXPORT std::ostream & operator<< (escape_type1 o, char *const &in)
 Inserts a C string into a stream, escaping special SQL characters.


Detailed Description

Declares std::ostream manipulators useful with SQL syntax.

These manipulators let you automatically quote elements or escape characters that are special in SQL when inserting them into an std::ostream. Since mysqlpp::Query is an ostream, these manipulators make it easier to build syntactically-correct SQL queries.

This file also includes operator<< definitions for ColData_Tmpl, one of the MySQL++ string-like classes. When inserting such items into a stream, they are automatically quoted and escaped as necessary unless the global variable dont_quote_auto is set to true. These operators are smart enough to turn this behavior off when the stream is cout or cerr, however, since quoting and escaping are surely not required in that instance.


Enumeration Type Documentation

enum do_nothing_type0
 

The 'do_nothing' manipulator.

Does exactly what it says: nothing. Used as a dummy manipulator when you are required to use some manipulator but don't want anything to be done to the following item. When used with SQLQueryParms it will make sure that it does not get formatted in any way, overriding any setting set by the template query.

Enumeration values:
do_nothing  insert into a std::ostream to override manipulation of next item

enum escape_type0
 

The 'escape' manipulator.

Calls mysql_escape_string() in the MySQL C API on the following argument to prevent any special SQL characters from being interpreted.

enum ignore_type0
 

The 'ignore' manipulator.

Only valid when used with SQLQueryParms. It's a dummy manipulator like the <a href="#do_nothing_manip>do_nothing manipulator, except that it will not override formatting set by the template query. It is simply ignored.

Enumeration values:
ignore  insert into a std::ostream as a dummy manipulator

enum quote_double_only_type0
 

The 'double_quote_only' manipulator.

Similar to quote_only manipulator, except that it uses double quotes instead of single quotes.

Enumeration values:
quote_double_only  insert into a std::ostream to double-quote next item

enum quote_only_type0
 

The 'quote_only' manipulator.

Similar to quote manipulator, except that it doesn't escape special SQL characters.

Enumeration values:
quote_only  insert into a std::ostream to single-quote next item

enum quote_type0
 

The standard 'quote' manipulator.

Insert this into a stream to put single quotes around the next item in the stream, and escape characters within it that are 'special' in SQL. This is the most generally useful of the manipulators.

Enumeration values:
quote  insert into a std::ostream to single-quote and escape next item


Function Documentation

template<>
MYSQLPP_EXPORT std::ostream& operator<< escape_type1  o,
char *const &  in
[inline]
 

Inserts a C string into a stream, escaping special SQL characters.

This version exists solely to handle constness problems. We force everything to the completely-const version: operator<<(escape_type1, const char* const&).

template<class T>
std::ostream& operator<< escape_type1  o,
const T &  in
[inline]
 

Inserts any type T into a stream that has an operator<< defined for it.

Does not actually escape that data! Use one of the other forms of operator<< for the escape manipulator if you need escaping. This template exists to catch cases like inserting an int after the escape manipulator: you don't actually want escaping in this instance.


Generated on Tue Aug 16 12:53:48 2005 for MySQL++ by  doxygen 1.3.9.1