diff --git a/dev/storage.h b/dev/storage.h index 33f37cdb8..1d5a53563 100644 --- a/dev/storage.h +++ b/dev/storage.h @@ -586,7 +586,7 @@ namespace sqlite_orm { static_assert(is_preparable_v, "Expression must be a high-level statement"); decltype(auto) e2 = static_if>( - [](auto expression) -> auto { + [](auto expression) -> auto{ expression.highest_level = true; return expression; }, diff --git a/dev/type_is_nullable.h b/dev/type_is_nullable.h index a88b42b1c..1f77b95cf 100644 --- a/dev/type_is_nullable.h +++ b/dev/type_is_nullable.h @@ -1,5 +1,6 @@ #pragma once +#include // std::false_type, std::true_type, std::enable_if #include // std::shared_ptr, std::unique_ptr #include "functional/cxx_optional.h" @@ -14,12 +15,27 @@ namespace sqlite_orm { * custom type as `NULL` (for example: boost::optional) you have to create a specialiation * of type_is_nullable for your type and derive from `std::true_type`. */ + template + struct type_is_nullable : std::false_type { + bool operator()(const T&) const { + return true; + } + }; + + /** + * This is a specialization for std::shared_ptr, std::unique_ptr, std::optional, which are nullable in sqlite_orm. + */ template - using type_is_nullable = polyfill::disjunction< + struct type_is_nullable, + polyfill::is_specialization_of, #endif - polyfill::is_specialization_of, - polyfill::is_specialization_of>; + polyfill::is_specialization_of, + polyfill::is_specialization_of>>> : std::true_type { + bool operator()(const T& t) const { + return static_cast(t); + } + }; } diff --git a/dev/xdestroy_handling.h b/dev/xdestroy_handling.h index e9f986a03..25e172a32 100644 --- a/dev/xdestroy_handling.h +++ b/dev/xdestroy_handling.h @@ -29,20 +29,20 @@ namespace sqlite_orm { */ template concept integral_fp_c = requires { - typename D::value_type; - D::value; - requires std::is_function_v>; - }; + typename D::value_type; + D::value; + requires std::is_function_v>; + }; /** * Constraints a deleter to be or to yield a function pointer. */ template concept yields_fp = requires(D d) { - // yielding function pointer by using the plus trick - {+d}; - requires std::is_function_v>; - }; + // yielding function pointer by using the plus trick + { +d }; + requires std::is_function_v>; + }; #endif #if __cpp_lib_concepts >= 201907L @@ -57,7 +57,7 @@ namespace sqlite_orm { template SQLITE_ORM_INLINE_VAR constexpr bool is_stateless_deleter_v = - std::is_empty::value&& std::is_default_constructible::value; + std::is_empty::value && std::is_default_constructible::value; template struct is_integral_fp_c : std::false_type {}; @@ -118,7 +118,8 @@ namespace sqlite_orm { * it doesn't check so explicitly, but a compiler error will occur. */ template - requires(!integral_fp_c) void xdestroy_proxy(void* p) noexcept { + requires(!integral_fp_c) + void xdestroy_proxy(void* p) noexcept { // C-casting `void* -> P*` like statement_binder> auto o = (P*)p; // ignoring return code @@ -146,7 +147,7 @@ namespace sqlite_orm { template SQLITE_ORM_INLINE_VAR constexpr bool can_yield_xdestroy_v = - can_yield_fp_v&& std::is_convertible, xdestroy_fn_t>::value; + can_yield_fp_v && std::is_convertible, xdestroy_fn_t>::value; template SQLITE_ORM_INLINE_VAR constexpr bool needs_xdestroy_proxy_v = @@ -181,7 +182,9 @@ namespace sqlite_orm { * Explicitly declared for better error messages. */ template - constexpr xdestroy_fn_t obtain_xdestroy_for(D, P*) noexcept requires(internal::is_unusable_for_xdestroy) { + constexpr xdestroy_fn_t obtain_xdestroy_for(D, P*) noexcept + requires(internal::is_unusable_for_xdestroy) + { static_assert(polyfill::always_false_v, "A function pointer, which is not of type xdestroy_fn_t, is prohibited."); return nullptr; @@ -200,7 +203,9 @@ namespace sqlite_orm { * is invocable with the non-q-qualified pointer value. */ template - constexpr xdestroy_fn_t obtain_xdestroy_for(D, P*) noexcept requires(internal::needs_xdestroy_proxy) { + constexpr xdestroy_fn_t obtain_xdestroy_for(D, P*) noexcept + requires(internal::needs_xdestroy_proxy) + { return internal::xdestroy_proxy; } @@ -219,7 +224,9 @@ namespace sqlite_orm { * is invocable with the non-q-qualified pointer value. */ template - constexpr xdestroy_fn_t obtain_xdestroy_for(D d, P*) noexcept requires(internal::yields_xdestroy) { + constexpr xdestroy_fn_t obtain_xdestroy_for(D d, P*) noexcept + requires(internal::yields_xdestroy) + { return d; } #else diff --git a/examples/nullable_enum_binding.cpp b/examples/nullable_enum_binding.cpp index 46d360cc8..8625af059 100644 --- a/examples/nullable_enum_binding.cpp +++ b/examples/nullable_enum_binding.cpp @@ -99,7 +99,7 @@ namespace sqlite_orm { * specializing type_is_nullable and deriving from std::true_type. */ template<> - struct type_is_nullable : public std::true_type { + struct type_is_nullable : std::true_type { // this function must return whether value null or not (false is null). Don't forget to implement it bool operator()(const Gender& g) const { diff --git a/include/sqlite_orm/sqlite_orm.h b/include/sqlite_orm/sqlite_orm.h index 3ead3a346..56022ee29 100644 --- a/include/sqlite_orm/sqlite_orm.h +++ b/include/sqlite_orm/sqlite_orm.h @@ -16,6 +16,7 @@ __pragma(push_macro("max")) // #include "cxx_universal.h" + /* * This header makes central C++ functionality on which sqlite_orm depends universally available: * - alternative operator representations @@ -34,6 +35,7 @@ using std::nullptr_t; // #include "cxx_core_features.h" + #ifdef __has_cpp_attribute #define SQLITE_ORM_HAS_CPP_ATTRIBUTE(attr) __has_cpp_attribute(attr) #else @@ -107,6 +109,7 @@ using std::nullptr_t; // #include "cxx_compiler_quirks.h" + #ifdef __clang__ #define SQLITE_ORM_DO_PRAGMA(...) _Pragma(#__VA_ARGS__) #endif @@ -136,6 +139,8 @@ using std::nullptr_t; #define SQLITE_ORM_BROKEN_VARIADIC_PACK_EXPANSION #endif + + namespace sqlite_orm { namespace internal { namespace polyfill { @@ -277,6 +282,7 @@ namespace sqlite_orm { namespace polyfill = internal::polyfill; } + namespace sqlite_orm { // C++ generic traits used throughout the library namespace internal { @@ -505,8 +511,10 @@ namespace sqlite_orm { #include // std::vector // #include "functional/cxx_optional.h" + // #include "cxx_core_features.h" + #if SQLITE_ORM_HAS_INCLUDE() #include #endif @@ -515,6 +523,7 @@ namespace sqlite_orm { #define SQLITE_ORM_OPTIONAL_SUPPORTED #endif + // #include "functional/cxx_type_traits_polyfill.h" // #include "type_traits.h" @@ -551,6 +560,7 @@ namespace sqlite_orm { }; } + namespace sqlite_orm { /** @@ -649,6 +659,7 @@ namespace sqlite_orm { // #include "functional/mpl.h" + /* * Symbols for 'template metaprogramming' (compile-time template programming), * inspired by the MPL of Aleksey Gurtovoy and David Abrahams. @@ -677,6 +688,7 @@ namespace sqlite_orm { // #include "cxx_type_traits_polyfill.h" + namespace sqlite_orm { namespace internal { namespace mpl { @@ -957,6 +969,7 @@ namespace sqlite_orm { // #include "tuple_helper/same_or_void.h" + namespace sqlite_orm { namespace internal { @@ -986,6 +999,7 @@ namespace sqlite_orm { // #include "tuple_helper/tuple_traits.h" + #include // std::is_same #include @@ -993,6 +1007,7 @@ namespace sqlite_orm { // #include "../functional/mpl.h" + namespace sqlite_orm { namespace internal { /* @@ -1040,6 +1055,7 @@ namespace sqlite_orm { } // #include "tuple_helper/tuple_filter.h" + #include // std::integral_constant, std::index_sequence, std::conditional, std::declval #include // std::tuple @@ -1047,6 +1063,7 @@ namespace sqlite_orm { // #include "../functional/index_sequence_util.h" + #include // std::index_sequence, std::make_index_sequence // #include "../functional/cxx_universal.h" @@ -1115,6 +1132,7 @@ namespace sqlite_orm { } } + namespace sqlite_orm { namespace internal { @@ -1206,6 +1224,7 @@ namespace sqlite_orm { // #include "table_type_of.h" + namespace sqlite_orm { namespace internal { @@ -1242,6 +1261,7 @@ namespace sqlite_orm { // #include "type_printer.h" + namespace sqlite_orm { namespace internal { @@ -1784,11 +1804,14 @@ namespace sqlite_orm { } #pragma once +#include // std::false_type, std::true_type, std::enable_if #include // std::shared_ptr, std::unique_ptr // #include "functional/cxx_optional.h" + // #include "functional/cxx_type_traits_polyfill.h" + namespace sqlite_orm { /** @@ -1798,13 +1821,28 @@ namespace sqlite_orm { * custom type as `NULL` (for example: boost::optional) you have to create a specialiation * of type_is_nullable for your type and derive from `std::true_type`. */ + template + struct type_is_nullable : std::false_type { + bool operator()(const T&) const { + return true; + } + }; + + /** + * This is a specialization for std::shared_ptr, std::unique_ptr, std::optional, which are nullable in sqlite_orm. + */ template - using type_is_nullable = polyfill::disjunction< + struct type_is_nullable, + polyfill::is_specialization_of, #endif - polyfill::is_specialization_of, - polyfill::is_specialization_of>; + polyfill::is_specialization_of, + polyfill::is_specialization_of>>> : std::true_type { + bool operator()(const T& t) const { + return static_cast(t); + } + }; } #pragma once @@ -1813,8 +1851,10 @@ namespace sqlite_orm { #include // std::move // #include "functional/cxx_optional.h" + // #include "tags.h" + namespace sqlite_orm { namespace internal { struct negatable_t {}; @@ -1828,10 +1868,13 @@ namespace sqlite_orm { // #include "serialize_result_type.h" + // #include "functional/cxx_string_view.h" + // #include "cxx_core_features.h" + #if SQLITE_ORM_HAS_INCLUDE() #include #endif @@ -1854,6 +1897,7 @@ namespace sqlite_orm { } } + namespace sqlite_orm { namespace internal { @@ -2142,12 +2186,14 @@ namespace sqlite_orm { // #include "member_traits/member_traits.h" + #include // std::enable_if, std::is_function, std::true_type, std::false_type // #include "../functional/cxx_universal.h" // #include "../functional/cxx_type_traits_polyfill.h" + namespace sqlite_orm { namespace internal { // SFINAE friendly trait to get a member object pointer's field type @@ -2239,6 +2285,7 @@ namespace sqlite_orm { // #include "constraints.h" + namespace sqlite_orm { namespace internal { @@ -2417,12 +2464,14 @@ namespace sqlite_orm { #endif // SQLITE_ORM_OMITS_CODECVT // #include "functional/cxx_optional.h" + // #include "functional/cxx_universal.h" // #include "functional/cxx_type_traits_polyfill.h" // #include "is_std_ptr.h" + namespace sqlite_orm { /** @@ -2586,6 +2635,7 @@ namespace sqlite_orm { // #include "optional_container.h" + namespace sqlite_orm { namespace internal { @@ -2620,6 +2670,7 @@ namespace sqlite_orm { // #include "serializer_context.h" + namespace sqlite_orm { namespace internal { @@ -2661,14 +2712,17 @@ namespace sqlite_orm { // #include "expression.h" + #include #include // std::move, std::forward // #include "functional/cxx_optional.h" + // #include "functional/cxx_universal.h" // #include "operators.h" + namespace sqlite_orm { namespace internal { @@ -2747,6 +2801,7 @@ namespace sqlite_orm { // #include "literal.h" + namespace sqlite_orm { namespace internal { @@ -2763,6 +2818,7 @@ namespace sqlite_orm { } } + namespace sqlite_orm { namespace internal { @@ -4180,6 +4236,7 @@ namespace sqlite_orm { // #include "conditions.h" + namespace sqlite_orm { namespace internal { @@ -4293,6 +4350,7 @@ namespace sqlite_orm { // #include "is_base_of_template.h" + #include // std::true_type, std::false_type, std::declval namespace sqlite_orm { @@ -4338,8 +4396,10 @@ namespace sqlite_orm { // #include "ast/into.h" + // #include "../functional/cxx_type_traits_polyfill.h" + namespace sqlite_orm { namespace internal { @@ -4358,6 +4418,7 @@ namespace sqlite_orm { } } + namespace sqlite_orm { using int64 = sqlite_int64; @@ -6461,6 +6522,7 @@ namespace sqlite_orm { #include // std::tuple, std::get, std::tuple_size // #include "functional/cxx_optional.h" + // #include "functional/cxx_universal.h" // #include "functional/cxx_type_traits_polyfill.h" @@ -6473,6 +6535,7 @@ namespace sqlite_orm { // #include "ast/where.h" + #include // std::false_type, std::true_type #include // std::move @@ -6482,6 +6545,7 @@ namespace sqlite_orm { // #include "../serialize_result_type.h" + namespace sqlite_orm { namespace internal { @@ -6529,12 +6593,14 @@ namespace sqlite_orm { // #include "ast/group_by.h" + #include // std::tuple, std::make_tuple #include // std::true_type, std::false_type #include // std::forward, std::move // #include "../functional/cxx_type_traits_polyfill.h" + namespace sqlite_orm { namespace internal { @@ -6604,6 +6670,7 @@ namespace sqlite_orm { // #include "core_functions.h" + namespace sqlite_orm { namespace internal { @@ -7080,6 +7147,7 @@ namespace sqlite_orm { // #include "functional/cxx_universal.h" + namespace sqlite_orm { struct table_info { @@ -7136,6 +7204,7 @@ namespace sqlite_orm { // #include "optional_container.h" + // NOTE Idea : Maybe also implement a custom trigger system to call a c++ callback when a trigger triggers ? // (Could be implemented with a normal trigger that insert or update an internal table and then retreive // the event in the C++ code, to call the C++ user callback, with update hooks: https://www.sqlite.org/c3ref/update_hook.html) @@ -7168,7 +7237,7 @@ namespace sqlite_orm { partial_trigger_t(T trigger_base, S... statements) : base{std::move(trigger_base)}, statements{std::make_tuple(std::forward(statements)...)} {} - partial_trigger_t& end() { + partial_trigger_t &end() { return *this; } }; @@ -7237,7 +7306,7 @@ namespace sqlite_orm { trigger_base_t(trigger_type_base type_base_) : type_base(std::move(type_base_)) {} - trigger_base_t& for_each_row() { + trigger_base_t &for_each_row() { this->do_for_each_row = true; return *this; } @@ -7398,7 +7467,7 @@ namespace sqlite_orm { } template - internal::trigger_t make_trigger(std::string name, const internal::partial_trigger_t& part) { + internal::trigger_t make_trigger(std::string name, const internal::partial_trigger_t &part) { SQLITE_ORM_CLANG_SUPPRESS_MISSING_BRACES(return {move(name), std::move(part.base), std::move(part.statements)}); } @@ -7458,6 +7527,7 @@ namespace sqlite_orm { // #include "xdestroy_handling.h" + #include // std::integral_constant #if defined(SQLITE_ORM_CONCEPTS_SUPPORTED) && SQLITE_ORM_HAS_INCLUDE() #include @@ -7467,6 +7537,7 @@ namespace sqlite_orm { // #include "functional/cxx_type_traits_polyfill.h" + namespace sqlite_orm { using xdestroy_fn_t = void (*)(void*); @@ -7488,20 +7559,20 @@ namespace sqlite_orm { */ template concept integral_fp_c = requires { - typename D::value_type; - D::value; - requires std::is_function_v>; - }; + typename D::value_type; + D::value; + requires std::is_function_v>; + }; /** * Constraints a deleter to be or to yield a function pointer. */ template concept yields_fp = requires(D d) { - // yielding function pointer by using the plus trick - {+d}; - requires std::is_function_v>; - }; + // yielding function pointer by using the plus trick + { +d }; + requires std::is_function_v>; + }; #endif #if __cpp_lib_concepts >= 201907L @@ -7516,7 +7587,7 @@ namespace sqlite_orm { template SQLITE_ORM_INLINE_VAR constexpr bool is_stateless_deleter_v = - std::is_empty::value&& std::is_default_constructible::value; + std::is_empty::value && std::is_default_constructible::value; template struct is_integral_fp_c : std::false_type {}; @@ -7577,7 +7648,8 @@ namespace sqlite_orm { * it doesn't check so explicitly, but a compiler error will occur. */ template - requires(!integral_fp_c) void xdestroy_proxy(void* p) noexcept { + requires(!integral_fp_c) + void xdestroy_proxy(void* p) noexcept { // C-casting `void* -> P*` like statement_binder> auto o = (P*)p; // ignoring return code @@ -7605,7 +7677,7 @@ namespace sqlite_orm { template SQLITE_ORM_INLINE_VAR constexpr bool can_yield_xdestroy_v = - can_yield_fp_v&& std::is_convertible, xdestroy_fn_t>::value; + can_yield_fp_v && std::is_convertible, xdestroy_fn_t>::value; template SQLITE_ORM_INLINE_VAR constexpr bool needs_xdestroy_proxy_v = @@ -7640,7 +7712,9 @@ namespace sqlite_orm { * Explicitly declared for better error messages. */ template - constexpr xdestroy_fn_t obtain_xdestroy_for(D, P*) noexcept requires(internal::is_unusable_for_xdestroy) { + constexpr xdestroy_fn_t obtain_xdestroy_for(D, P*) noexcept + requires(internal::is_unusable_for_xdestroy) + { static_assert(polyfill::always_false_v, "A function pointer, which is not of type xdestroy_fn_t, is prohibited."); return nullptr; @@ -7659,7 +7733,9 @@ namespace sqlite_orm { * is invocable with the non-q-qualified pointer value. */ template - constexpr xdestroy_fn_t obtain_xdestroy_for(D, P*) noexcept requires(internal::needs_xdestroy_proxy) { + constexpr xdestroy_fn_t obtain_xdestroy_for(D, P*) noexcept + requires(internal::needs_xdestroy_proxy) + { return internal::xdestroy_proxy; } @@ -7678,7 +7754,9 @@ namespace sqlite_orm { * is invocable with the non-q-qualified pointer value. */ template - constexpr xdestroy_fn_t obtain_xdestroy_for(D d, P*) noexcept requires(internal::yields_xdestroy) { + constexpr xdestroy_fn_t obtain_xdestroy_for(D d, P*) noexcept + requires(internal::yields_xdestroy) + { return d; } #else @@ -7701,6 +7779,7 @@ namespace sqlite_orm { #endif } + namespace sqlite_orm { /** @@ -7897,6 +7976,7 @@ namespace sqlite_orm { #endif // #include "../member_traits/member_traits.h" + namespace sqlite_orm { namespace internal { namespace polyfill { @@ -7975,6 +8055,7 @@ namespace sqlite_orm { // #include "pointer_value.h" + namespace sqlite_orm { /** @@ -8338,6 +8419,7 @@ namespace sqlite_orm { // #include "journal_mode.h" + #include // std::back_inserter #include // std::string #include // std::unique_ptr @@ -8414,6 +8496,7 @@ namespace sqlite_orm { // #include "is_std_ptr.h" + namespace sqlite_orm { /** @@ -8738,6 +8821,7 @@ namespace sqlite_orm { // #include "error_code.h" + namespace sqlite_orm { /** @@ -8933,6 +9017,7 @@ namespace sqlite_orm { // #include "indexed_column.h" + #include // std::string #include // std::move @@ -8940,6 +9025,7 @@ namespace sqlite_orm { // #include "ast/where.h" + namespace sqlite_orm { namespace internal { @@ -9003,6 +9089,7 @@ namespace sqlite_orm { } + namespace sqlite_orm { namespace internal { @@ -9056,6 +9143,7 @@ namespace sqlite_orm { // #include "alias.h" + namespace sqlite_orm { namespace internal { @@ -9171,6 +9259,7 @@ namespace sqlite_orm { // #include "storage_traits.h" + #include // std::tuple // #include "functional/cxx_type_traits_polyfill.h" @@ -9179,10 +9268,12 @@ namespace sqlite_orm { // #include "tuple_helper/tuple_transformer.h" + #include // std::tuple // #include "../functional/mpl.h" + namespace sqlite_orm { namespace internal { @@ -9208,6 +9299,7 @@ namespace sqlite_orm { // #include "storage_lookup.h" + #include // std::true_type, std::false_type, std::remove_const, std::enable_if #include #include // std::index_sequence @@ -9218,6 +9310,7 @@ namespace sqlite_orm { // #include "type_traits.h" + namespace sqlite_orm { namespace internal { @@ -9346,6 +9439,7 @@ namespace sqlite_orm { } } + namespace sqlite_orm { namespace internal { @@ -9376,6 +9470,7 @@ namespace sqlite_orm { // #include "function.h" + #include #include #include // std::string @@ -9388,6 +9483,7 @@ namespace sqlite_orm { // #include "functional/cxx_type_traits_polyfill.h" + namespace sqlite_orm { struct arg_values; @@ -9401,13 +9497,13 @@ namespace sqlite_orm { struct user_defined_function_base { using func_call = std::function< - void(sqlite3_context* context, void* functionPointer, int argsCount, sqlite3_value** values)>; - using final_call = std::function; + void(sqlite3_context *context, void *functionPointer, int argsCount, sqlite3_value **values)>; + using final_call = std::function; std::string name; int argumentsCount = 0; - std::function create; - void (*destroy)(int*) = nullptr; + std::function create; + void (*destroy)(int *) = nullptr; #ifndef SQLITE_ORM_AGGREGATE_NSDMI_SUPPORTED user_defined_function_base(decltype(name) name_, @@ -9539,7 +9635,7 @@ namespace sqlite_orm { constexpr bool is_same_pvt_v> = true; #if __cplusplus >= 201703L // using C++17 or higher - template + template SQLITE_ORM_CONSTEVAL bool assert_same_pointer_type() { constexpr bool valid = Binding == PointerArg; static_assert(valid, "Pointer value types of I-th argument do not match"); @@ -9622,6 +9718,7 @@ namespace sqlite_orm { } + namespace sqlite_orm { namespace internal { @@ -9908,6 +10005,7 @@ namespace sqlite_orm { // #include "functional/static_magic.h" + #include // std::false_type, std::true_type, std::integral_constant #include // std::forward @@ -9990,6 +10088,7 @@ namespace sqlite_orm { // #include "tuple_helper/tuple_iteration.h" + #include // std::tuple, std::get, std::tuple_element, std::tuple_size #include // std::index_sequence, std::make_index_sequence #include // std::forward, std::move @@ -10002,6 +10101,7 @@ namespace sqlite_orm { // #include "../functional/index_sequence_util.h" + namespace sqlite_orm { namespace internal { @@ -10131,6 +10231,7 @@ namespace sqlite_orm { // #include "column.h" + namespace sqlite_orm { namespace internal { @@ -10433,6 +10534,7 @@ namespace sqlite_orm { // #include "storage_lookup.h" + // interface functions namespace sqlite_orm { namespace internal { @@ -10517,6 +10619,7 @@ namespace sqlite_orm { // #include "storage_lookup.h" + namespace sqlite_orm { namespace internal { @@ -10553,6 +10656,7 @@ namespace sqlite_orm { #include // std::for_each, std::ranges::for_each // #include "functional/cxx_optional.h" + // #include "functional/cxx_universal.h" // #include "functional/cxx_functional_polyfill.h" @@ -10573,16 +10677,19 @@ namespace sqlite_orm { // #include "row_extractor_builder.h" + // #include "functional/cxx_universal.h" // #include "row_extractor.h" // #include "mapped_row_extractor.h" + #include // #include "object_from_column_builder.h" + #include #include // std::is_member_object_pointer @@ -10590,6 +10697,7 @@ namespace sqlite_orm { // #include "row_extractor.h" + namespace sqlite_orm { namespace internal { @@ -10630,6 +10738,7 @@ namespace sqlite_orm { } } + namespace sqlite_orm { namespace internal { @@ -10660,6 +10769,7 @@ namespace sqlite_orm { } + namespace sqlite_orm { namespace internal { @@ -10711,6 +10821,7 @@ namespace sqlite_orm { // #include "view.h" + #include #include // std::string #include // std::forward, std::move @@ -10722,6 +10833,7 @@ namespace sqlite_orm { // #include "iterator.h" + #include #include // std::shared_ptr, std::unique_ptr, std::make_shared #include // std::decay @@ -10742,6 +10854,7 @@ namespace sqlite_orm { // #include "util.h" + namespace sqlite_orm { namespace internal { @@ -10829,6 +10942,7 @@ namespace sqlite_orm { // #include "ast_iterator.h" + #include // std::vector #include // std::reference_wrapper @@ -10844,6 +10958,7 @@ namespace sqlite_orm { // #include "prepared_statement.h" + #include #include // std::unique_ptr #include // std::iterator_traits @@ -10861,12 +10976,14 @@ namespace sqlite_orm { // #include "connection_holder.h" + #include #include #include // std::string // #include "error_code.h" + namespace sqlite_orm { namespace internal { @@ -10939,6 +11056,7 @@ namespace sqlite_orm { // #include "values.h" + #include // std::vector #include // std::tuple #include // std::forward @@ -10947,6 +11065,7 @@ namespace sqlite_orm { // #include "functional/cxx_type_traits_polyfill.h" + namespace sqlite_orm { namespace internal { @@ -10985,12 +11104,14 @@ namespace sqlite_orm { // #include "ast/upsert_clause.h" + #include // std::tuple, std::make_tuple #include // std::false_type, std::true_type #include // std::forward, std::move // #include "../functional/cxx_type_traits_polyfill.h" + namespace sqlite_orm { namespace internal { #if SQLITE_VERSION_NUMBER >= 3024000 @@ -11046,6 +11167,7 @@ namespace sqlite_orm { #endif } + namespace sqlite_orm { namespace internal { @@ -11787,6 +11909,7 @@ namespace sqlite_orm { // #include "ast/excluded.h" + #include // std::move namespace sqlite_orm { @@ -11816,10 +11939,12 @@ namespace sqlite_orm { // #include "ast/exists.h" + #include // std::move // #include "../tags.h" + namespace sqlite_orm { namespace internal { @@ -11848,6 +11973,7 @@ namespace sqlite_orm { } } + namespace sqlite_orm { namespace internal { @@ -12527,6 +12653,7 @@ namespace sqlite_orm { // #include "util.h" + namespace sqlite_orm { namespace internal { @@ -12583,6 +12710,7 @@ namespace sqlite_orm { // #include "storage_base.h" + #include #include // std::function, std::bind #include // std::string @@ -12603,6 +12731,7 @@ namespace sqlite_orm { // #include "pragma.h" + #include #include // std::string #include // std::function @@ -12622,6 +12751,7 @@ namespace sqlite_orm { // #include "serializing_util.h" + #include // std::index_sequence #include #include @@ -12645,6 +12775,7 @@ namespace sqlite_orm { // #include "util.h" + namespace sqlite_orm { namespace internal { template @@ -12670,18 +12801,18 @@ namespace sqlite_orm { } } #else - inline void stream_sql_escaped(std::ostream& os, const std::string& str, char char2Escape) { - if(str.find(char2Escape) == str.npos) { - os << str; - } else { - for(char c: str) { - if(c == char2Escape) { - os << char2Escape; - } - os << c; + inline void stream_sql_escaped(std::ostream& os, const std::string& str, char char2Escape) { + if(str.find(char2Escape) == str.npos) { + os << str; + } else { + for(char c: str) { + if(c == char2Escape) { + os << char2Escape; } + os << c; } } + } #endif inline void stream_identifier(std::ostream& ss, @@ -13046,6 +13177,7 @@ namespace sqlite_orm { } } + namespace sqlite_orm { namespace internal { @@ -13254,6 +13386,7 @@ namespace sqlite_orm { // #include "limit_accessor.h" + #include #include // std::map #include // std::function @@ -13261,6 +13394,7 @@ namespace sqlite_orm { // #include "connection_holder.h" + namespace sqlite_orm { namespace internal { @@ -13394,11 +13528,13 @@ namespace sqlite_orm { // #include "transaction_guard.h" + #include // std::function #include // std::move // #include "connection_holder.h" + namespace sqlite_orm { namespace internal { @@ -13425,7 +13561,7 @@ namespace sqlite_orm { connection(std::move(connection_)), commit_func(move(commit_func_)), rollback_func(move(rollback_func_)) {} - transaction_guard_t(transaction_guard_t&& other) : + transaction_guard_t(transaction_guard_t &&other) : commit_on_destroy(other.commit_on_destroy), connection(std::move(other.connection)), commit_func(move(other.commit_func)), rollback_func(move(other.rollback_func)), gotta_fire(other.gotta_fire) { @@ -13442,7 +13578,7 @@ namespace sqlite_orm { } } - transaction_guard_t& operator=(transaction_guard_t&&) = delete; + transaction_guard_t &operator=(transaction_guard_t &&) = delete; /** * Call `COMMIT` explicitly. After this call @@ -13479,6 +13615,7 @@ namespace sqlite_orm { // #include "backup.h" + #include #include // std::system_error #include // std::string @@ -13489,6 +13626,7 @@ namespace sqlite_orm { // #include "connection_holder.h" + namespace sqlite_orm { namespace internal { @@ -13556,6 +13694,7 @@ namespace sqlite_orm { // #include "values_to_tuple.h" + #include #include // std::index_sequence, std::make_index_sequence #include // std::tuple, std::tuple_size, std::get @@ -13566,17 +13705,19 @@ namespace sqlite_orm { // #include "arg_values.h" + #include // #include "row_extractor.h" + namespace sqlite_orm { struct arg_value { arg_value() : arg_value(nullptr) {} - arg_value(sqlite3_value* value_) : value(value_) {} + arg_value(sqlite3_value *value_) : value(value_) {} template T get() const { @@ -13613,18 +13754,18 @@ namespace sqlite_orm { } private: - sqlite3_value* value = nullptr; + sqlite3_value *value = nullptr; }; struct arg_values { struct iterator { - iterator(const arg_values& container_, int index_) : + iterator(const arg_values &container_, int index_) : container(container_), index(index_), currentValue(index_ < int(container_.size()) ? container_[index_] : arg_value()) {} - iterator& operator++() { + iterator &operator++() { ++this->index; if(this->index < int(this->container.size())) { this->currentValue = this->container[this->index]; @@ -13653,27 +13794,27 @@ namespace sqlite_orm { } } - arg_value* operator->() const { + arg_value *operator->() const { return &this->currentValue; } - bool operator==(const iterator& other) const { + bool operator==(const iterator &other) const { return &other.container == &this->container && other.index == this->index; } - bool operator!=(const iterator& other) const { + bool operator!=(const iterator &other) const { return !(*this == other); } private: - const arg_values& container; + const arg_values &container; int index = 0; mutable arg_value currentValue; }; arg_values() : arg_values(0, nullptr) {} - arg_values(int argsCount_, sqlite3_value** values_) : argsCount(argsCount_), values(values_) {} + arg_values(int argsCount_, sqlite3_value **values_) : argsCount(argsCount_), values(values_) {} size_t size() const { return this->argsCount; @@ -13685,7 +13826,7 @@ namespace sqlite_orm { arg_value operator[](int index) const { if(index < this->argsCount && index >= 0) { - sqlite3_value* value = this->values[index]; + sqlite3_value *value = this->values[index]; return {value}; } else { throw std::system_error{orm_error_code::index_is_out_of_bounds}; @@ -13706,10 +13847,11 @@ namespace sqlite_orm { private: int argsCount = 0; - sqlite3_value** values = nullptr; + sqlite3_value **values = nullptr; }; } + namespace sqlite_orm { namespace internal { @@ -13731,13 +13873,13 @@ namespace sqlite_orm { (this->extract(values[Idx], std::get(tuple)), ...); } #else - template - void operator()(sqlite3_value** values, Tpl& tuple, std::index_sequence) const { - this->extract(values[I], std::get(tuple)); - (*this)(values, tuple, std::index_sequence{}); - } - template - void operator()(sqlite3_value** /*values*/, Tpl&, std::index_sequence) const {} + template + void operator()(sqlite3_value** values, Tpl& tuple, std::index_sequence) const { + this->extract(values[I], std::get(tuple)); + (*this)(values, tuple, std::index_sequence{}); + } + template + void operator()(sqlite3_value** /*values*/, Tpl&, std::index_sequence) const {} #endif template void extract(sqlite3_value* value, T& t) const { @@ -13753,6 +13895,7 @@ namespace sqlite_orm { // #include "serializing_util.h" + namespace sqlite_orm { namespace internal { @@ -14519,11 +14662,13 @@ namespace sqlite_orm { // #include "expression_object_type.h" + #include // std::decay #include // std::reference_wrapper // #include "prepared_statement.h" + namespace sqlite_orm { namespace internal { @@ -14657,6 +14802,7 @@ namespace sqlite_orm { // #include "statement_serializer.h" + #include // std::stringstream #include // std::string #include // std::enable_if, std::remove_pointer @@ -14669,6 +14815,7 @@ namespace sqlite_orm { #include // #include "functional/cxx_string_view.h" + // #include "functional/cxx_universal.h" // #include "functional/cxx_functional_polyfill.h" @@ -14711,6 +14858,7 @@ namespace sqlite_orm { // #include "table_name_collector.h" + #include // std::set #include // std::string #include // std::function @@ -14726,13 +14874,14 @@ namespace sqlite_orm { // #include "core_functions.h" + namespace sqlite_orm { namespace internal { struct table_name_collector { using table_name_set = std::set>; - using find_table_name_t = std::function; + using find_table_name_t = std::function; find_table_name_t find_table_name; mutable table_name_set table_names; @@ -14742,7 +14891,7 @@ namespace sqlite_orm { table_name_collector(find_table_name_t find_table_name) : find_table_name{move(find_table_name)} {} template - table_name_set operator()(const T&) const { + table_name_set operator()(const T &) const { return {}; } @@ -14752,17 +14901,17 @@ namespace sqlite_orm { } template - void operator()(const column_pointer&) const { + void operator()(const column_pointer &) const { table_names.emplace(this->find_table_name(typeid(T)), ""); } template - void operator()(const alias_column_t& a) const { + void operator()(const alias_column_t &a) const { (*this)(a.column, alias_extractor::get()); } template - void operator()(const count_asterisk_t&) const { + void operator()(const count_asterisk_t &) const { auto tableName = this->find_table_name(typeid(T)); if(!tableName.empty()) { table_names.emplace(move(tableName), ""); @@ -14770,12 +14919,12 @@ namespace sqlite_orm { } template = true> - void operator()(const asterisk_t&) const { + void operator()(const asterisk_t &) const { table_names.emplace(this->find_table_name(typeid(T)), ""); } template = true> - void operator()(const asterisk_t&) const { + void operator()(const asterisk_t &) const { // note: not all alias classes have a nested A::type static_assert(polyfill::is_detected_v, "alias must have a nested alias::type typename"); @@ -14784,22 +14933,22 @@ namespace sqlite_orm { } template - void operator()(const object_t&) const { + void operator()(const object_t &) const { table_names.emplace(this->find_table_name(typeid(T)), ""); } template - void operator()(const table_rowid_t&) const { + void operator()(const table_rowid_t &) const { table_names.emplace(this->find_table_name(typeid(T)), ""); } template - void operator()(const table_oid_t&) const { + void operator()(const table_oid_t &) const { table_names.emplace(this->find_table_name(typeid(T)), ""); } template - void operator()(const table__rowid_t&) const { + void operator()(const table__rowid_t &) const { table_names.emplace(this->find_table_name(typeid(T)), ""); } }; @@ -14810,6 +14959,7 @@ namespace sqlite_orm { // #include "column_names_getter.h" + #include // std::system_error #include // std::string #include // std::vector @@ -14825,6 +14975,7 @@ namespace sqlite_orm { // #include "util.h" + namespace sqlite_orm { namespace internal { @@ -14929,6 +15080,7 @@ namespace sqlite_orm { // #include "order_by_serializer.h" + #include // std::string #include // std::stringstream @@ -15020,6 +15172,7 @@ namespace sqlite_orm { // #include "util.h" + namespace sqlite_orm { namespace internal { @@ -15765,7 +15918,7 @@ namespace sqlite_orm { using statement_type = conflict_clause_t; template - std::string operator()(const statement_type& statement, const Ctx& context) const { + std::string operator()(const statement_type& statement, const Ctx&) const { switch(statement) { case conflict_clause_t::rollback: return "ROLLBACK"; @@ -17050,6 +17203,7 @@ namespace sqlite_orm { // #include "serializing_util.h" + namespace sqlite_orm { namespace internal { @@ -17582,7 +17736,7 @@ namespace sqlite_orm { static_assert(is_preparable_v, "Expression must be a high-level statement"); decltype(auto) e2 = static_if>( - [](auto expression) -> auto { + [](auto expression) -> auto{ expression.highest_level = true; return expression; }, @@ -17851,7 +18005,7 @@ namespace sqlite_orm { #if SQLITE_VERSION_NUMBER >= 3035000 // DROP COLUMN feature exists (v3.35.0) res = sync_schema_result::old_columns_removed; #else - gottaCreateTable = true; + gottaCreateTable = true; #endif } else { res = sync_schema_result::old_columns_removed; @@ -18170,13 +18324,13 @@ namespace sqlite_orm { std::ref(processObject), std::ref(expression.transformer)); #else - auto& transformer = expression.transformer; - std::for_each(expression.range.first, - expression.range.second, - [&processObject, &transformer](auto& item) { - const object_type& object = polyfill::invoke(transformer, item); - processObject(object); - }); + auto& transformer = expression.transformer; + std::for_each(expression.range.first, + expression.range.second, + [&processObject, &transformer](auto& item) { + const object_type& object = polyfill::invoke(transformer, item); + processObject(object); + }); #endif }, [&processObject](auto& expression) { @@ -18216,13 +18370,13 @@ namespace sqlite_orm { std::ref(processObject), std::ref(expression.transformer)); #else - auto& transformer = expression.transformer; - std::for_each(expression.range.first, - expression.range.second, - [&processObject, &transformer](auto& item) { - const object_type& object = polyfill::invoke(transformer, item); - processObject(object); - }); + auto& transformer = expression.transformer; + std::for_each(expression.range.first, + expression.range.second, + [&processObject, &transformer](auto& item) { + const object_type& object = polyfill::invoke(transformer, item); + processObject(object); + }); #endif }, [&processObject](auto& expression) { @@ -18314,22 +18468,22 @@ namespace sqlite_orm { } return move(res).value(); #else - auto& table = this->get_table(); - auto stepRes = sqlite3_step(stmt); - switch(stepRes) { - case SQLITE_ROW: { - T res; - object_from_column_builder builder{res, stmt}; - table.for_each_column(builder); - return res; - } break; - case SQLITE_DONE: { - throw std::system_error{orm_error_code::not_found}; - } break; - default: { - throw_translated_sqlite_error(stmt); - } + auto& table = this->get_table(); + auto stepRes = sqlite3_step(stmt); + switch(stepRes) { + case SQLITE_ROW: { + T res; + object_from_column_builder builder{res, stmt}; + table.for_each_column(builder); + return res; + } break; + case SQLITE_DONE: { + throw std::system_error{orm_error_code::not_found}; + } break; + default: { + throw_translated_sqlite_error(stmt); } + } #endif } @@ -18440,6 +18594,7 @@ namespace sqlite_orm { #include // std::reference_wrapper // #include "functional/cxx_optional.h" + // #include "tuple_helper/tuple_filter.h" // #include "conditions.h" @@ -18466,6 +18621,7 @@ namespace sqlite_orm { // #include "ast/group_by.h" + namespace sqlite_orm { namespace internal { @@ -18770,6 +18926,7 @@ namespace sqlite_orm { // #include "expression_object_type.h" + namespace sqlite_orm { template @@ -18949,6 +19106,7 @@ namespace sqlite_orm { // #include "pointer_value.h" + namespace sqlite_orm { inline constexpr const char carray_pvt_name[] = "carray"; @@ -19021,6 +19179,7 @@ namespace sqlite_orm { // #include "table.h" + namespace sqlite_orm { #ifdef SQLITE_ENABLE_DBSTAT_VTAB struct dbstat { @@ -19063,6 +19222,7 @@ namespace sqlite_orm { * this file is also used to provide definitions of interface methods 'hitting the database'. */ + #include // std::make_unique // #include "../functional/cxx_core_features.h" @@ -19079,6 +19239,7 @@ namespace sqlite_orm { // #include "../column.h" + namespace sqlite_orm { namespace internal { @@ -19118,6 +19279,7 @@ namespace sqlite_orm { // #include "../table.h" + namespace sqlite_orm { namespace internal { @@ -19145,9 +19307,9 @@ namespace sqlite_orm { #if __cpp_lib_ranges >= 201911L auto it = std::ranges::find(res, columnName, &table_xinfo::name); #else - auto it = std::find_if(res.begin(), res.end(), [&columnName](const table_xinfo& ti) { - return ti.name == columnName; - }); + auto it = std::find_if(res.begin(), res.end(), [&columnName](const table_xinfo& ti) { + return ti.name == columnName; + }); #endif if(it != res.end()) { it->pk = static_cast(i + 1); @@ -19178,6 +19340,7 @@ namespace sqlite_orm { // #include "../storage.h" + namespace sqlite_orm { namespace internal { @@ -19220,9 +19383,9 @@ namespace sqlite_orm { } res = sync_schema_result::old_columns_removed; #else - // extra table columns than storage columns - this->backup_table(db, table, {}); - res = sync_schema_result::old_columns_removed; + // extra table columns than storage columns + this->backup_table(db, table, {}); + res = sync_schema_result::old_columns_removed; #endif } @@ -19286,11 +19449,11 @@ namespace sqlite_orm { #if __cpp_lib_ranges >= 201911L auto columnToIgnoreIt = std::ranges::find(columnsToIgnore, columnName, &table_xinfo::name); #else - auto columnToIgnoreIt = std::find_if(columnsToIgnore.begin(), - columnsToIgnore.end(), - [&columnName](const table_xinfo* tableInfo) { - return columnName == tableInfo->name; - }); + auto columnToIgnoreIt = std::find_if(columnsToIgnore.begin(), + columnsToIgnore.end(), + [&columnName](const table_xinfo* tableInfo) { + return columnName == tableInfo->name; + }); #endif if(columnToIgnoreIt == columnsToIgnore.end()) { columnNames.push_back(cref(columnName));