Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dev/functional/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#define SQLITE_ORM_EXPORT
#endif

#if SQLITE_ORM_HAS_INCLUDE(<version>)
#if __has_include(<version>)
#include <version>
#endif

Expand Down
12 changes: 7 additions & 5 deletions dev/functional/cxx_check_prerequisites.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@

// note: Before the C++17 language standard was made the baseline, the library had workarounds for these specific missing C++14 language features,
// so they are kept here as explicit checks for reference.
#if __cpp_aggregate_nsdmi < 201304L || __cpp_constexpr < 201304L
#if (__cpp_aggregate_nsdmi < 201304L || __cpp_constexpr < 201304L)
#error A fully C++17-compliant compiler is required.
#endif

#if (__cpp_noexcept_function_type < 201510L) || \
(__cpp_fold_expressions < 201603L || __cpp_constexpr < 201603L || __cpp_aggregate_bases < 201603L || \
__cpp_range_based_for < 201603L) || \
(__cpp_if_constexpr < 201606L || __cpp_inline_variables < 201606L || __cpp_structured_bindings < 201606L)
#if (!defined(__has_include)) || \
((__cpp_noexcept_function_type < 201510L) || \
(__cpp_fold_expressions < 201603L || __cpp_constexpr < 201603L || __cpp_aggregate_bases < 201603L || \
__cpp_range_based_for < 201603L) || \
(__cpp_if_constexpr < 201606L || __cpp_inline_variables < 201606L || __cpp_structured_bindings < 201606L) || \
(__cpp_deduction_guides < 201703L))
#error A fully C++17-compliant compiler is required.
#endif
10 changes: 0 additions & 10 deletions dev/functional/cxx_core_features.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,6 @@
#define SQLITE_ORM_HAS_CPP_ATTRIBUTE(attr) 0L
#endif

#ifdef __has_include
#define SQLITE_ORM_HAS_INCLUDE(file) __has_include(file)
#else
#define SQLITE_ORM_HAS_INCLUDE(file) 0L
#endif

#if __cpp_deduction_guides >= 201703L
#define SQLITE_ORM_CTAD_SUPPORTED
#endif

#if __cpp_generic_lambdas >= 201707L
#define SQLITE_ORM_EXPLICIT_GENERIC_LAMBDA_SUPPORTED
#endif
Expand Down
4 changes: 1 addition & 3 deletions dev/functional/cxx_optional.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@

#ifdef SQLITE_ORM_IMPORT_STD_MODULE
#include <version>
#else
#if SQLITE_ORM_HAS_INCLUDE(<optional>)
#elif __has_include(<optional>)
#include <optional>
#endif
#endif

#if __cpp_lib_optional >= 201606L
#define SQLITE_ORM_OPTIONAL_SUPPORTED
Expand Down
4 changes: 1 addition & 3 deletions dev/functional/cxx_string_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@

#ifdef SQLITE_ORM_IMPORT_STD_MODULE
#include <version>
#else
#if SQLITE_ORM_HAS_INCLUDE(<string_view>)
#elif __has_include(<string_view>)
#include <string_view>
#endif
#endif

#if __cpp_lib_string_view >= 201606L
#define SQLITE_ORM_STRING_VIEW_SUPPORTED
Expand Down
18 changes: 1 addition & 17 deletions dev/storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,15 @@ namespace sqlite_orm {

template<class Opt, class OptionsTpl>
decltype(auto) storage_opt_or_default(OptionsTpl& options) {
#ifdef SQLITE_ORM_CTAD_SUPPORTED
if constexpr (tuple_has_type<OptionsTpl, Opt>::value) {
return std::move(std::get<Opt>(options));
} else {
return Opt{};
}
#else
return Opt{};
#endif
}

/**
* Storage class itself. Create an instanse to use it as an interfacto to sqlite db by calling `make_storage`
* Storage class itself. Create an instance to use it as an interfacto to sqlite db by calling `make_storage`
* function.
*/
template<class... DBO>
Expand Down Expand Up @@ -1759,7 +1755,6 @@ namespace sqlite_orm {
#endif // SQLITE_ORM_OPTIONAL_SUPPORTED
}; // struct storage_t

#ifdef SQLITE_ORM_CTAD_SUPPORTED
template<class Elements>
using dbo_index_sequence = filter_tuple_sequence_t<Elements, check_if_lacks<storage_opt_tag_t>::template fn>;

Expand All @@ -1770,12 +1765,10 @@ namespace sqlite_orm {
storage_t<DBO...> make_storage(std::string filename, std::tuple<DBO...> dbObjects, OptionsTpl options) {
return {std::move(filename), std::move(dbObjects), std::move(options)};
}
#endif
}
}

