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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
// file : pgsql/custom/query.hxx
// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#ifndef QUERY_HXX
#define QUERY_HXX
#include <string>
#include <odb/pgsql/query.hxx>
#include "test.hxx" // point
namespace odb
{
namespace pgsql
{
template <>
struct query_column<point, id_string>
{
private:
const char* table_;
const char* column_;
const char* conversion_;
std::string x_column_;
std::string y_column_;
// Sub-columns for individual members.
//
public:
query_column<double, id_double> x, y;
// is_null, is_not_null
//
public:
query
is_null () const
{
query q (table_, column_);
q += "IS NULL";
return q;
}
query
is_not_null () const
{
query q (table_, column_);
q += "IS NOT NULL";
return q;
}
// =
//
public:
query
equal (const point& v) const
{
return equal (val_bind<point> (v));
}
query
equal (val_bind<point> v) const
{
query q (table_, column_);
q += "~=";
q.append<point, id_string> (v, conversion_);
return q;
}
query
equal (ref_bind<point> r) const
{
query q (table_, column_);
q += "~=";
q.append<point, id_string> (r, conversion_);
return q;
}
friend query
operator== (const query_column& c, const point& v)
{
return c.equal (v);
}
friend query
operator== (const point& v, const query_column& c)
{
return c.equal (v);
}
friend query
operator== (const query_column& c, val_bind<point> v)
{
return c.equal (v);
}
friend query
operator== (val_bind<point> v, const query_column& c)
{
return c.equal (v);
}
friend query
operator== (const query_column& c, ref_bind<point> r)
{
return c.equal (r);
}
friend query
operator== (ref_bind<point> r, const query_column& c)
{
return c.equal (r);
}
// Column comparison.
//
public:
query
operator== (const query_column<point, id_string>& c) const
{
query q (table_, column_);
q += "~=";
q.append (c.table (), c.column ());
return q;
}
public:
query_column (const char* table, const char* column, const char* conv)
: table_ (table), column_ (column), conversion_ (conv),
x_column_ (std::string (column) + "[0]"),
y_column_ (std::string (column) + "[1]"),
x (table, x_column_.c_str (), 0),
y (table, y_column_.c_str (), 0)
{
}
const char*
table () const
{
return table_;
}
const char*
column () const
{
return column_;
}
const char*
conversion () const
{
return conversion_;
}
};
}
}
#endif // QUERY_HXX
|