1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
/*
* manipulator.h
*
* Copyright (C) 2009 Tim Marston <tim@ed.am>
*
* This file is part of sqlite3cc (hereafter referred to as "this program").
* See http://ed.am/dev/sqlite3cc for more information.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SQLITE3CC_MANIPULATOR_H_
#define SQLITE3CC_MANIPULATOR_H_
#include <string>
namespace sqlite
{
namespace detail
{
// types to represent special manipulators for use with stream operators
struct null_t { };
struct exec_t { };
struct set_index_t { unsigned int _index; };
struct blob_t { const char *value; unsigned int value_length; };
}
/**
* Stream manipulator. When used with a statment's stream operator, this
* specifies a NULL value to bind to a parameter. When used with a row's stream
* operator, no value is fetched for a column.
*/
extern detail::null_t null;
/**
* Stream manipulator. When used with a statment's stream operator, this
* indicates that the statement should be executed immediately. Unlike a
* statment's exec() method, this will throw on error. Also, it will throw if
* the execution returns any result rows. When used with a query's stream
* operator, behaviour is the same except that it will not throw when the
* execution returns results.
*/
extern detail::exec_t exec;
/**
* Stream manipulator. When used with a statment's or a row's stream operator,
* this manipulator sets the index used to automatically bind values or get
* column values.
*
* @param index the new index
*/
detail::set_index_t set_index(
unsigned int index );
/**
* Stream manipulator. When used with a statement's or a row's stream operator,
* this indicates that the data contained within is to be bound as a blob,
* rather than text.
*
* @param value the blob data value
* @param value_length the length of the blob data
*/
detail::blob_t blob(
const char *value,
unsigned int value_length );
/**
* Stream manipulator. When used with a statement's or a row's stream operator,
* this indicates that the data contained within is to be bound as a blob,
* rather than text.
*
* @param value the blob data value
*/
detail::blob_t blob(
const std::string &value );
} // namespace sqlite
#endif /* SQLITE3CC_MANIPULATOR_H_ */
|