SQLITE_ORM_EXPORT namespace sqlite_orm {
#ifdef SQLITE_ORM_CTAD_SUPPORTED
/*
* Factory function for a storage instance, from a database file, a set of database object definitions
* and option storage options like connection control options and an 'on open' callback.
Expand All @@ -1793,15 +1786,6 @@ SQLITE_ORM_EXPORT namespace sqlite_orm {
create_from_tuple<std::tuple>(std::move(specTuple), dbo_index_sequence<decltype(specTuple)>{}),
create_from_tuple<std::tuple>(std::move(specTuple), opt_index_sequence<decltype(specTuple)>{}));
}
#else
/*
* Factory function for a storage instance, from a database file and a bunch of database object definitions.
*/
template<class... DBO>
internal::storage_t<DBO...> make_storage(std::string filename, DBO... dbObjects) {
return {std::move(filename), {std::forward<DBO>(dbObjects)...}, std::tuple<>{}};
}
#endif

/**
* sqlite3_threadsafe() interface.
Expand Down
3 changes: 1 addition & 2 deletions dev/storage_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,14 @@ SQLITE_ORM_EXPORT namespace sqlite_orm {
static_assert(std::is_aggregate_v<connection_control>);
#endif

#ifdef SQLITE_ORM_CTAD_SUPPORTED
/**
* Callback function to be passed to `make_storage()`.
* The provided function is called immdediately after the database connection has been established and set up.
*/
inline internal::on_open_spec on_open(std::function<void(sqlite3*)> onOpen) {
return {std::move(onOpen)};
}
#endif

inline internal::will_run_query_spec
will_run_query(std::function<void(internal::serialize_arg_type)> willRunQuery) {
return {std::move(willRunQuery)};
Expand Down
2 changes: 0 additions & 2 deletions dev/tuple_helper/tuple_transformer.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ namespace sqlite_orm {
}
#endif

#ifdef SQLITE_ORM_CTAD_SUPPORTED
template<template<typename...> class R, class Tpl, size_t... Idx, class Projection = polyfill::identity>
constexpr auto create_from_tuple(Tpl&& tpl, std::index_sequence<Idx...>, Projection project = {}) {
return R{polyfill::invoke(project, std::get<Idx>(std::forward<Tpl>(tpl)))...};
Expand All @@ -148,7 +147,6 @@ namespace sqlite_orm {
std::make_index_sequence<std::tuple_size<std::remove_reference_t<Tpl>>::value>{},
std::forward<Projection>(project));
}
#endif
#endif
}
}
2 changes: 0 additions & 2 deletions examples/any.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@
* BLOB is mapped to std::vector<char>.
*/
#include <sqlite_orm/sqlite_orm.h>
#ifdef __has_include
#if __has_include(<any>)
#include <any>
#endif
#endif

#if __cpp_lib_any >= 201606L
#define ENABLE_THIS_EXAMPLE
Expand Down
2 changes: 0 additions & 2 deletions examples/chrono_binding.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
#include <sqlite3.h>
#include <sqlite_orm/sqlite_orm.h>
#ifdef __has_include
#if __has_include(<version>)
#include <version>
#endif
#endif
#if __cpp_lib_chrono >= 201907L && __cpp_lib_format >= 201907L
#define ENABLE_THIS_EXAMPLE
#endif
Expand Down
55 changes: 12 additions & 43 deletions include/sqlite_orm/sqlite_orm.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,16 @@ using std::nullptr_t;

