blob: cd64e7e3ce0c37373a150d61984d12d5870cb9b8 (
plain)
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
|
#ifndef DB_SELECTCOMMANDUTIL_IMPL_H
#define DB_SELECTCOMMANDUTIL_IMPL_H
#include "selectcommand.h"
#include <type_traits>
/// @cond
namespace DB {
template<typename... Fn, std::size_t... I>
inline void
forEachField(DB::SelectCommand * sel [[maybe_unused]], auto && func, std::index_sequence<I...>)
{
std::tuple<Fn...> values;
(((*sel)[I] >> std::get<I>(values)), ...);
std::apply(func, values);
}
template<typename... Fn, typename Func>
inline void
SelectCommand::forEachRow(const Func & func)
{
while (fetch()) {
forEachField<Fn...>(this, func, std::make_index_sequence<sizeof...(Fn)> {});
}
}
template<typename... Fn>
inline RowRange<Fn...>
SelectCommand::as()
{
return RowRange<Fn...>(this);
}
template<typename... Fn> inline RowRange<Fn...>::RowRange(SelectCommand * s) : sel(s) { }
template<typename... Fn>
inline RowRangeIterator<Fn...>
RowRange<Fn...>::begin() const
{
return RowRangeIterator<Fn...>(sel);
}
template<typename... Fn>
inline RowRangeIterator<Fn...>
RowRange<Fn...>::end() const
{
return RowRangeIterator<Fn...>(nullptr);
}
template<typename... Fn> inline RowRangeIterator<Fn...>::RowRangeIterator(SelectCommand * s) : sel(s)
{
if (sel) {
validRow = sel->fetch();
}
else {
validRow = false;
}
}
template<typename... Fn>
inline bool
RowRangeIterator<Fn...>::operator!=(const RowRangeIterator &) const
{
return validRow;
}
template<typename... Fn>
inline void
RowRangeIterator<Fn...>::operator++()
{
validRow = sel->fetch();
}
template<typename... Fn>
inline Row<Fn...>
RowRangeIterator<Fn...>::operator*() const
{
return Row<Fn...>(sel);
}
template<typename... Fn> inline Row<Fn...>::Row(SelectCommand * s) : RowBase(s) { }
template<typename... Fn>
template<unsigned int C>
inline typename Row<Fn...>::template FieldType<C>
Row<Fn...>::value() const
{
return get<C>();
}
template<typename... Fn>
template<unsigned int C>
inline typename Row<Fn...>::template FieldType<C>
Row<Fn...>::get() const
{
FieldType<C> a;
sel->operator[](C) >> a;
return a;
}
}
/// @endcond
#endif
|