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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
|
// file : mssql/custom/query.hxx
// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#ifndef QUERY_HXX
#define QUERY_HXX
#include <string>
#include <odb/mssql/query.hxx>
#include "test.hxx" // point
namespace odb
{
namespace mssql
{
#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000
template <>
struct query_column<point, id_string>
{
private:
const char* table_;
const char* column_;
const char* conversion_;
unsigned short prec_;
unsigned short scale_;
std::string x_column_;
std::string y_column_;
// Sub-columns for individual members.
//
public:
query_column<double, id_float8> x, y;
// is_null, is_not_null
//
public:
query_base
is_null () const
{
query_base q (table_, column_);
q += "IS NULL";
return q;
}
query_base
is_not_null () const
{
query_base q (table_, column_);
q += "IS NOT NULL";
return q;
}
// =
//
public:
query_base
equal (const point& v) const
{
return equal (val_bind<point> (v));
}
query_base
equal (val_bind<point> v) const
{
query_base q (table_, column_);
q += ".STEquals(";
q.append<point, id_string> (v, conversion_);
q += ") = 1";
return q;
}
query_base
equal (ref_bind<point> r) const
{
query_base q (table_, column_);
q += ".STEquals(";
q.append<point, id_string> (r, conversion_);
q += ") = 1";
return q;
}
friend query_base
operator== (const query_column& c, const point& v)
{
return c.equal (v);
}
friend query_base
operator== (const point& v, const query_column& c)
{
return c.equal (v);
}
friend query_base
operator== (const query_column& c, val_bind<point> v)
{
return c.equal (v);
}
friend query_base
operator== (val_bind<point> v, const query_column& c)
{
return c.equal (v);
}
friend query_base
operator== (const query_column& c, ref_bind<point> r)
{
return c.equal (r);
}
friend query_base
operator== (ref_bind<point> r, const query_column& c)
{
return c.equal (r);
}
// Column comparison.
//
public:
query_base
operator== (const query_column<point, id_string>& c) const
{
query_base q (table_, column_);
q += ".STEquals(";
q.append (c.table (), c.column ());
q += ") = 1";
return q;
}
public:
query_column (const char* table,
const char* column,
const char* conv,
unsigned short prec = 0,
unsigned short scale = 0xFFFF)
: table_ (table), column_ (column), conversion_ (conv),
prec_ (prec), scale_ (scale),
x_column_ (std::string (column) + ".STX"),
y_column_ (std::string (column) + ".STY"),
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_;
}
unsigned short
prec () const
{
return prec_;
}
unsigned short
scale () const
{
return scale_;
}
};
#endif // SQL Server > 2005
}
}
#endif // QUERY_HXX
|