Menu

[7bea58]: / db / statement.hpp  Maximize  Restore  History

Download this file

60 lines (43 with data), 1.7 kB

 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
#ifndef CHILON_DB_STATEMENT_HPP
#define CHILON_DB_STATEMENT_HPP
namespace chilon { namespace db {
namespace detail {
template <int idx, class Tag, class Table>
struct tag_to_index;
template <int idx, class Tag, class... Columns>
struct tag_to_index<idx, Tag, table<Columns...>>
: tag_to_index<idx, Tag, type::list<Columns...>> {};
template <int idx, class Tag, class Head, class... Tail>
struct tag_to_index<idx, Tag, type::list<Head, Tail...>>
: tag_to_index<idx + 1, Tag, type::list<Tail...>> {};
template <int idx, class Tag, class SourceType, class... Tail>
struct tag_to_index<idx, Tag, type::list<column<Tag, SourceType>, Tail...>>
: type::head_i<idx> {};
}
// TODO: rename these to something
template <class Table, int... Columns>
struct columns_i {
typedef Table table_type;
};
template <class Table, class... Tags>
struct columns {
typedef Table table_type;
};
template <class Table, class... Tags>
struct tags {};
template <class Columns>
struct statement;
template <class Table, int... Columns>
struct statement<columns_i<Table, Columns...>> {
enum { n_parameters = sizeof...(Columns) ? sizeof...(Columns) : Table::n_columns };
typedef Table table_type;
typedef type::view<typename Table::columns_type, Columns...> column_view;
typedef type::view<typename Table::types, Columns...> type_view;
};
template <class Table, class Tag>
struct tag_to_index : detail::tag_to_index<0, Tag, Table> {};
template <class Table, class... Tags>
struct statement<columns<Table, Tags...>>
: statement<columns_i<Table, tag_to_index<Table, Tags>::value...>> {};
} }
#endif
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.