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:
This graph shows which files directly or indirectly include this file:
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. |
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.
|
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. |
|
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. |
|
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. |
|
The 'double_quote_only' manipulator. Similar to quote_only manipulator, except that it uses double quotes instead of single quotes. |
|
The 'quote_only' manipulator. Similar to quote manipulator, except that it doesn't escape special SQL characters. |
|
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. |
|
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&). |
|
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 |