@@ -81,54 +81,37 @@ namespace sqlite_orm {
81
81
polyfill::void_t <indirectly_test_preparable<decltype (std::declval<S>().prepare(std::declval<E>()))>>> =
82
82
true ;
83
83
84
+ template <class Opt , class OptionsTpl >
85
+ decltype (auto ) storage_opt_or_default(OptionsTpl& options) {
84
86
#ifdef SQLITE_ORM_CTAD_SUPPORTED
85
- template <class PropsTpl >
86
- on_open on_open_spec_or_default (PropsTpl& properties) {
87
- if constexpr (tuple_has_type<PropsTpl, on_open>::value) {
88
- return std::move (std::get<on_open>(properties));
87
+ if constexpr (tuple_has_type<OptionsTpl, Opt>::value) {
88
+ return std::move (std::get<Opt>(options));
89
89
} else {
90
- return {};
90
+ return Opt {};
91
91
}
92
- }
93
-
94
- template <class PropsTpl >
95
- connection_control connection_control_or_default (PropsTpl& properties) {
96
- if constexpr (tuple_has_type<PropsTpl, connection_control>::value) {
97
- return std::move (std::get<connection_control>(properties));
98
- } else {
99
- return {};
100
- }
101
- }
102
92
#else
103
- template <class PropsTpl >
104
- on_open on_open_spec_or_default (PropsTpl&) {
105
- return {};
106
- }
107
-
108
- template <class PropsTpl >
109
- connection_control connection_control_or_default (PropsTpl&) {
110
- return {};
111
- }
93
+ return Opt{};
112
94
#endif
95
+ }
113
96
114
97
/* *
115
98
* Storage class itself. Create an instanse to use it as an interfacto to sqlite db by calling `make_storage`
116
99
* function.
117
100
*/
118
101
template <class ... DBO>
119
102
struct storage_t : storage_base {
120
- using self = storage_t ;
103
+ using self_type = storage_t ;
121
104
using db_objects_type = db_objects_tuple<DBO...>;
122
105
123
106
/* *
124
107
* @param filename database filename.
125
108
* @param dbObjects db_objects_tuple
126
109
*/
127
- template <class PropsTpl >
128
- storage_t (std::string filename, db_objects_type dbObjects, PropsTpl properties ) :
110
+ template <class OptionsTpl >
111
+ storage_t (std::string filename, db_objects_type dbObjects, OptionsTpl options ) :
129
112
storage_base{std::move (filename),
130
- on_open_spec_or_default (properties ),
131
- connection_control_or_default (properties ),
113
+ storage_opt_or_default<connection_control>(options ),
114
+ storage_opt_or_default<on_open_spec>(options ),
132
115
foreign_keys_count (dbObjects)},
133
116
db_objects{std::move (dbObjects)} {}
134
117
@@ -149,7 +132,7 @@ namespace sqlite_orm {
149
132
*
150
133
* Hence, friend was replaced by `obtain_db_objects()` and `pick_const_impl()`.
151
134
*/
152
- friend const db_objects_type& obtain_db_objects (const self & storage) noexcept {
135
+ friend const db_objects_type& obtain_db_objects (const self_type & storage) noexcept {
153
136
return storage.db_objects ;
154
137
}
155
138
@@ -281,7 +264,7 @@ namespace sqlite_orm {
281
264
282
265
public:
283
266
template <class T , class O = mapped_type_proxy_t <T>, class ... Args>
284
- mapped_view<O, self , Args...> iterate(Args&&... args) {
267
+ mapped_view<O, self_type , Args...> iterate(Args&&... args) {
285
268
this ->assert_mapped_type <O>();
286
269
287
270
auto con = this ->get_connection ();
@@ -816,7 +799,7 @@ namespace sqlite_orm {
816
799
std::enable_if_t <!is_prepared_statement<Ex>::value && !is_mapped<db_objects_type, Ex>::value,
817
800
bool > = true >
818
801
std::string dump (E&& expression, bool parametrized = false ) const {
819
- static_assert (is_preparable_v<self , Ex>, " Expression must be a high-level statement" );
802
+ static_assert (is_preparable_v<self_type , Ex>, " Expression must be a high-level statement" );
820
803
821
804
decltype (auto ) e2 = static_if<is_select<Ex>::value>(
822
805
[](auto expression) -> auto {
@@ -1739,18 +1722,15 @@ namespace sqlite_orm {
1739
1722
}; // struct storage_t
1740
1723
1741
1724
#ifdef SQLITE_ORM_CTAD_SUPPORTED
1742
- template <typename T>
1743
- using storage_prop_tag_t = typename T::storage_prop_tag;
1744
-
1745
1725
template <class Elements >
1746
- using prop_index_sequence = filter_tuple_sequence_t <Elements, check_if_names< storage_prop_tag_t >::template fn>;
1726
+ using dbo_index_sequence = filter_tuple_sequence_t <Elements, check_if_lacks< storage_opt_tag_t >::template fn>;
1747
1727
1748
1728
template <class Elements >
1749
- using dbo_index_sequence = filter_tuple_sequence_t <Elements, check_if_lacks< storage_prop_tag_t >::template fn>;
1729
+ using opt_index_sequence = filter_tuple_sequence_t <Elements, check_if_names< storage_opt_tag_t >::template fn>;
1750
1730
1751
- template <class ... DBO, class PropsTpl >
1752
- storage_t <DBO...> make_storage (std::string filename, std::tuple<DBO...> dbObjects, PropsTpl properties ) {
1753
- return {std::move (filename), std::move (dbObjects), std::move (properties )};
1731
+ template <class ... DBO, class OptionsTpl >
1732
+ storage_t <DBO...> make_storage (std::string filename, std::tuple<DBO...> dbObjects, OptionsTpl options ) {
1733
+ return {std::move (filename), std::move (dbObjects), std::move (options )};
1754
1734
}
1755
1735
#endif
1756
1736
}
@@ -1762,13 +1742,14 @@ SQLITE_ORM_EXPORT namespace sqlite_orm {
1762
1742
* Factory function for a storage, from a database file and a bunch of database object definitions.
1763
1743
*/
1764
1744
template <class ... Spec>
1765
- auto make_storage (std::string filename, Spec... arguments ) {
1745
+ auto make_storage (std::string filename, Spec... specifications ) {
1766
1746
using namespace ::sqlite_orm::internal;
1767
1747
1768
- std::tuple args{std::forward<Spec>(arguments)...};
1769
- return make_storage (std::move (filename),
1770
- create_from_tuple<std::tuple>(std::move (args), dbo_index_sequence<decltype (args)>{}),
1771
- create_from_tuple<std::tuple>(std::move (args), prop_index_sequence<decltype (args)>{}));
1748
+ std::tuple specTuple{std::forward<Spec>(specifications)...};
1749
+ return internal::make_storage (
1750
+ std::move (filename),
1751
+ create_from_tuple<std::tuple>(std::move (specTuple), dbo_index_sequence<decltype (specTuple)>{}),
1752
+ create_from_tuple<std::tuple>(std::move (specTuple), opt_index_sequence<decltype (specTuple)>{}));
1772
1753
}
1773
1754
#else
1774
1755
template <class ... DBO>
0 commit comments