| @@ -2,5 +2,6 @@ | |||||
| #include <cpphibernate/config.h> | #include <cpphibernate/config.h> | ||||
| #include <cpphibernate/misc.h> | #include <cpphibernate/misc.h> | ||||
| #include <cpphibernate/modifier.h> | |||||
| #include <cpphibernate/schema.h> | #include <cpphibernate/schema.h> | ||||
| #include <cpphibernate/types.h> | #include <cpphibernate/types.h> | ||||
| @@ -46,6 +46,9 @@ | |||||
| #define beg_namespace_cpphibernate_misc cpphibernate_define_namespace_beg(beg_namespace_cpphibernate, misc) | #define beg_namespace_cpphibernate_misc cpphibernate_define_namespace_beg(beg_namespace_cpphibernate, misc) | ||||
| #define end_namespace_cpphibernate_misc cpphibernate_define_namespace_end(end_namespace_cpphibernate) | #define end_namespace_cpphibernate_misc cpphibernate_define_namespace_end(end_namespace_cpphibernate) | ||||
| #define beg_namespace_cpphibernate_modifier cpphibernate_define_namespace_beg(beg_namespace_cpphibernate, modifier) | |||||
| #define end_namespace_cpphibernate_modifier cpphibernate_define_namespace_end(end_namespace_cpphibernate) | |||||
| beg_namespace_cpphibernate | beg_namespace_cpphibernate | ||||
| { | { | ||||
| @@ -0,0 +1,6 @@ | |||||
| #pragma once | |||||
| #include <cpphibernate/modifier/limit.h> | |||||
| #include <cpphibernate/modifier/modifier.h> | |||||
| #include <cpphibernate/modifier/offset.h> | |||||
| #include <cpphibernate/modifier/where.h> | |||||
| @@ -0,0 +1,64 @@ | |||||
| #pragma once | |||||
| #include <cpphibernate/misc.h> | |||||
| #include <cpphibernate/config.h> | |||||
| #include <cpphibernate/modifier/modifier.h> | |||||
| beg_namespace_cpphibernate_modifier | |||||
| { | |||||
| namespace __impl | |||||
| { | |||||
| /* limit_t */ | |||||
| template<typename T_value> | |||||
| struct limit_t | |||||
| : public modifier_t | |||||
| { | |||||
| using value_type = T_value; | |||||
| value_type value; | |||||
| constexpr limit_t(T_value&& p_value) | |||||
| : value(std::forward<T_value>(p_value)) | |||||
| { } | |||||
| }; | |||||
| /* limit_builder */ | |||||
| template<typename X, typename = void> | |||||
| struct limit_builder | |||||
| { | |||||
| template<typename... T_args> | |||||
| static constexpr decltype(auto) apply(T_args&... args) | |||||
| { static_assert(sizeof...(args) == -1, "Invalid parameters for hibernate::modifier::limit(...)!"); } | |||||
| }; | |||||
| template<typename T_value> | |||||
| struct limit_builder< | |||||
| mp::list<T_value>, | |||||
| mp::enable_if<mp::is_integral<T_value>>> | |||||
| { | |||||
| static constexpr decltype(auto) apply(T_value&& value) | |||||
| { | |||||
| using value_type = mp::integral_constant<T_value, value>; | |||||
| return limit_t<value_type>(value_type { }); | |||||
| } | |||||
| }; | |||||
| } | |||||
| /* meta */ | |||||
| template<typename T> | |||||
| struct is_limit_modifier | |||||
| : public mp::is_specialization_of<T, __impl::limit_t> | |||||
| { }; | |||||
| /* make */ | |||||
| constexpr decltype(auto) limit = misc::make_generic_predicate<__impl::limit_builder> { }; | |||||
| } | |||||
| end_namespace_cpphibernate_modifier | |||||
| @@ -0,0 +1,31 @@ | |||||
| #pragma once | |||||
| #include <cpphibernate/config.h> | |||||
| beg_namespace_cpphibernate_modifier | |||||
| { | |||||
| namespace __impl | |||||
| { | |||||
| /* modifier_t */ | |||||
| struct modifier_t | |||||
| { }; | |||||
| } | |||||
| /* meta */ | |||||
| template<typename T> | |||||
| struct is_modifier | |||||
| : public mp::is_base_of<__impl::modifier_t, T> | |||||
| { }; | |||||
| template<typename... T> | |||||
| struct all_are_modifier | |||||
| : public mp::all_true<is_modifier<T>::value...> | |||||
| { }; | |||||
| } | |||||
| end_namespace_cpphibernate_modifier | |||||
| @@ -0,0 +1,64 @@ | |||||
| #pragma once | |||||
| #include <cpphibernate/misc.h> | |||||
| #include <cpphibernate/config.h> | |||||
| #include <cpphibernate/modifier/modifier.h> | |||||
| beg_namespace_cpphibernate_modifier | |||||
| { | |||||
| namespace __impl | |||||
| { | |||||
| /* offset_t */ | |||||
| template<typename T_value> | |||||
| struct offset_t | |||||
| : public modifier_t | |||||
| { | |||||
| using value_type = T_value; | |||||
| value_type value; | |||||
| constexpr offset_t(T_value&& p_value) | |||||
| : value(std::forward<T_value>(p_value)) | |||||
| { } | |||||
| }; | |||||
| /* offset_builder */ | |||||
| template<typename X, typename = void> | |||||
| struct offset_builder | |||||
| { | |||||
| template<typename... T_args> | |||||
| static constexpr decltype(auto) apply(T_args&... args) | |||||
| { static_assert(sizeof...(args) == -1, "Invalid parameters for hibernate::modifier::offset(...)!"); } | |||||
| }; | |||||
| template<typename T_value> | |||||
| struct offset_builder< | |||||
| mp::list<T_value>, | |||||
| mp::enable_if<mp::is_integral<T_value>>> | |||||
| { | |||||
| static constexpr decltype(auto) apply(T_value&& value) | |||||
| { | |||||
| using value_type = mp::integral_constant<T_value, value>; | |||||
| return offset_t<value_type>(value_type { }); | |||||
| } | |||||
| }; | |||||
| } | |||||
| /* meta */ | |||||
| template<typename T> | |||||
| struct is_offset_modifier | |||||
| : public mp::is_specialization_of<T, __impl::offset_t> | |||||
| { }; | |||||
| /* make */ | |||||
| constexpr decltype(auto) offset = misc::make_generic_predicate<__impl::offset_builder> { }; | |||||
| } | |||||
| end_namespace_cpphibernate_modifier | |||||
| @@ -0,0 +1,4 @@ | |||||
| #pragma once | |||||
| #include <cpphibernate/modifier/where/clauses.h> | |||||
| #include <cpphibernate/modifier/where/where.h> | |||||
| @@ -0,0 +1,6 @@ | |||||
| #pragma once | |||||
| #include <cpphibernate/modifier/where/clauses/and.h> | |||||
| #include <cpphibernate/modifier/where/clauses/clause.h> | |||||
| #include <cpphibernate/modifier/where/clauses/equal.h> | |||||
| #include <cpphibernate/modifier/where/clauses/not.h> | |||||
| @@ -0,0 +1,60 @@ | |||||
| #pragma once | |||||
| #include <cpphibernate/config.h> | |||||
| #include <cpphibernate/modifier/where/clauses/clause.h> | |||||
| beg_namespace_cpphibernate_modifier | |||||
| { | |||||
| namespace __impl | |||||
| { | |||||
| /* where_clause_and_t */ | |||||
| template<typename... T_clauses> | |||||
| struct where_clause_and_t | |||||
| : public where_clause_t | |||||
| { | |||||
| using clauses_type = hana::basic_tuple<T_clauses...>; | |||||
| clauses_type clauses; | |||||
| constexpr where_clause_and_t(T_clauses&&... p_clauses) | |||||
| : clauses(std::forward<T_clauses>(p_clauses)...) | |||||
| { } | |||||
| }; | |||||
| /* where_clause_and_builder */ | |||||
| template<typename X, typename = void> | |||||
| struct where_clause_and_builder | |||||
| { | |||||
| template<typename... T_args> | |||||
| static constexpr decltype(auto) apply(T_args&&... args) | |||||
| { static_assert(sizeof...(args) == -1, "Invalid parameters for hibernate::modifier::and(...)!"); } | |||||
| }; | |||||
| template<typename... T_clauses> | |||||
| struct where_clause_and_builder< | |||||
| mp::list<T_clauses...>, | |||||
| mp::enable_if<all_are_where_clauses<mp::decay_t<T_clauses>...>>> | |||||
| { | |||||
| static constexpr decltype(auto) apply(T_clauses&&... clauses) | |||||
| { return where_clause_and_t<T_clauses...>(std::forward<T_clauses>(clauses)...); } | |||||
| }; | |||||
| } | |||||
| /* meta */ | |||||
| template<typename T> | |||||
| struct is_where_clause_and | |||||
| : public mp::is_specialization_of<T, __impl::where_clause_and_t> | |||||
| { }; | |||||
| /* make */ | |||||
| constexpr decltype(auto) and_ = misc::make_generic_predicate<__impl::where_clause_and_builder> { }; | |||||
| } | |||||
| end_namespace_cpphibernate_modifier | |||||
| @@ -0,0 +1,31 @@ | |||||
| #pragma once | |||||
| #include <cpphibernate/config.h> | |||||
| beg_namespace_cpphibernate_modifier | |||||
| { | |||||
| namespace __impl | |||||
| { | |||||
| /* where_clause_t */ | |||||
| struct where_clause_t | |||||
| { }; | |||||
| } | |||||
| /* meta */ | |||||
| template<typename T> | |||||
| struct is_where_clause | |||||
| : public mp::is_base_of<__impl::where_clause_t, T> | |||||
| { }; | |||||
| template<typename... T> | |||||
| struct all_are_where_clauses | |||||
| : public mp::all_true<is_where_clause<T>::value...> | |||||
| { }; | |||||
| } | |||||
| end_namespace_cpphibernate_modifier | |||||
| @@ -0,0 +1,64 @@ | |||||
| #pragma once | |||||
| #include <cpphibernate/config.h> | |||||
| #include <cpphibernate/schema/field.h> | |||||
| #include <cpphibernate/modifier/where/clauses/clause.h> | |||||
| beg_namespace_cpphibernate_modifier | |||||
| { | |||||
| namespace __impl | |||||
| { | |||||
| /* where_clause_equal_t */ | |||||
| template<typename T_field, typename T_value> | |||||
| struct where_clause_equal_t | |||||
| : public where_clause_t | |||||
| { | |||||
| using field_type = T_field; | |||||
| using value_type = T_value; | |||||
| field_type field; | |||||
| value_type value; | |||||
| constexpr where_clause_equal_t(T_field&& p_field, T_value&& p_value) | |||||
| : field(std::forward<T_field>(p_field)) | |||||
| , value(std::forward<T_value>(p_value)) | |||||
| { } | |||||
| }; | |||||
| /* where_clause_equal_builder */ | |||||
| template<typename X, typename = void> | |||||
| struct where_clause_equal_builder | |||||
| { | |||||
| template<typename... T_args> | |||||
| static constexpr decltype(auto) apply(T_args&&... args) | |||||
| { static_assert(sizeof...(args) == -1, "Invalid parameters for hibernate::modifier::equal(...)!"); } | |||||
| }; | |||||
| template<typename T_field, typename T_value> | |||||
| struct where_clause_equal_builder< | |||||
| mp::list<T_field, T_value>, | |||||
| mp::enable_if<schema::is_field<mp::decay_t<T_field>>>> | |||||
| { | |||||
| static constexpr decltype(auto) apply(T_field&& field, T_value&& value) | |||||
| { return where_clause_equal_t<T_field, T_value>(std::forward<T_field>(field), std::forward<T_value>(value)); } | |||||
| }; | |||||
| } | |||||
| /* meta */ | |||||
| template<typename T> | |||||
| struct is_where_clause_equal | |||||
| : public mp::is_specialization_of<T, __impl::where_clause_equal_t> | |||||
| { }; | |||||
| /* make */ | |||||
| constexpr decltype(auto) equal = misc::make_generic_predicate<__impl::where_clause_equal_builder> { }; | |||||
| } | |||||
| end_namespace_cpphibernate_modifier | |||||
| @@ -0,0 +1,60 @@ | |||||
| #pragma once | |||||
| #include <cpphibernate/config.h> | |||||
| #include <cpphibernate/modifier/where/clauses/clause.h> | |||||
| beg_namespace_cpphibernate_modifier | |||||
| { | |||||
| namespace __impl | |||||
| { | |||||
| /* where_clause_not_t */ | |||||
| template<typename T_clause> | |||||
| struct where_clause_not_t | |||||
| : public where_clause_t | |||||
| { | |||||
| using clause_type = T_clause; | |||||
| clause_type clause; | |||||
| constexpr where_clause_not_t(T_clause&& p_clause) | |||||
| : clause(std::forward<T_clause>(p_clause)) | |||||
| { } | |||||
| }; | |||||
| /* where_clause_not_builder */ | |||||
| template<typename X, typename = void> | |||||
| struct where_clause_not_builder | |||||
| { | |||||
| template<typename... T_args> | |||||
| static constexpr decltype(auto) apply(T_args&&... args) | |||||
| { static_assert(sizeof...(args) == -1, "Invalid parameters for hibernate::modifier::not(...)!"); } | |||||
| }; | |||||
| template<typename T_clause> | |||||
| struct where_clause_not_builder< | |||||
| mp::list<T_clause>, | |||||
| mp::enable_if<is_where_clause<mp::decay_t<T_clause>>>> | |||||
| { | |||||
| static constexpr decltype(auto) apply(T_clause&& clause) | |||||
| { return where_clause_not_t<T_clause>(std::forward<T_clause>(clause)); } | |||||
| }; | |||||
| } | |||||
| /* meta */ | |||||
| template<typename T> | |||||
| struct is_where_clause_not | |||||
| : public mp::is_specialization_of<T, __impl::where_clause_not_t> | |||||
| { }; | |||||
| /* make */ | |||||
| constexpr decltype(auto) not_ = misc::make_generic_predicate<__impl::where_clause_not_builder> { }; | |||||
| } | |||||
| end_namespace_cpphibernate_modifier | |||||
| @@ -0,0 +1,60 @@ | |||||
| #pragma once | |||||
| #include <cpphibernate/config.h> | |||||
| #include <cpphibernate/modifier/where/clauses/clause.h> | |||||
| beg_namespace_cpphibernate_modifier | |||||
| { | |||||
| namespace __impl | |||||
| { | |||||
| /* where_clause_or_t */ | |||||
| template<typename... T_clauses> | |||||
| struct where_clause_or_t | |||||
| : public where_clause_t | |||||
| { | |||||
| using clauses_type = hana::basic_tuple<T_clauses...>; | |||||
| clauses_type clauses; | |||||
| constexpr where_clause_or_t(T_clauses&&... p_clauses) | |||||
| : clauses(std::forward<T_clauses>(p_clauses)...) | |||||
| { } | |||||
| }; | |||||
| /* where_clause_or_builder */ | |||||
| template<typename X, typename = void> | |||||
| struct where_clause_or_builder | |||||
| { | |||||
| template<typename... T_args> | |||||
| static constexpr decltype(auto) apply(T_args&&... args) | |||||
| { static_assert(sizeof...(args) == -1, "Invalid parameters for hibernate::modifier::or(...)!"); } | |||||
| }; | |||||
| template<typename... T_clauses> | |||||
| struct where_clause_or_builder< | |||||
| mp::list<T_clauses...>, | |||||
| mp::enable_if<all_are_where_clauses<mp::decay_t<T_clauses>...>>> | |||||
| { | |||||
| static constexpr decltype(auto) apply(T_clauses&&... clauses) | |||||
| { return where_clause_or_t<T_clauses...>(std::forward<T_clauses>(clauses)...); } | |||||
| }; | |||||
| } | |||||
| /* meta */ | |||||
| template<typename T> | |||||
| struct is_where_clause_or | |||||
| : public mp::is_specialization_of<T, __impl::where_clause_or_t> | |||||
| { }; | |||||
| /* make */ | |||||
| constexpr decltype(auto) or_ = misc::make_generic_predicate<__impl::where_clause_or_builder> { }; | |||||
| } | |||||
| end_namespace_cpphibernate_modifier | |||||
| @@ -0,0 +1,60 @@ | |||||
| #pragma once | |||||
| #include <cpphibernate/misc.h> | |||||
| #include <cpphibernate/config.h> | |||||
| #include <cpphibernate/modifier/modifier.h> | |||||
| #include <cpphibernate/modifier/where/clauses/clause.h> | |||||
| beg_namespace_cpphibernate_modifier | |||||
| { | |||||
| namespace __impl | |||||
| { | |||||
| /* where_t */ | |||||
| template<typename T_clause> | |||||
| struct where_t | |||||
| : public modifier_t | |||||
| { | |||||
| using clause_type = T_clause; | |||||
| clause_type clause; | |||||
| constexpr where_t(T_clause&& p_clause) | |||||
| : clause(std::forward<T_clause>(p_clause)) | |||||
| { } | |||||
| }; | |||||
| /* where_builder */ | |||||
| template<typename X, typename = void> | |||||
| struct where_builder | |||||
| { | |||||
| template<typename... T_args> | |||||
| static constexpr decltype(auto) apply(T_args&... args) | |||||
| { static_assert(sizeof...(args) == -1, "Invalid parameters for hibernate::modifier::where(...)!"); } | |||||
| }; | |||||
| template<typename T_clause> | |||||
| struct where_builder<mp::list<T_clause>, mp::enable_if<is_where_clause<T_clause>>> | |||||
| { | |||||
| static constexpr decltype(auto) apply(T_clause&& clause) | |||||
| { return where_t<T_clause>(std::forward<T_clause>(clause)); } | |||||
| }; | |||||
| } | |||||
| /* meta */ | |||||
| template<typename T> | |||||
| struct is_where_modifier | |||||
| : public mp::is_specialization_of<T, __impl::where_t> | |||||
| { }; | |||||
| /* make */ | |||||
| constexpr decltype(auto) where = misc::make_generic_predicate<__impl::where_builder> { }; | |||||
| } | |||||
| end_namespace_cpphibernate_modifier | |||||
| @@ -4,6 +4,7 @@ | |||||
| #include <cpphibernate/config.h> | #include <cpphibernate/config.h> | ||||
| #include <cpphibernate/schema/getter.h> | #include <cpphibernate/schema/getter.h> | ||||
| #include <cpphibernate/schema/setter.h> | #include <cpphibernate/schema/setter.h> | ||||
| #include <cpphibernate/schema/attributes.h> | |||||
| #include <cpputils/misc/indent.h> | #include <cpputils/misc/indent.h> | ||||
| #include <cpputils/misc/type_helper.h> | #include <cpputils/misc/type_helper.h> | ||||
| @@ -1,5 +1,6 @@ | |||||
| #pragma once | #pragma once | ||||
| #include <iostream> | |||||
| #include <cpphibernate/config.h> | #include <cpphibernate/config.h> | ||||
| namespace std | namespace std | ||||