// note: Before the C++17 language standard was made the baseline, the library had workarounds for these specific missing C++14 language features,
// so they are kept here as explicit checks for reference.
#if __cpp_aggregate_nsdmi < 201304L || __cpp_constexpr < 201304L
#if (__cpp_aggregate_nsdmi < 201304L || __cpp_constexpr < 201304L)
#error A fully C++17-compliant compiler is required.
#endif

#if (__cpp_noexcept_function_type < 201510L) || \
(__cpp_fold_expressions < 201603L || __cpp_constexpr < 201603L || __cpp_aggregate_bases < 201603L || \
__cpp_range_based_for < 201603L) || \
(__cpp_if_constexpr < 201606L || __cpp_inline_variables < 201606L || __cpp_structured_bindings < 201606L)
#if (!defined(__has_include)) || \
((__cpp_noexcept_function_type < 201510L) || \
(__cpp_fold_expressions < 201603L || __cpp_constexpr < 201603L || __cpp_aggregate_bases < 201603L || \
__cpp_range_based_for < 201603L) || \
(__cpp_if_constexpr < 201606L || __cpp_inline_variables < 201606L || __cpp_structured_bindings < 201606L) || \
(__cpp_deduction_guides < 201703L))
#error A fully C++17-compliant compiler is required.
#endif

Expand All @@ -70,16 +72,6 @@ using std::nullptr_t;
#define SQLITE_ORM_HAS_CPP_ATTRIBUTE(attr) 0L
#endif

#ifdef __has_include
#define SQLITE_ORM_HAS_INCLUDE(file) __has_include(file)
#else
#define SQLITE_ORM_HAS_INCLUDE(file) 0L
#endif

#if __cpp_deduction_guides >= 201703L
#define SQLITE_ORM_CTAD_SUPPORTED
#endif

#if __cpp_generic_lambdas >= 201707L
#define SQLITE_ORM_EXPLICIT_GENERIC_LAMBDA_SUPPORTED
#endif
Expand Down Expand Up @@ -267,7 +259,7 @@ using std::nullptr_t;
#define SQLITE_ORM_EXPORT
#endif

#if SQLITE_ORM_HAS_INCLUDE(<version>)
#if __has_include(<version>)
#include <version>
#endif

