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

# manip.h File Reference

Declares the Query stream manipulators and operators. More...

`#include "common.h"`
`#include "myset.h"`
`#include "stadapter.h"`
`#include <iostream>`

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 }

## Detailed Description

Declares the Query stream manipulators and operators.

These manipulators let you automatically quote elements or escape characters that are special in SQL when inserting them into a Query stream. They make it easier to build syntactically-correct SQL queries.

This file also includes special `operator<<` definitions for a few key MySQL++ data types, since we know when to do automatic quoting and escaping for these types. This only works with Query streams, not regular std::ostreams, since we're only concerned with making correct SQL, not with presentation matters.

test/test_manip.cpp exercises the mechanisms defined here.

## 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.

enum escape_type0

| The 'escape' manipulator. SQL-escapes following argument if it is of a data type that may require escaping when inserted into a Query or SQLQueryParms stream. This is useful with string types, for example, to avoid bad SQL when they contain special characters like single quotes, nulls, and newlines. Data types like integers which never benefit from escaping don't get run through the escaping routine even if you ask for it.

enum ignore_type0

| The 'ignore' manipulator. Only valid when used with SQLQueryParms. It's a dummy manipulator like the do_nothing manipulator, except that it will not override formatting set by the template query. It is simply ignored.

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. You might care to use it when you have MySQL's `ANSI_QUOTES` mode enabled. In that mode, single quotes are used only for string literals, and double quotes for identifiers. Otherwise, `quote_only` and `quote` are quite sufficient.

enum quote_only_type0

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

enum quote_type0

| The standard 'quote' manipulator. It is the most widely useful manipulator in MySQL++. Insert this manipulator into a Query or SQLQueryParms stream to put single quotes around the next item in the stream, and escape any characters within it that are special in SQL, if the data type of the next item in the stream may require it. By contrast, Date objects only require escaping, not quoting, and integers never require either. The manipulators won't do work they know is not necessary to ensure syntactially-correct SQL.