1//
2// AbstractBinder.cpp
3//
4// Library: Data
5// Package: DataCore
6// Module: AbstractBinder
7//
8// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
9// and Contributors.
10//
11// SPDX-License-Identifier: BSL-1.0
12//
13
14
15#include "Poco/Data/AbstractBinder.h"
16#include "Poco/Data/Date.h"
17#include "Poco/Data/Time.h"
18#include "Poco/Data/LOB.h"
19#include "Poco/Data/DataException.h"
20#include "Poco/DateTime.h"
21#include "Poco/Any.h"
22#include "Poco/Dynamic/Var.h"
23
24
25namespace Poco {
26namespace Data {
27
28
29AbstractBinder::AbstractBinder()
30{
31}
32
33
34AbstractBinder::~AbstractBinder()
35{
36}
37
38
39void AbstractBinder::bind(std::size_t pos, const std::vector<Poco::Int8>& val, Direction dir)
40{
41 throw NotImplementedException("std::vector binder must be implemented.");
42}
43
44
45void AbstractBinder::bind(std::size_t pos, const std::deque<Poco::Int8>& val, Direction dir)
46{
47 throw NotImplementedException("std::deque binder must be implemented.");
48}
49
50
51void AbstractBinder::bind(std::size_t pos, const std::list<Poco::Int8>& val, Direction dir)
52{
53 throw NotImplementedException("std::list binder must be implemented.");
54}
55
56
57void AbstractBinder::bind(std::size_t pos, const std::vector<Poco::UInt8>& val, Direction dir)
58{
59 throw NotImplementedException("std::vector binder must be implemented.");
60}
61
62
63void AbstractBinder::bind(std::size_t pos, const std::deque<Poco::UInt8>& val, Direction dir)
64{
65 throw NotImplementedException("std::deque binder must be implemented.");
66}
67
68
69void AbstractBinder::bind(std::size_t pos, const std::list<Poco::UInt8>& val, Direction dir)
70{
71 throw NotImplementedException("std::list binder must be implemented.");
72}
73
74
75void AbstractBinder::bind(std::size_t pos, const std::vector<Poco::Int16>& val, Direction dir)
76{
77 throw NotImplementedException("std::vector binder must be implemented.");
78}
79
80
81void AbstractBinder::bind(std::size_t pos, const std::deque<Poco::Int16>& val, Direction dir)
82{
83 throw NotImplementedException("std::deque binder must be implemented.");
84}
85
86
87void AbstractBinder::bind(std::size_t pos, const std::list<Poco::Int16>& val, Direction dir)
88{
89 throw NotImplementedException("std::list binder must be implemented.");
90}
91
92
93void AbstractBinder::bind(std::size_t pos, const std::vector<Poco::UInt16>& val, Direction dir)
94{
95 throw NotImplementedException("std::vector binder must be implemented.");
96}
97
98
99void AbstractBinder::bind(std::size_t pos, const std::deque<Poco::UInt16>& val, Direction dir)
100{
101 throw NotImplementedException("std::deque binder must be implemented.");
102}
103
104
105void AbstractBinder::bind(std::size_t pos, const std::list<Poco::UInt16>& val, Direction dir)
106{
107 throw NotImplementedException("std::list binder must be implemented.");
108}
109
110
111void AbstractBinder::bind(std::size_t pos, const std::vector<Poco::Int32>& val, Direction dir)
112{
113 throw NotImplementedException("std::vector binder must be implemented.");
114}
115
116
117void AbstractBinder::bind(std::size_t pos, const std::deque<Poco::Int32>& val, Direction dir)
118{
119 throw NotImplementedException("std::deque binder must be implemented.");
120}
121
122
123void AbstractBinder::bind(std::size_t pos, const std::list<Poco::Int32>& val, Direction dir)
124{
125 throw NotImplementedException("std::list binder must be implemented.");
126}
127
128
129void AbstractBinder::bind(std::size_t pos, const std::vector<Poco::UInt32>& val, Direction dir)
130{
131 throw NotImplementedException("std::vector binder must be implemented.");
132}
133
134
135void AbstractBinder::bind(std::size_t pos, const std::deque<Poco::UInt32>& val, Direction dir)
136{
137 throw NotImplementedException("std::deque binder must be implemented.");
138}
139
140
141void AbstractBinder::bind(std::size_t pos, const std::list<Poco::UInt32>& val, Direction dir)
142{
143 throw NotImplementedException("std::list binder must be implemented.");
144}
145
146
147void AbstractBinder::bind(std::size_t pos, const std::vector<Poco::Int64>& val, Direction dir)
148{
149 throw NotImplementedException("std::vector binder must be implemented.");
150}
151
152
153void AbstractBinder::bind(std::size_t pos, const std::deque<Poco::Int64>& val, Direction dir)
154{
155 throw NotImplementedException("std::deque binder must be implemented.");
156}
157
158
159void AbstractBinder::bind(std::size_t pos, const std::list<Poco::Int64>& val, Direction dir)
160{
161 throw NotImplementedException("std::list binder must be implemented.");
162}
163
164
165void AbstractBinder::bind(std::size_t pos, const std::vector<Poco::UInt64>& val, Direction dir)
166{
167 throw NotImplementedException("std::vector binder must be implemented.");
168}
169
170
171void AbstractBinder::bind(std::size_t pos, const std::deque<Poco::UInt64>& val, Direction dir)
172{
173 throw NotImplementedException("std::deque binder must be implemented.");
174}
175
176
177void AbstractBinder::bind(std::size_t pos, const std::list<Poco::UInt64>& val, Direction dir)
178{
179 throw NotImplementedException("std::list binder must be implemented.");
180}
181
182
183#ifndef POCO_LONG_IS_64_BIT
184void AbstractBinder::bind(std::size_t pos, const std::vector<long>& val, Direction dir)
185{
186 throw NotImplementedException("std::vector binder must be implemented.");
187}
188
189
190void AbstractBinder::bind(std::size_t pos, const std::deque<long>& val, Direction dir)
191{
192 throw NotImplementedException("std::deque binder must be implemented.");
193}
194
195
196void AbstractBinder::bind(std::size_t pos, const std::list<long>& val, Direction dir)
197{
198 throw NotImplementedException("std::list binder must be implemented.");
199}
200#endif
201
202
203void AbstractBinder::bind(std::size_t pos, const std::vector<bool>& val, Direction dir)
204{
205 throw NotImplementedException("std::vector binder must be implemented.");
206}
207
208
209void AbstractBinder::bind(std::size_t pos, const std::deque<bool>& val, Direction dir)
210{
211 throw NotImplementedException("std::deque binder must be implemented.");
212}
213
214
215void AbstractBinder::bind(std::size_t pos, const std::list<bool>& val, Direction dir)
216{
217 throw NotImplementedException("std::list binder must be implemented.");
218}
219
220
221void AbstractBinder::bind(std::size_t pos, const std::vector<float>& val, Direction dir)
222{
223 throw NotImplementedException("std::vector binder must be implemented.");
224}
225
226
227void AbstractBinder::bind(std::size_t pos, const std::deque<float>& val, Direction dir)
228{
229 throw NotImplementedException("std::deque binder must be implemented.");
230}
231
232
233void AbstractBinder::bind(std::size_t pos, const std::list<float>& val, Direction dir)
234{
235 throw NotImplementedException("std::list binder must be implemented.");
236}
237
238
239void AbstractBinder::bind(std::size_t pos, const std::vector<double>& val, Direction dir)
240{
241 throw NotImplementedException("std::vector binder must be implemented.");
242}
243
244
245void AbstractBinder::bind(std::size_t pos, const std::deque<double>& val, Direction dir)
246{
247 throw NotImplementedException("std::deque binder must be implemented.");
248}
249
250
251void AbstractBinder::bind(std::size_t pos, const std::list<double>& val, Direction dir)
252{
253 throw NotImplementedException("std::list binder must be implemented.");
254}
255
256
257void AbstractBinder::bind(std::size_t pos, const std::vector<char>& val, Direction dir)
258{
259 throw NotImplementedException("std::vector binder must be implemented.");
260}
261
262
263void AbstractBinder::bind(std::size_t pos, const std::deque<char>& val, Direction dir)
264{
265 throw NotImplementedException("std::deque binder must be implemented.");
266}
267
268
269void AbstractBinder::bind(std::size_t pos, const std::list<char>& val, Direction dir)
270{
271 throw NotImplementedException("std::list binder must be implemented.");
272}
273
274
275void AbstractBinder::bind(std::size_t pos, const std::vector<std::string>& val, Direction dir)
276{
277 throw NotImplementedException("std::vector binder must be implemented.");
278}
279
280
281void AbstractBinder::bind(std::size_t pos, const std::deque<std::string>& val, Direction dir)
282{
283 throw NotImplementedException("std::deque binder must be implemented.");
284}
285
286
287void AbstractBinder::bind(std::size_t pos, const std::list<std::string>& val, Direction dir)
288{
289 throw NotImplementedException("std::list binder must be implemented.");
290}
291
292
293void AbstractBinder::bind(std::size_t pos, const UTF16String& val, Direction dir, const WhenNullCb& nullCb)
294{
295 throw NotImplementedException("UTF16String binder must be implemented.");
296}
297
298
299void AbstractBinder::bind(std::size_t pos, const std::vector<UTF16String>& val, Direction dir)
300{
301 throw NotImplementedException("std::vector binder must be implemented.");
302}
303
304
305void AbstractBinder::bind(std::size_t pos, const std::deque<UTF16String>& val, Direction dir)
306{
307 throw NotImplementedException("std::deque binder must be implemented.");
308}
309
310
311void AbstractBinder::bind(std::size_t pos, const std::list<UTF16String>& val, Direction dir)
312{
313 throw NotImplementedException("std::list binder must be implemented.");
314}
315
316
317void AbstractBinder::bind(std::size_t pos, const std::vector<BLOB>& val, Direction dir)
318{
319 throw NotImplementedException("std::vector binder must be implemented.");
320}
321
322
323void AbstractBinder::bind(std::size_t pos, const std::deque<BLOB>& val, Direction dir)
324{
325 throw NotImplementedException("std::deque binder must be implemented.");
326}
327
328
329void AbstractBinder::bind(std::size_t pos, const std::list<BLOB>& val, Direction dir)
330{
331 throw NotImplementedException("std::list binder must be implemented.");
332}
333
334
335void AbstractBinder::bind(std::size_t pos, const std::vector<CLOB>& val, Direction dir)
336{
337 throw NotImplementedException("std::vector binder must be implemented.");
338}
339
340
341void AbstractBinder::bind(std::size_t pos, const std::deque<CLOB>& val, Direction dir)
342{
343 throw NotImplementedException("std::deque binder must be implemented.");
344}
345
346
347void AbstractBinder::bind(std::size_t pos, const std::list<CLOB>& val, Direction dir)
348{
349 throw NotImplementedException("std::list binder must be implemented.");
350}
351
352
353void AbstractBinder::bind(std::size_t pos, const std::vector<DateTime>& val, Direction dir)
354{
355 throw NotImplementedException("std::vector binder must be implemented.");
356}
357
358
359void AbstractBinder::bind(std::size_t pos, const std::deque<DateTime>& val, Direction dir)
360{
361 throw NotImplementedException("std::deque binder must be implemented.");
362}
363
364
365void AbstractBinder::bind(std::size_t pos, const std::list<DateTime>& val, Direction dir)
366{
367 throw NotImplementedException("std::list binder must be implemented.");
368}
369
370
371void AbstractBinder::bind(std::size_t pos, const std::vector<Date>& val, Direction dir)
372{
373 throw NotImplementedException("std::vector binder must be implemented.");
374}
375
376
377void AbstractBinder::bind(std::size_t pos, const std::deque<Date>& val, Direction dir)
378{
379 throw NotImplementedException("std::deque binder must be implemented.");
380}
381
382
383void AbstractBinder::bind(std::size_t pos, const std::list<Date>& val, Direction dir)
384{
385 throw NotImplementedException("std::list binder must be implemented.");
386}
387
388
389void AbstractBinder::bind(std::size_t pos, const std::vector<Time>& val, Direction dir)
390{
391 throw NotImplementedException("std::vector binder must be implemented.");
392}
393
394
395void AbstractBinder::bind(std::size_t pos, const std::deque<Time>& val, Direction dir)
396{
397 throw NotImplementedException("std::deque binder must be implemented.");
398}
399
400
401void AbstractBinder::bind(std::size_t pos, const std::list<Time>& val, Direction dir)
402{
403 throw NotImplementedException("std::list binder must be implemented.");
404}
405
406
407void AbstractBinder::bind(std::size_t pos, const std::vector<NullData>& val, Direction dir, const std::type_info& bindElemType)
408{
409 throw NotImplementedException("std::vector binder must be implemented.");
410}
411
412
413void AbstractBinder::bind(std::size_t pos, const std::deque<NullData>& val, Direction dir, const std::type_info& bindElemType)
414{
415 throw NotImplementedException("std::deque binder must be implemented.");
416}
417
418
419void AbstractBinder::bind(std::size_t pos, const std::list<NullData>& val, Direction dir, const std::type_info& bindElemType)
420{
421 throw NotImplementedException("std::list binder must be implemented.");
422}
423
424
425void AbstractBinder::bind(std::size_t pos, const Any& val, Direction dir, const WhenNullCb& nullCb)
426{
427 const std::type_info& type = val.type();
428
429 if(type == typeid(Int32))
430 bind(pos, RefAnyCast<Int32>(val), dir, nullCb);
431 else if(type == typeid(std::string))
432 bind(pos, RefAnyCast<std::string>(val), dir, nullCb);
433 else if (type == typeid(Poco::UTF16String))
434 bind(pos, RefAnyCast<Poco::UTF16String>(val), dir, nullCb);
435 else if (type == typeid(bool))
436 bind(pos, RefAnyCast<bool>(val), dir, nullCb);
437 else if(type == typeid(char))
438 bind(pos, RefAnyCast<char>(val), dir, nullCb);
439 else if(type == typeid(Int8))
440 bind(pos, RefAnyCast<Int8>(val), dir, nullCb);
441 else if(type == typeid(UInt8))
442 bind(pos, RefAnyCast<UInt8>(val), dir, nullCb);
443 else if(type == typeid(Int16))
444 bind(pos, RefAnyCast<Int16>(val), dir, nullCb);
445 else if(type == typeid(UInt16))
446 bind(pos, RefAnyCast<UInt16>(val), dir, nullCb);
447 else if(type == typeid(UInt32))
448 bind(pos, RefAnyCast<UInt32>(val), dir, nullCb);
449 else if(type == typeid(Int64))
450 bind(pos, RefAnyCast<Int64>(val), dir, nullCb);
451 else if(type == typeid(UInt64))
452 bind(pos, RefAnyCast<UInt64>(val), dir, nullCb);
453 else if(type == typeid(float))
454 bind(pos, RefAnyCast<float>(val), dir, nullCb);
455 else if(type == typeid(double))
456 bind(pos, RefAnyCast<double>(val), dir, nullCb);
457 else if(type == typeid(DateTime))
458 bind(pos, RefAnyCast<DateTime>(val), dir, nullCb);
459 else if(type == typeid(Date))
460 bind(pos, RefAnyCast<Date>(val), dir, nullCb);
461 else if(type == typeid(Time))
462 bind(pos, RefAnyCast<Time>(val), dir, nullCb);
463 else if(type == typeid(BLOB))
464 bind(pos, RefAnyCast<BLOB>(val), dir, nullCb);
465 else if(type == typeid(void))
466 bind(pos, NULL_GENERIC, dir, type);
467#ifndef POCO_LONG_IS_64_BIT
468 else if(type == typeid(long))
469 bind(pos, RefAnyCast<long>(val), dir, nullCb);
470#endif
471 else
472 throw UnknownTypeException(std::string(val.type().name()));
473}
474
475
476void AbstractBinder::bind(std::size_t pos, const Poco::Dynamic::Var& val, Direction dir, const WhenNullCb& nullCb)
477{
478 const std::type_info& type = val.type();
479
480 if(type == typeid(Int32))
481 bind(pos, val.extract<Int32>(), dir, nullCb);
482 else if(type == typeid(std::string))
483 bind(pos, val.extract<std::string>(), dir, nullCb);
484 else if (type == typeid(Poco::UTF16String))
485 bind(pos, val.extract<Poco::UTF16String>(), dir, nullCb);
486 else if (type == typeid(bool))
487 bind(pos, val.extract<bool>(), dir, nullCb);
488 else if(type == typeid(char))
489 bind(pos, val.extract<char>(), dir, nullCb);
490 else if(type == typeid(Int8))
491 bind(pos, val.extract<Int8>(), dir, nullCb);
492 else if(type == typeid(UInt8))
493 bind(pos, val.extract<UInt8>(), dir, nullCb);
494 else if(type == typeid(Int16))
495 bind(pos, val.extract<Int16>(), dir, nullCb);
496 else if(type == typeid(UInt16))
497 bind(pos, val.extract<UInt16>(), dir, nullCb);
498 else if(type == typeid(UInt32))
499 bind(pos, val.extract<UInt32>(), dir, nullCb);
500 else if(type == typeid(Int64))
501 bind(pos, val.extract<Int64>(), dir, nullCb);
502 else if(type == typeid(UInt64))
503 bind(pos, val.extract<UInt64>(), dir, nullCb);
504 else if(type == typeid(float))
505 bind(pos, val.extract<float>(), dir, nullCb);
506 else if(type == typeid(double))
507 bind(pos, val.extract<double>(), dir, nullCb);
508 else if(type == typeid(DateTime))
509 bind(pos, val.extract<DateTime>(), dir, nullCb);
510 else if(type == typeid(Date))
511 bind(pos, val.extract<Date>(), dir, nullCb);
512 else if(type == typeid(Time))
513 bind(pos, val.extract<Time>(), dir, nullCb);
514 else if(type == typeid(BLOB))
515 bind(pos, val.extract<BLOB>(), dir, nullCb);
516 else if(type == typeid(void))
517 bind(pos, NULL_GENERIC, dir, type);
518 else if (type == typeid(NullData))
519 bind(pos, val.extract<NullData>(), dir, type);
520 else if (type == typeid(NullType))
521 bind(pos, static_cast<NullData>(val.extract<NullType>()), dir, type);
522#ifndef POCO_LONG_IS_64_BIT
523 else if(type == typeid(long))
524 bind(pos, val.extract<long>(), dir, nullCb);
525#endif
526 else
527 throw UnknownTypeException(std::string(val.type().name()));
528}
529
530
531} } // namespace Poco::Data
532