Expand Down Expand Up @@ -366,11 +358,9 @@ namespace sqlite_orm {

#ifdef SQLITE_ORM_IMPORT_STD_MODULE
#include <version>
#else
#if SQLITE_ORM_HAS_INCLUDE(<optional>)
#elif __has_include(<optional>)
#include <optional>
#endif
#endif

#if __cpp_lib_optional >= 201606L
#define SQLITE_ORM_OPTIONAL_SUPPORTED
Expand Down Expand Up @@ -1741,7 +1731,6 @@ namespace sqlite_orm {
}
#endif

#ifdef SQLITE_ORM_CTAD_SUPPORTED
template<template<typename...> class R, class Tpl, size_t... Idx, class Projection = polyfill::identity>
constexpr auto create_from_tuple(Tpl&& tpl, std::index_sequence<Idx...>, Projection project = {}) {
return R{polyfill::invoke(project, std::get<Idx>(std::forward<Tpl>(tpl)))...};
Expand All @@ -1767,7 +1756,6 @@ namespace sqlite_orm {
std::make_index_sequence<std::tuple_size<std::remove_reference_t<Tpl>>::value>{},
std::forward<Projection>(project));
}
#endif
#endif
}
}
Expand Down Expand Up @@ -4514,11 +4502,9 @@ namespace sqlite_orm {

#ifdef SQLITE_ORM_IMPORT_STD_MODULE
#include <version>
#else
#if SQLITE_ORM_HAS_INCLUDE(<string_view>)
#elif __has_include(<string_view>)
#include <string_view>
#endif
#endif

#if __cpp_lib_string_view >= 201606L
#define SQLITE_ORM_STRING_VIEW_SUPPORTED
Expand Down Expand Up @@ -14594,15 +14580,14 @@ SQLITE_ORM_EXPORT namespace sqlite_orm {
static_assert(std::is_aggregate_v<connection_control>);
#endif

#ifdef SQLITE_ORM_CTAD_SUPPORTED
/**
* Callback function to be passed to `make_storage()`.
* The provided function is called immdediately after the database connection has been established and set up.
*/
inline internal::on_open_spec on_open(std::function<void(sqlite3*)> onOpen) {
return {std::move(onOpen)};
}
#endif

inline internal::will_run_query_spec
will_run_query(std::function<void(internal::serialize_arg_type)> willRunQuery) {
return {std::move(willRunQuery)};
Expand Down Expand Up @@ -23948,19 +23933,15 @@ namespace sqlite_orm {

template<class Opt, class OptionsTpl>
decltype(auto) storage_opt_or_default(OptionsTpl& options) {
#ifdef SQLITE_ORM_CTAD_SUPPORTED
if constexpr (tuple_has_type<OptionsTpl, Opt>::value) {
return std::move(std::get<Opt>(options));
} else {
return Opt{};
}
#else
return Opt{};
#endif
}

/**
* Storage class itself. Create an instanse to use it as an interfacto to sqlite db by calling `make_storage`
* Storage class itself. Create an instance to use it as an interfacto to sqlite db by calling `make_storage`
* function.
*/
template<class... DBO>
Expand Down Expand Up @@ -25619,7 +25600,6 @@ namespace sqlite_orm {
#endif // SQLITE_ORM_OPTIONAL_SUPPORTED
}; // struct storage_t

#ifdef SQLITE_ORM_CTAD_SUPPORTED
template<class Elements>
using dbo_index_sequence = filter_tuple_sequence_t<Elements, check_if_lacks<storage_opt_tag_t>::template fn>;

Expand All @@ -25630,12 +25610,10 @@ namespace sqlite_orm {
storage_t<DBO...> make_storage(std::string filename, std::tuple<DBO...> dbObjects, OptionsTpl options) {
return {std::move(filename), std::move(dbObjects), std::move(options)};
}
#endif
}
}

SQLITE_ORM_EXPORT namespace sqlite_orm {
#ifdef SQLITE_ORM_CTAD_SUPPORTED
/*
* Factory function for a storage instance, from a database file, a set of database object definitions
* and option storage options like connection control options and an 'on open' callback.
Expand All @@ -25653,15 +25631,6 @@ SQLITE_ORM_EXPORT namespace sqlite_orm {
create_from_tuple<std::tuple>(std::move(specTuple), dbo_index_sequence<decltype(specTuple)>{}),
create_from_tuple<std::tuple>(std::move(specTuple), opt_index_sequence<decltype(specTuple)>{}));
}
#else
/*
* Factory function for a storage instance, from a database file and a bunch of database object definitions.
*/
template<class... DBO>
internal::storage_t<DBO...> make_storage(std::string filename, DBO... dbObjects) {
return {std::move(filename), {std::forward<DBO>(dbObjects)...}, std::tuple<>{}};
}
#endif

/**
* sqlite3_threadsafe() interface.
Expand Down
2 changes: 0 additions & 2 deletions tests/storage_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

using namespace sqlite_orm;

#ifdef SQLITE_ORM_CTAD_SUPPORTED
TEST_CASE("connection control") {
const auto openForever = GENERATE(false, true);
SECTION("") {
Expand Down Expand Up @@ -57,7 +56,6 @@ TEST_CASE("connection control") {
}
}
}
#endif

TEST_CASE("Current time/date/timestamp") {
auto storage = make_storage("");
Expand Down
Loading