From ffb804d77644ff1a127ecd28959737e527976297 Mon Sep 17 00:00:00 2001 From: bergmann Date: Sat, 29 Jun 2019 11:23:59 +0200 Subject: [PATCH] * Refactored modifier implementation --- include/cpphibernate.h | 1 + include/cpphibernate/modifier.h | 18 ++ include/cpphibernate/modifier/limit.h | 43 ++-- include/cpphibernate/modifier/limit.inl | 50 ++++ include/cpphibernate/modifier/modifier.h | 33 +-- include/cpphibernate/modifier/modifier.inl | 25 ++ include/cpphibernate/modifier/modifiers.h | 69 ++--- include/cpphibernate/modifier/modifiers.inl | 63 +++++ include/cpphibernate/modifier/offset.h | 43 ++-- include/cpphibernate/modifier/offset.inl | 50 ++++ include/cpphibernate/modifier/order_by.h | 173 ++----------- include/cpphibernate/modifier/order_by.inl | 54 ++++ .../modifier/order_by/ascending.h | 38 +++ .../modifier/order_by/ascending.inl | 49 ++++ .../modifier/order_by/descending.h | 38 +++ .../modifier/order_by/descending.inl | 47 ++++ .../modifier/order_by/order_direction.h | 22 ++ .../modifier/order_by/order_direction.inl | 37 +++ include/cpphibernate/modifier/where.h | 38 ++- include/cpphibernate/modifier/where.inl | 59 +++++ include/cpphibernate/modifier/where/clauses.h | 7 - .../cpphibernate/modifier/where/clauses/and.h | 60 ----- .../modifier/where/clauses/clause.h | 31 --- .../modifier/where/clauses/equal.h | 64 ----- .../cpphibernate/modifier/where/clauses/not.h | 60 ----- .../cpphibernate/modifier/where/clauses/or.h | 60 ----- .../cpphibernate/modifier/where/conjunction.h | 59 +++++ .../modifier/where/conjunction.inl | 69 +++++ .../cpphibernate/modifier/where/disjunction.h | 59 +++++ .../modifier/where/disjunction.inl | 69 +++++ include/cpphibernate/modifier/where/equal.h | 38 +++ include/cpphibernate/modifier/where/equal.inl | 64 +++++ .../cpphibernate/modifier/where/negation.h | 59 +++++ .../cpphibernate/modifier/where/negation.inl | 67 +++++ include/cpphibernate/modifier/where/where.h | 60 ----- .../modifier/where/where_clause.h | 22 ++ .../modifier/where/where_clause.inl | 25 ++ include/cpphibernate/schema/attributes.inl | 2 +- include/cpphibernate/schema/fields.inl | 2 +- include/cpphibernate/schema/tables.inl | 2 +- test/cpphibernate/cpphibernate_tests.cpp | 25 +- test/test_schema.h | 236 ------------------ 42 files changed, 1233 insertions(+), 857 deletions(-) create mode 100644 include/cpphibernate/modifier.h create mode 100644 include/cpphibernate/modifier/limit.inl create mode 100644 include/cpphibernate/modifier/modifier.inl create mode 100644 include/cpphibernate/modifier/modifiers.inl create mode 100644 include/cpphibernate/modifier/offset.inl create mode 100644 include/cpphibernate/modifier/order_by.inl create mode 100644 include/cpphibernate/modifier/order_by/ascending.h create mode 100644 include/cpphibernate/modifier/order_by/ascending.inl create mode 100644 include/cpphibernate/modifier/order_by/descending.h create mode 100644 include/cpphibernate/modifier/order_by/descending.inl create mode 100644 include/cpphibernate/modifier/order_by/order_direction.h create mode 100644 include/cpphibernate/modifier/order_by/order_direction.inl create mode 100644 include/cpphibernate/modifier/where.inl delete mode 100644 include/cpphibernate/modifier/where/clauses.h delete mode 100644 include/cpphibernate/modifier/where/clauses/and.h delete mode 100644 include/cpphibernate/modifier/where/clauses/clause.h delete mode 100644 include/cpphibernate/modifier/where/clauses/equal.h delete mode 100644 include/cpphibernate/modifier/where/clauses/not.h delete mode 100644 include/cpphibernate/modifier/where/clauses/or.h create mode 100644 include/cpphibernate/modifier/where/conjunction.h create mode 100644 include/cpphibernate/modifier/where/conjunction.inl create mode 100644 include/cpphibernate/modifier/where/disjunction.h create mode 100644 include/cpphibernate/modifier/where/disjunction.inl create mode 100644 include/cpphibernate/modifier/where/equal.h create mode 100644 include/cpphibernate/modifier/where/equal.inl create mode 100644 include/cpphibernate/modifier/where/negation.h create mode 100644 include/cpphibernate/modifier/where/negation.inl delete mode 100644 include/cpphibernate/modifier/where/where.h create mode 100644 include/cpphibernate/modifier/where/where_clause.h create mode 100644 include/cpphibernate/modifier/where/where_clause.inl delete mode 100644 test/test_schema.h diff --git a/include/cpphibernate.h b/include/cpphibernate.h index dc4dd33..3dbc55a 100644 --- a/include/cpphibernate.h +++ b/include/cpphibernate.h @@ -1,5 +1,6 @@ #pragma once #include "cpphibernate/misc.h" +#include "cpphibernate/modifier.h" #include "cpphibernate/schema.h" #include "cpphibernate/types.h" diff --git a/include/cpphibernate/modifier.h b/include/cpphibernate/modifier.h new file mode 100644 index 0000000..2d487c6 --- /dev/null +++ b/include/cpphibernate/modifier.h @@ -0,0 +1,18 @@ +#pragma once + +#include "modifier/modifier.h" +#include "modifier/modifiers.h" + +#include "modifier/limit.h" +#include "modifier/offset.h" + +#include "modifier/order_by.h" +#include "modifier/order_by/ascending.h" +#include "modifier/order_by/descending.h" + +#include "modifier/where.h" +#include "modifier/where/where_clause.h" +#include "modifier/where/equal.h" +#include "modifier/where/negation.h" +#include "modifier/where/conjunction.h" +#include "modifier/where/disjunction.h" diff --git a/include/cpphibernate/modifier/limit.h b/include/cpphibernate/modifier/limit.h index 39c3256..80f8b21 100644 --- a/include/cpphibernate/modifier/limit.h +++ b/include/cpphibernate/modifier/limit.h @@ -1,39 +1,38 @@ #pragma once -#include #include -#include -beg_namespace_cpphibernate_modifier +namespace cpphibernate { namespace __impl { - /* limit_t */ - - template - struct limit_t - : public modifier_t - { - using value_type = T_value; - - value_type value; - }; + /** + * @brief Helper class to build limit objects. + */ + template + struct limit_builder; } - /* meta */ - + /** + * @brief Evaluates to true_t if the passed type is a limit modifier, false_t otherwise. + */ template - struct is_limit_modifier - : public mp::is_specialization_of - { }; + struct is_limit_modifier; - /* make */ + /** + * @brief Is true if the passed type is a limit modifier, false otherwise. + */ + template + constexpr decltype(auto) is_limit_modifier_v = is_limit_modifier::value; - template - constexpr decltype(auto) limit = __impl::limit_t> { }; + /** + * @brief Predicate to create new limit objects. + */ + constexpr decltype(auto) limit = mp::generic_predicate<__impl::limit_builder> { }; } -end_namespace_cpphibernate_modifier \ No newline at end of file + +#include "limit.inl" diff --git a/include/cpphibernate/modifier/limit.inl b/include/cpphibernate/modifier/limit.inl new file mode 100644 index 0000000..b54be4b --- /dev/null +++ b/include/cpphibernate/modifier/limit.inl @@ -0,0 +1,50 @@ +#pragma once + +#include "limit.h" + +namespace cpphibernate +{ + + namespace __impl + { + + /* limit_t */ + + template + struct limit_t + : public mp::size_t + , public tag_modifier + , public tag_equality_comparable + { }; + + /* limit_builder */ + + template + struct limit_builder + { + template + static constexpr decltype(auto) apply(T_args&&...) + { static_assert(sizeof...(T_args) == -1, "Invalid parameters for limit(...)!"); } + }; + + template + struct limit_builder< + mp::list, + mp::enable_if_t< + mp::is_valid_v + && mp::is_integral_v>>> + { + static constexpr decltype(auto) apply(T&&) + { return limit_t { }; } + }; + + } + + /* is_limit_modifier */ + + template + struct is_limit_modifier + : public mp::is_specialization_of + { }; + +} diff --git a/include/cpphibernate/modifier/modifier.h b/include/cpphibernate/modifier/modifier.h index 5e24e90..7a066f8 100644 --- a/include/cpphibernate/modifier/modifier.h +++ b/include/cpphibernate/modifier/modifier.h @@ -2,30 +2,21 @@ #include -beg_namespace_cpphibernate_modifier +namespace cpphibernate { - namespace __impl - { - - /* modifier_t */ - - struct modifier_t - { }; - - } - - /* meta */ - + /** + * @brief Evaluates to true_t if the passed type is a modifier, false_t otherwise. + */ template - struct is_modifier - : public mp::is_base_of<__impl::modifier_t, T> - { }; + struct is_modifier; - template - struct all_are_modifiers - : public mp::all_true::value...> - { }; + /** + * @brief Is true if the passed type is a modifier, false otherwise. + */ + template + constexpr decltype(auto) is_modifier_v = is_modifier::value; } -end_namespace_cpphibernate_modifier \ No newline at end of file + +#include "modifier.inl" diff --git a/include/cpphibernate/modifier/modifier.inl b/include/cpphibernate/modifier/modifier.inl new file mode 100644 index 0000000..cf3019e --- /dev/null +++ b/include/cpphibernate/modifier/modifier.inl @@ -0,0 +1,25 @@ +#pragma once + +#include "modifier.h" + +namespace cpphibernate +{ + + namespace __impl + { + + /* tag_modifier */ + + struct tag_modifier + { }; + + } + + /* is_modifier */ + + template + struct is_modifier + : public mp::is_base_of<__impl::tag_modifier, T> + { }; + +} diff --git a/include/cpphibernate/modifier/modifiers.h b/include/cpphibernate/modifier/modifiers.h index f1b5782..0a82c4c 100644 --- a/include/cpphibernate/modifier/modifiers.h +++ b/include/cpphibernate/modifier/modifiers.h @@ -1,65 +1,38 @@ #pragma once -#include #include -#include -beg_namespace_cpphibernate_modifier -{ +namespace cpphibernate { +namespace schema { namespace __impl { - /* is_modifiers_impl */ - + /** + * @brief Helper type to build modifiers. + */ template - struct is_modifiers_impl - : mp::c_false_t - { }; - - template - struct is_modifiers_impl, mp::enable_if>> - : mp::c_true_t - { }; + struct modifiers_builder; } - /* meta */ - + /** + * @brief Evaluates to true_t if the passed type is a modifiers type. + */ template - struct is_modifiers - : public __impl::is_modifiers_impl - { }; - - /* operations */ - - namespace __impl - { - - /* make_modifiers_impl */ - - template - struct make_modifiers_impl - { - template - static constexpr decltype(auto) apply(T_args&&...) - { static_assert(sizeof...(T_args) == -1, "Invalid parameters for hibernate::schema::modifier::make(...)!"); } - }; + struct is_modifiers; - template - struct make_modifiers_impl< - mp::list, - mp::enable_if_c< - all_are_modifiers...>::value>> - { - template - static constexpr decltype(auto) apply(T_args&&... args) - { return hana::make_basic_tuple(std::forward(args)...); } - }; + /** + * @brief Is true if the passed type is an modifiers type, false otherwise. + */ + template + constexpr bool is_modifiers_v = is_modifiers::value; - } + /** + * @brief Predicate to create an modifiers object from the passed modifiers. + */ + constexpr decltype(auto) make_modifiers = mp::generic_predicate<__impl::modifiers_builder> { }; - constexpr decltype(auto) make_list = misc::make_generic_predicate<__impl::make_modifiers_impl> { }; +} } -} -end_namespace_cpphibernate_modifier \ No newline at end of file +#include "modifiers.inl" diff --git a/include/cpphibernate/modifier/modifiers.inl b/include/cpphibernate/modifier/modifiers.inl new file mode 100644 index 0000000..8044483 --- /dev/null +++ b/include/cpphibernate/modifier/modifiers.inl @@ -0,0 +1,63 @@ +#pragma once + +#include "modifier.h" +#include "modifiers.h" + +namespace cpphibernate { +namespace schema { + + namespace __impl + { + + /* modifiers_t */ + + template + using modifiers_t = hana::basic_tuple; + + /* modifiers_builder */ + + template + struct modifiers_builder + { + template + static constexpr decltype(auto) apply(T_args&&...) + { static_assert(sizeof...(T_args) == -1, "Invalid parameters for make_modifiers(...)!"); } + }; + + template + struct modifiers_builder< + mp::list, + mp::enable_if_t< + mp::is_true_v>...>>> + { + static constexpr decltype(auto) apply(T_args&&... args) + { + using modifiers_type = modifiers_t; + return modifiers_type(std::forward(args)...); + } + }; + + /* is_modifiers_impl */ + + template + struct is_modifiers_impl + : mp::false_t + { }; + + template + struct is_modifiers_impl< + modifiers_t, + mp::enable_if_t>...>>> + : mp::true_t + { }; + + } + + /* is_modifiers */ + + template + struct is_modifiers + : public __impl::is_modifiers_impl + { }; + +} } diff --git a/include/cpphibernate/modifier/offset.h b/include/cpphibernate/modifier/offset.h index 20bbcec..cbad170 100644 --- a/include/cpphibernate/modifier/offset.h +++ b/include/cpphibernate/modifier/offset.h @@ -1,39 +1,38 @@ #pragma once -#include #include -#include -beg_namespace_cpphibernate_modifier +namespace cpphibernate { namespace __impl { - /* offset_t */ - - template - struct offset_t - : public modifier_t - { - using value_type = T_value; - - value_type value; - }; + /** + * @brief Helper class to build offset objects. + */ + template + struct offset_builder; } - /* meta */ - + /** + * @brief Evaluates to true_t if the passed type is a offset modifier, false_t otherwise. + */ template - struct is_offset - : public mp::is_specialization_of - { }; + struct is_offset_modifier; - /* make */ + /** + * @brief Is true if the passed type is a offset modifier, false otherwise. + */ + template + constexpr decltype(auto) is_offset_modifier_v = is_offset_modifier::value; - template - constexpr decltype(auto) offset = __impl::offset_t> { }; + /** + * @brief Predicate to create new offset objects. + */ + constexpr decltype(auto) offset = mp::generic_predicate<__impl::offset_builder> { }; } -end_namespace_cpphibernate_modifier \ No newline at end of file + +#include "offset.inl" diff --git a/include/cpphibernate/modifier/offset.inl b/include/cpphibernate/modifier/offset.inl new file mode 100644 index 0000000..2e3f7ff --- /dev/null +++ b/include/cpphibernate/modifier/offset.inl @@ -0,0 +1,50 @@ +#pragma once + +#include "offset.h" + +namespace cpphibernate +{ + + namespace __impl + { + + /* offset_t */ + + template + struct offset_t + : public mp::size_t + , public tag_modifier + , public tag_equality_comparable + { }; + + /* offset_builder */ + + template + struct offset_builder + { + template + static constexpr decltype(auto) apply(T_args&&...) + { static_assert(sizeof...(T_args) == -1, "Invalid parameters for offset(...)!"); } + }; + + template + struct offset_builder< + mp::list, + mp::enable_if_t< + mp::is_valid_v + && mp::is_integral_v>>> + { + static constexpr decltype(auto) apply(T&&) + { return offset_t { }; } + }; + + } + + /* is_offset_modifier */ + + template + struct is_offset_modifier + : public mp::is_specialization_of + { }; + +} diff --git a/include/cpphibernate/modifier/order_by.h b/include/cpphibernate/modifier/order_by.h index 515c0b9..c4f580a 100644 --- a/include/cpphibernate/modifier/order_by.h +++ b/include/cpphibernate/modifier/order_by.h @@ -1,171 +1,38 @@ #pragma once -#include #include -#include -beg_namespace_cpphibernate_modifier +namespace cpphibernate { namespace __impl { - /* order_direction_tag_t */ - - struct order_direction_tag_t - { }; - - /* order_direction_t */ - - template - struct order_direction_t - : public order_direction_tag_t - { - using field_type = T_field; - using wrapped_field_type = hana::type>; - - wrapped_field_type wrapped_field; - }; + /** + * @brief Helper class to build order_by objects. + */ + template + struct order_by_builder; } - /* meta */ - + /** + * @brief Evaluates to true_t if the passed type is a offset modifier, false_t otherwise. + */ template - struct is_order_direction - : public mp::is_base_of<__impl::order_direction_tag_t, T> - { }; - - template - struct all_are_order_directions - : public mp::all_true::value...> - { }; - - namespace __impl - { - - /* order_ascending_t */ - - template - struct order_ascending_t - : public order_direction_t - { }; - - /* order_descending_t */ - - template - struct order_descending_t - : public order_direction_t - { }; - - /* order_by_t */ - - template - struct order_by_t - : public modifier_t - { - using fields_type = hana::basic_tuple; - - fields_type fields; - }; - - } - - /* meta */ + struct is_order_by_modifier; + /** + * @brief Is true if the passed type is a offset modifier, false otherwise. + */ template - struct is_order_by - : public mp::is_specialization_of - { }; + constexpr decltype(auto) is_order_by_modifier_v = is_order_by_modifier::value; - template - struct is_ascending - : public mp::is_specialization_of - { }; - - template - struct is_descending - : public mp::is_specialization_of - { }; - - namespace __impl - { - - /* ascending_builder */ - - template - struct ascending_builder - { - template - static constexpr decltype(auto) apply(T_args&&... args) - { static_assert(sizeof...(args) == -1, "Invalid parameters for hibernate::modifier::ascending(...)!"); } - }; - - template - struct ascending_builder< - mp::list, - mp::enable_if>>> - { - static constexpr decltype(auto) apply(T_field&&) - { - using field_type = mp::decay_t; - using ascending_type = order_ascending_t; - return ascending_type { }; - } - }; - - /* descending_builder */ - - template - struct descending_builder - { - template - static constexpr decltype(auto) apply(T_args&&... args) - { static_assert(sizeof...(args) == -1, "Invalid parameters for hibernate::modifier::descending(...)!"); } - }; - - template - struct descending_builder< - mp::list, - mp::enable_if>>> - { - static constexpr decltype(auto) apply(T_field&&) - { - using field_type = mp::decay_t; - using descending_type = order_descending_t; - return descending_type { }; - } - }; - - /* order_by_builder */ - - template - struct order_by_builder - { - template - static constexpr decltype(auto) apply(T_args&&... args) - { static_assert(sizeof...(args) == -1, "Invalid parameters for hibernate::modifier::order_by(...)!"); } - }; - - template - struct order_by_builder< - mp::list, - mp::enable_if...>>> - { - static constexpr decltype(auto) apply(T_order_directions&&...) - { - using order_by_type = order_by_t...>; - return order_by_type { }; - } - }; - - } - - /* make */ - - constexpr decltype(auto) ascending = misc::make_generic_predicate<__impl::ascending_builder> { }; - constexpr decltype(auto) descending = misc::make_generic_predicate<__impl::descending_builder> { }; - constexpr decltype(auto) order_by = misc::make_generic_predicate<__impl::order_by_builder> { }; + /** + * @brief Predicate to create new offset objects. + */ + constexpr decltype(auto) order_by = mp::generic_predicate<__impl::order_by_builder> { }; } -end_namespace_cpphibernate_modifier \ No newline at end of file + +#include "order_by.inl" diff --git a/include/cpphibernate/modifier/order_by.inl b/include/cpphibernate/modifier/order_by.inl new file mode 100644 index 0000000..f1fdd86 --- /dev/null +++ b/include/cpphibernate/modifier/order_by.inl @@ -0,0 +1,54 @@ +#pragma once + +#include "order_by.h" +#include "order_by/order_direction.h" + +namespace cpphibernate +{ + + namespace __impl + { + + /* order_by_t */ + + template + struct order_by_t + : public tag_modifier + { + using order_directions_type = hana::basic_tuple; + + order_directions_type order_directions; + }; + + /* order_by_builder */ + + template + struct order_by_builder + { + template + static constexpr decltype(auto) apply(T_args&&...) + { static_assert(sizeof...(T_args) == -1, "Invalid parameters for order_by(...)!"); } + }; + + template + struct order_by_builder< + mp::list, + mp::enable_if_t>...>>> + { + static constexpr decltype(auto) apply(T_order_directions&&...) + { + using order_by_type = order_by_t...>; + return order_by_type { }; + } + }; + + } + + /* is_order_by_modifier */ + + template + struct is_order_by_modifier + : public mp::is_specialization_of + { }; + +} diff --git a/include/cpphibernate/modifier/order_by/ascending.h b/include/cpphibernate/modifier/order_by/ascending.h new file mode 100644 index 0000000..3fa1f82 --- /dev/null +++ b/include/cpphibernate/modifier/order_by/ascending.h @@ -0,0 +1,38 @@ +#pragma once + +#include + +namespace cpphibernate +{ + + namespace __impl + { + + /** + * @brief Helper class to build ascending objects. + */ + template + struct ascending_builder; + + } + + /** + * @brief Evaluates to true_t if the passed type is a ascending order, false_t otherwise. + */ + template + struct is_ascending; + + /** + * @brief Is true if the passed type is a ascending order, false otherwise. + */ + template + constexpr decltype(auto) is_ascending_v = is_ascending::value; + + /** + * @brief Predicate to create new ascending order objects. + */ + constexpr decltype(auto) ascending = mp::generic_predicate<__impl::ascending_builder> { }; + +} + +#include "ascending.inl" diff --git a/include/cpphibernate/modifier/order_by/ascending.inl b/include/cpphibernate/modifier/order_by/ascending.inl new file mode 100644 index 0000000..434a266 --- /dev/null +++ b/include/cpphibernate/modifier/order_by/ascending.inl @@ -0,0 +1,49 @@ +#pragma once + +#include + +#include "ascending.h" +#include "order_direction.h" + +namespace cpphibernate +{ + + namespace __impl + { + + /* ascending_t */ + + template + struct ascending_t + : public order_direction_t + { }; + + /* ascending_builder */ + + template + struct ascending_builder + { + template + static constexpr decltype(auto) apply(T_args&&... args) + { static_assert(sizeof...(args) == -1, "Invalid parameters for hibernate::ascending(...)!"); } + }; + + template + struct ascending_builder< + mp::list, + mp::enable_if_t>>> + { + static constexpr decltype(auto) apply(T_field&&) + { return ascending_t { }; } + }; + + } + + /* is_ascending */ + + template + struct is_ascending + : public mp::is_specialization_of + { }; + +} diff --git a/include/cpphibernate/modifier/order_by/descending.h b/include/cpphibernate/modifier/order_by/descending.h new file mode 100644 index 0000000..e274edd --- /dev/null +++ b/include/cpphibernate/modifier/order_by/descending.h @@ -0,0 +1,38 @@ +#pragma once + +#include + +namespace cpphibernate +{ + + namespace __impl + { + + /** + * @brief Helper class to build descending objects. + */ + template + struct descending_builder; + + } + + /** + * @brief Evaluates to true_t if the passed type is a descending order, false_t otherwise. + */ + template + struct is_descending; + + /** + * @brief Is true if the passed type is a descending order, false otherwise. + */ + template + constexpr decltype(auto) is_descending_v = is_descending::value; + + /** + * @brief Predicate to create new descending order objects. + */ + constexpr decltype(auto) descending = mp::generic_predicate<__impl::descending_builder> { }; + +} + +#include "descending.inl" diff --git a/include/cpphibernate/modifier/order_by/descending.inl b/include/cpphibernate/modifier/order_by/descending.inl new file mode 100644 index 0000000..78fddf8 --- /dev/null +++ b/include/cpphibernate/modifier/order_by/descending.inl @@ -0,0 +1,47 @@ +#pragma once + +#include "descending.h" +#include "order_direction.h" + +namespace cpphibernate +{ + + namespace __impl + { + + /* descending_t */ + + template + struct descending_t + : public order_direction_t + { }; + + /* descending_builder */ + + template + struct descending_builder + { + template + static constexpr decltype(auto) apply(T_args&&... args) + { static_assert(sizeof...(args) == -1, "Invalid parameters for hibernate::descending(...)!"); } + }; + + template + struct descending_builder< + mp::list, + mp::enable_if_t>>> + { + static constexpr decltype(auto) apply(T_field&&) + { return descending_t { }; } + }; + + } + + /* is_descending */ + + template + struct is_descending + : public mp::is_specialization_of + { }; + +} diff --git a/include/cpphibernate/modifier/order_by/order_direction.h b/include/cpphibernate/modifier/order_by/order_direction.h new file mode 100644 index 0000000..2ce643b --- /dev/null +++ b/include/cpphibernate/modifier/order_by/order_direction.h @@ -0,0 +1,22 @@ +#pragma once + +#include + +namespace cpphibernate +{ + + /** + * @brief Evaluates to true_t if the passed type is a order_direction, false_t otherwise. + */ + template + struct is_order_direction; + + /** + * @brief Is true if the passed type is a order_direction, false otherwise. + */ + template + constexpr decltype(auto) is_order_direction_v = is_order_direction::value; + +} + +#include "order_direction.inl" diff --git a/include/cpphibernate/modifier/order_by/order_direction.inl b/include/cpphibernate/modifier/order_by/order_direction.inl new file mode 100644 index 0000000..58b24e2 --- /dev/null +++ b/include/cpphibernate/modifier/order_by/order_direction.inl @@ -0,0 +1,37 @@ +#pragma once + +#include "order_direction.h" + +namespace cpphibernate +{ + + namespace __impl + { + + /* tag_order_direction */ + + struct tag_order_direction + { }; + + /* order_direction_t */ + + template + struct order_direction_t + : public tag_order_direction + { + using field_type = T_field; + using wrapped_field_type = hana::type>; + + wrapped_field_type wrapped_field; + }; + + } + + /* is_order_direction */ + + template + struct is_order_direction + : public mp::is_base_of<__impl::tag_order_direction, T> + { }; + +} diff --git a/include/cpphibernate/modifier/where.h b/include/cpphibernate/modifier/where.h index e381b88..024f1a2 100644 --- a/include/cpphibernate/modifier/where.h +++ b/include/cpphibernate/modifier/where.h @@ -1,4 +1,38 @@ #pragma once -#include -#include \ No newline at end of file +#include + +namespace cpphibernate +{ + + namespace __impl + { + + /** + * @brief Helper class to build where objects. + */ + template + struct where_builder; + + } + + /** + * @brief Evaluates to true_t if the passed type is a where modifier, false_t otherwise. + */ + template + struct is_where_modifier; + + /** + * @brief Is true if the passed type is a where modifier, false otherwise. + */ + template + constexpr decltype(auto) is_where_modifier_v = is_where_modifier::value; + + /** + * @brief Predicate to create new where objects. + */ + constexpr decltype(auto) where = mp::generic_predicate<__impl::where_builder> { }; + +} + +#include "where.inl" diff --git a/include/cpphibernate/modifier/where.inl b/include/cpphibernate/modifier/where.inl new file mode 100644 index 0000000..ce82757 --- /dev/null +++ b/include/cpphibernate/modifier/where.inl @@ -0,0 +1,59 @@ +#pragma once + +#include "where.h" +#include "where/where_clause.h" + +namespace cpphibernate +{ + + namespace __impl + { + + /* where_t */ + + template + struct where_t + : public tag_modifier + { + using clause_type = T_where_clause; + + clause_type clause; + + constexpr where_t(clause_type&& p_clause) + : clause(p_clause) + { } + }; + + /* where_builder */ + + template + struct where_builder + { + template + static constexpr decltype(auto) apply(T_args&&...) + { static_assert(sizeof...(T_args) == -1, "Invalid parameters for where(...)!"); } + }; + + template + struct where_builder< + mp::list, + mp::enable_if_t>>>> + { + static constexpr decltype(auto) apply(T_where_clause&& clause) + { + using clause_type = T_where_clause; + using where_type = where_t; + return where_type(std::forward(clause)); + } + }; + + } + + /* is_where_modifier */ + + template + struct is_where_modifier + : public mp::is_specialization_of + { }; + +} diff --git a/include/cpphibernate/modifier/where/clauses.h b/include/cpphibernate/modifier/where/clauses.h deleted file mode 100644 index f716bce..0000000 --- a/include/cpphibernate/modifier/where/clauses.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include \ No newline at end of file diff --git a/include/cpphibernate/modifier/where/clauses/and.h b/include/cpphibernate/modifier/where/clauses/and.h deleted file mode 100644 index 942fc3b..0000000 --- a/include/cpphibernate/modifier/where/clauses/and.h +++ /dev/null @@ -1,60 +0,0 @@ -#pragma once - -#include -#include - -beg_namespace_cpphibernate_modifier -{ - - namespace __impl - { - - /* where_clause_and_t */ - - template - struct where_clause_and_t - : public where_clause_t - { - using clauses_type = hana::tuple; - - clauses_type clauses; - - constexpr where_clause_and_t(T_clauses&&... p_clauses) - : clauses(std::forward(p_clauses)...) - { } - }; - - /* where_clause_and_builder */ - - template - struct where_clause_and_builder - { - template - static constexpr decltype(auto) apply(T_args&&... args) - { static_assert(sizeof...(args) == -1, "Invalid parameters for hibernate::modifier::and(...)!"); } - }; - - template - struct where_clause_and_builder< - mp::list, - mp::enable_if...>>> - { - static constexpr decltype(auto) apply(T_clauses&&... clauses) - { return where_clause_and_t(std::forward(clauses)...); } - }; - - } - - /* meta */ - - template - struct is_where_clause_and - : public mp::is_specialization_of - { }; - - /* make */ - - constexpr decltype(auto) and_ = misc::make_generic_predicate<__impl::where_clause_and_builder> { }; - -} -end_namespace_cpphibernate_modifier \ No newline at end of file diff --git a/include/cpphibernate/modifier/where/clauses/clause.h b/include/cpphibernate/modifier/where/clauses/clause.h deleted file mode 100644 index f1ed328..0000000 --- a/include/cpphibernate/modifier/where/clauses/clause.h +++ /dev/null @@ -1,31 +0,0 @@ -#pragma once - -#include - -beg_namespace_cpphibernate_modifier -{ - - namespace __impl - { - - /* where_clause_t */ - - struct where_clause_t - { }; - - } - - /* meta */ - - template - struct is_where_clause - : public mp::is_base_of<__impl::where_clause_t, T> - { }; - - template - struct all_are_where_clauses - : public mp::all_true::value...> - { }; - -} -end_namespace_cpphibernate_modifier \ No newline at end of file diff --git a/include/cpphibernate/modifier/where/clauses/equal.h b/include/cpphibernate/modifier/where/clauses/equal.h deleted file mode 100644 index b994fd8..0000000 --- a/include/cpphibernate/modifier/where/clauses/equal.h +++ /dev/null @@ -1,64 +0,0 @@ -#pragma once - -#include -#include -#include - -beg_namespace_cpphibernate_modifier -{ - - namespace __impl - { - - /* where_clause_equal_t */ - - template - 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(p_field)) - , value(std::forward(p_value)) - { } - }; - - /* where_clause_equal_builder */ - - template - struct where_clause_equal_builder - { - template - static constexpr decltype(auto) apply(T_args&&... args) - { static_assert(sizeof...(args) == -1, "Invalid parameters for hibernate::modifier::equal(...)!"); } - }; - - template - struct where_clause_equal_builder< - mp::list, - mp::enable_if>>> - { - static constexpr decltype(auto) apply(T_field&& field, T_value&& value) - { return where_clause_equal_t(std::forward(field), std::forward(value)); } - }; - - } - - /* meta */ - - template - struct is_where_clause_equal - : public mp::is_specialization_of - { }; - - /* make */ - - constexpr decltype(auto) equal = misc::make_generic_predicate<__impl::where_clause_equal_builder> { }; - -} -end_namespace_cpphibernate_modifier \ No newline at end of file diff --git a/include/cpphibernate/modifier/where/clauses/not.h b/include/cpphibernate/modifier/where/clauses/not.h deleted file mode 100644 index e8cf36e..0000000 --- a/include/cpphibernate/modifier/where/clauses/not.h +++ /dev/null @@ -1,60 +0,0 @@ -#pragma once - -#include -#include - -beg_namespace_cpphibernate_modifier -{ - - namespace __impl - { - - /* where_clause_not_t */ - - template - 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(p_clause)) - { } - }; - - /* where_clause_not_builder */ - - template - struct where_clause_not_builder - { - template - static constexpr decltype(auto) apply(T_args&&... args) - { static_assert(sizeof...(args) == -1, "Invalid parameters for hibernate::modifier::not(...)!"); } - }; - - template - struct where_clause_not_builder< - mp::list, - mp::enable_if>>> - { - static constexpr decltype(auto) apply(T_clause&& clause) - { return where_clause_not_t(std::forward(clause)); } - }; - - } - - /* meta */ - - template - struct is_where_clause_not - : public mp::is_specialization_of - { }; - - /* make */ - - constexpr decltype(auto) not_ = misc::make_generic_predicate<__impl::where_clause_not_builder> { }; - -} -end_namespace_cpphibernate_modifier \ No newline at end of file diff --git a/include/cpphibernate/modifier/where/clauses/or.h b/include/cpphibernate/modifier/where/clauses/or.h deleted file mode 100644 index 79dd497..0000000 --- a/include/cpphibernate/modifier/where/clauses/or.h +++ /dev/null @@ -1,60 +0,0 @@ -#pragma once - -#include -#include - -beg_namespace_cpphibernate_modifier -{ - - namespace __impl - { - - /* where_clause_or_t */ - - template - struct where_clause_or_t - : public where_clause_t - { - using clauses_type = hana::tuple; - - clauses_type clauses; - - constexpr where_clause_or_t(T_clauses&&... p_clauses) - : clauses(std::forward(p_clauses)...) - { } - }; - - /* where_clause_or_builder */ - - template - struct where_clause_or_builder - { - template - static constexpr decltype(auto) apply(T_args&&... args) - { static_assert(sizeof...(args) == -1, "Invalid parameters for hibernate::modifier::or(...)!"); } - }; - - template - struct where_clause_or_builder< - mp::list, - mp::enable_if...>>> - { - static constexpr decltype(auto) apply(T_clauses&&... clauses) - { return where_clause_or_t(std::forward(clauses)...); } - }; - - } - - /* meta */ - - template - struct is_where_clause_or - : public mp::is_specialization_of - { }; - - /* make */ - - constexpr decltype(auto) or_ = misc::make_generic_predicate<__impl::where_clause_or_builder> { }; - -} -end_namespace_cpphibernate_modifier \ No newline at end of file diff --git a/include/cpphibernate/modifier/where/conjunction.h b/include/cpphibernate/modifier/where/conjunction.h new file mode 100644 index 0000000..5f96115 --- /dev/null +++ b/include/cpphibernate/modifier/where/conjunction.h @@ -0,0 +1,59 @@ +#pragma once + +#include + +namespace cpphibernate +{ + + namespace __impl + { + + /** + * @brief Helper class to build conjunction objects. + */ + template + struct conjunction_builder; + + } + + + + /** + * @brief Evaluates to true_t if the passed type is a conjunction clause, false_t otherwise. + */ + template + struct is_conjunction; + + /** + * @brief Is true if the passed type is a conjunction clause, false otherwise. + */ + template + constexpr decltype(auto) is_conjunction_v = is_conjunction::value; + + /** + * @brief Predicate to create new conjunction clause objects. + */ + constexpr decltype(auto) conjunction = mp::generic_predicate<__impl::conjunction_builder> { }; + + + + /** + * @brief Evaluates to true_t if the passed type is a conjunction clause, false_t otherwise. + */ + template + struct is_and; + + /** + * @brief Is true if the passed type is a conjunction clause, false otherwise. + */ + template + constexpr decltype(auto) is_and_v = is_and::value; + + /** + * @brief Predicate to create new conjunction clause objects. + */ + constexpr decltype(auto) and_ = mp::generic_predicate<__impl::conjunction_builder> { }; + +} + +#include "conjunction.inl" diff --git a/include/cpphibernate/modifier/where/conjunction.inl b/include/cpphibernate/modifier/where/conjunction.inl new file mode 100644 index 0000000..f57bc35 --- /dev/null +++ b/include/cpphibernate/modifier/where/conjunction.inl @@ -0,0 +1,69 @@ +#pragma once + +#include + +#include "conjunction.h" + +namespace cpphibernate +{ + + namespace __impl + { + + /* where_clause_conjunction_t */ + + template + struct where_clause_conjunction_t + : public tag_where_clause + { + using clauses_type = hana::basic_tuple; + + clauses_type clauses; + + constexpr where_clause_conjunction_t( + T_clauses&&... p_clauses) + : clauses(std::forward(p_clauses)...) + { } + }; + + /* conjunction_builder */ + + template + struct conjunction_builder + { + template + static constexpr decltype(auto) apply(T_args&&... args) + { static_assert(sizeof...(args) == -1, "Invalid parameters for hibernate::conjunction(...)!"); } + }; + + template + struct conjunction_builder< + mp::list, + mp::enable_if_t< + mp::is_true_v>...> + && sizeof...(T_clauses) >= 2>> + { + static constexpr decltype(auto) apply(T_clauses&&... clauses) + { + using clause_type = where_clause_conjunction_t; + return clause_type(std::forward(clauses)...); + } + }; + + } + + /* is_conjunction */ + + template + struct is_conjunction + : public mp::is_specialization_of + { }; + + /* is_and */ + + template + struct is_and + : public mp::is_specialization_of + { }; + +} diff --git a/include/cpphibernate/modifier/where/disjunction.h b/include/cpphibernate/modifier/where/disjunction.h new file mode 100644 index 0000000..bc3e76e --- /dev/null +++ b/include/cpphibernate/modifier/where/disjunction.h @@ -0,0 +1,59 @@ +#pragma once + +#include + +namespace cpphibernate +{ + + namespace __impl + { + + /** + * @brief Helper class to build disjunction objects. + */ + template + struct disjunction_builder; + + } + + + + /** + * @brief Evaluates to true_t if the passed type is a disjunction clause, false_t otherwise. + */ + template + struct is_disjunction; + + /** + * @brief Is true if the passed type is a disjunction clause, false otherwise. + */ + template + constexpr decltype(auto) is_disjunction_v = is_disjunction::value; + + /** + * @brief Predicate to create new disjunction clause objects. + */ + constexpr decltype(auto) disjunction = mp::generic_predicate<__impl::disjunction_builder> { }; + + + + /** + * @brief Evaluates to true_t if the passed type is a disjunction clause, false_t otherwise. + */ + template + struct is_or; + + /** + * @brief Is true if the passed type is a disjunction clause, false otherwise. + */ + template + constexpr decltype(auto) is_or_v = is_or::value; + + /** + * @brief Predicate to create new disjunction clause objects. + */ + constexpr decltype(auto) or_ = mp::generic_predicate<__impl::disjunction_builder> { }; + +} + +#include "disjunction.inl" diff --git a/include/cpphibernate/modifier/where/disjunction.inl b/include/cpphibernate/modifier/where/disjunction.inl new file mode 100644 index 0000000..0e50791 --- /dev/null +++ b/include/cpphibernate/modifier/where/disjunction.inl @@ -0,0 +1,69 @@ +#pragma once + +#include + +#include "disjunction.h" + +namespace cpphibernate +{ + + namespace __impl + { + + /* where_clause_disjunction_t */ + + template + struct where_clause_disjunction_t + : public tag_where_clause + { + using clauses_type = hana::basic_tuple; + + clauses_type clauses; + + constexpr where_clause_disjunction_t( + T_clauses&&... p_clauses) + : clauses(std::forward(p_clauses)...) + { } + }; + + /* disjunction_builder */ + + template + struct disjunction_builder + { + template + static constexpr decltype(auto) apply(T_args&&... args) + { static_assert(sizeof...(args) == -1, "Invalid parameters for hibernate::disjunction(...)!"); } + }; + + template + struct disjunction_builder< + mp::list, + mp::enable_if_t< + mp::is_true_v>...> + && sizeof...(T_clauses) >= 2>> + { + static constexpr decltype(auto) apply(T_clauses&&... clauses) + { + using clause_type = where_clause_disjunction_t; + return clause_type(std::forward(clauses)...); + } + }; + + } + + /* is_disjunction */ + + template + struct is_disjunction + : public mp::is_specialization_of + { }; + + /* is_or */ + + template + struct is_or + : public mp::is_specialization_of + { }; + +} diff --git a/include/cpphibernate/modifier/where/equal.h b/include/cpphibernate/modifier/where/equal.h new file mode 100644 index 0000000..c35b6db --- /dev/null +++ b/include/cpphibernate/modifier/where/equal.h @@ -0,0 +1,38 @@ +#pragma once + +#include + +namespace cpphibernate +{ + + namespace __impl + { + + /** + * @brief Helper class to build equal objects. + */ + template + struct equal_builder; + + } + + /** + * @brief Evaluates to true_t if the passed type is a equal order, false_t otherwise. + */ + template + struct is_equal; + + /** + * @brief Is true if the passed type is a equal order, false otherwise. + */ + template + constexpr decltype(auto) is_equal_v = is_equal::value; + + /** + * @brief Predicate to create new equal order objects. + */ + constexpr decltype(auto) equal = mp::generic_predicate<__impl::equal_builder> { }; + +} + +#include "equal.inl" diff --git a/include/cpphibernate/modifier/where/equal.inl b/include/cpphibernate/modifier/where/equal.inl new file mode 100644 index 0000000..1a13346 --- /dev/null +++ b/include/cpphibernate/modifier/where/equal.inl @@ -0,0 +1,64 @@ +#pragma once + +#include + +#include "equal.h" + +namespace cpphibernate +{ + + namespace __impl + { + + /* where_clause_equal_t */ + + template + struct where_clause_equal_t + : public tag_where_clause + { + using field_type = T_field; + using value_type = T_value; + + field_type field; + value_type value; + + constexpr where_clause_equal_t( + field_type&& p_field, + value_type&& p_value) + : field(std::forward(p_field)) + , value(std::forward(p_value)) + { } + }; + + /* equal_builder */ + + template + struct equal_builder + { + template + static constexpr decltype(auto) apply(T_args&&... args) + { static_assert(sizeof...(args) == -1, "Invalid parameters for hibernate::equal(...)!"); } + }; + + template + struct equal_builder< + mp::list, + mp::enable_if_t>>> + { + static constexpr decltype(auto) apply(T_field&& field, T_value&& value) + { + using clause_type = where_clause_equal_t; + return clause_type(std::forward(field), std::forward(value)); + } + }; + + } + + /* is_equal */ + + template + struct is_equal + : public mp::is_specialization_of + { }; + +} diff --git a/include/cpphibernate/modifier/where/negation.h b/include/cpphibernate/modifier/where/negation.h new file mode 100644 index 0000000..ad49dd8 --- /dev/null +++ b/include/cpphibernate/modifier/where/negation.h @@ -0,0 +1,59 @@ +#pragma once + +#include + +namespace cpphibernate +{ + + namespace __impl + { + + /** + * @brief Helper class to build negation objects. + */ + template + struct negation_builder; + + } + + + + /** + * @brief Evaluates to true_t if the passed type is a negation clause, false_t otherwise. + */ + template + struct is_negation; + + /** + * @brief Is true if the passed type is a negation clause, false otherwise. + */ + template + constexpr decltype(auto) is_negation_v = is_negation::value; + + /** + * @brief Predicate to create new negation clause objects. + */ + constexpr decltype(auto) negation = mp::generic_predicate<__impl::negation_builder> { }; + + + + /** + * @brief Evaluates to true_t if the passed type is a negation clause, false_t otherwise. + */ + template + struct is_not; + + /** + * @brief Is true if the passed type is a negation clause, false otherwise. + */ + template + constexpr decltype(auto) is_not_v = is_not::value; + + /** + * @brief Predicate to create new negation clause objects. + */ + constexpr decltype(auto) not_ = mp::generic_predicate<__impl::negation_builder> { }; + +} + +#include "negation.inl" diff --git a/include/cpphibernate/modifier/where/negation.inl b/include/cpphibernate/modifier/where/negation.inl new file mode 100644 index 0000000..6ee91a5 --- /dev/null +++ b/include/cpphibernate/modifier/where/negation.inl @@ -0,0 +1,67 @@ +#pragma once + +#include + +#include "negation.h" + +namespace cpphibernate +{ + + namespace __impl + { + + /* where_clause_negation_t */ + + template + struct where_clause_negation_t + : public tag_where_clause + { + using clause_type = T_clause; + + clause_type clause; + + constexpr where_clause_negation_t( + clause_type&& p_clause) + : clause(std::forward(p_clause)) + { } + }; + + /* negation_builder */ + + template + struct negation_builder + { + template + static constexpr decltype(auto) apply(T_args&&... args) + { static_assert(sizeof...(args) == -1, "Invalid parameters for hibernate::negation(...)!"); } + }; + + template + struct negation_builder< + mp::list, + mp::enable_if_t>>> + { + static constexpr decltype(auto) apply(T_clause&& clause) + { + using clause_type = where_clause_negation_t; + return clause_type(std::forward(clause)); + } + }; + + } + + /* is_negation */ + + template + struct is_negation + : public mp::is_specialization_of + { }; + + /* is_not */ + + template + struct is_not + : public mp::is_specialization_of + { }; + +} diff --git a/include/cpphibernate/modifier/where/where.h b/include/cpphibernate/modifier/where/where.h deleted file mode 100644 index 685e24a..0000000 --- a/include/cpphibernate/modifier/where/where.h +++ /dev/null @@ -1,60 +0,0 @@ -#pragma once - -#include -#include -#include -#include - -beg_namespace_cpphibernate_modifier -{ - - namespace __impl - { - - /* where_t */ - - template - struct where_t - : public modifier_t - { - using clause_type = T_clause; - - clause_type clause; - - constexpr where_t(T_clause&& p_clause) - : clause(std::forward(p_clause)) - { } - }; - - /* where_builder */ - - template - struct where_builder - { - template - static constexpr decltype(auto) apply(T_args&&... args) - { static_assert(sizeof...(args) == -1, "Invalid parameters for hibernate::modifier::where(...)!"); } - }; - - template - struct where_builder, mp::enable_if>> - { - static constexpr decltype(auto) apply(T_clause&& clause) - { return where_t(std::forward(clause)); } - }; - - } - - /* meta */ - - template - struct is_where - : public mp::is_specialization_of - { }; - - /* make */ - - constexpr decltype(auto) where = misc::make_generic_predicate<__impl::where_builder> { }; - -} -end_namespace_cpphibernate_modifier \ No newline at end of file diff --git a/include/cpphibernate/modifier/where/where_clause.h b/include/cpphibernate/modifier/where/where_clause.h new file mode 100644 index 0000000..d4d774a --- /dev/null +++ b/include/cpphibernate/modifier/where/where_clause.h @@ -0,0 +1,22 @@ +#pragma once + +#include + +namespace cpphibernate +{ + + /** + * @brief Evaluates to true_t if the passed type is a where_clause, false_t otherwise. + */ + template + struct is_where_clause; + + /** + * @brief Is true if the passed type is a where_clause, false otherwise. + */ + template + constexpr decltype(auto) is_where_clause_v = is_where_clause::value; + +} + +#include "where_clause.inl" diff --git a/include/cpphibernate/modifier/where/where_clause.inl b/include/cpphibernate/modifier/where/where_clause.inl new file mode 100644 index 0000000..446a2e0 --- /dev/null +++ b/include/cpphibernate/modifier/where/where_clause.inl @@ -0,0 +1,25 @@ +#pragma once + +#include "where_clause.h" + +namespace cpphibernate +{ + + namespace __impl + { + + /* tag_where_clause */ + + struct tag_where_clause + { }; + + } + + /* is_where_clause */ + + template + struct is_where_clause + : public mp::is_base_of<__impl::tag_where_clause, T> + { }; + +} diff --git a/include/cpphibernate/schema/attributes.inl b/include/cpphibernate/schema/attributes.inl index a333cb8..8d72793 100644 --- a/include/cpphibernate/schema/attributes.inl +++ b/include/cpphibernate/schema/attributes.inl @@ -11,7 +11,7 @@ namespace schema { /* attributes_t */ template - using attributes_t = hana::basic_tuple; + using attributes_t = hana::tuple; /* attributes_builder */ diff --git a/include/cpphibernate/schema/fields.inl b/include/cpphibernate/schema/fields.inl index 386d231..8ed2800 100644 --- a/include/cpphibernate/schema/fields.inl +++ b/include/cpphibernate/schema/fields.inl @@ -11,7 +11,7 @@ namespace schema { /* fields_t */ template - using fields_t = hana::basic_tuple; + using fields_t = hana::tuple; /* fields_builder */ diff --git a/include/cpphibernate/schema/tables.inl b/include/cpphibernate/schema/tables.inl index 72ec401..22feefd 100644 --- a/include/cpphibernate/schema/tables.inl +++ b/include/cpphibernate/schema/tables.inl @@ -11,7 +11,7 @@ namespace schema { /* tables_t */ template - using tables_t = hana::basic_tuple; + using tables_t = hana::tuple; /* tables_builder */ diff --git a/test/cpphibernate/cpphibernate_tests.cpp b/test/cpphibernate/cpphibernate_tests.cpp index f1c3863..a6c2e50 100644 --- a/test/cpphibernate/cpphibernate_tests.cpp +++ b/test/cpphibernate/cpphibernate_tests.cpp @@ -4,17 +4,26 @@ #include "test_schema.h" -constexpr decltype(auto) x = ::cpphibernate::mp::make_getter( - [](std::string&) { - return int { }; - }); - using namespace ::testing; using namespace ::cpphibernate; using namespace ::cpphibernate::schema; -TEST(cpphibernate, getHelloWorld) +using namespace hana::literals; + +constexpr decltype(auto) tmp_table = test_schema.tables[0_c]; +constexpr decltype(auto) tmp_field = tmp_table.fields[0_c]; +constexpr decltype(auto) mod = make_modifiers( + limit(5_c), + offset(3_c), + order_by( + ascending(tmp_field), + descending(tmp_field)), + where( + or_( + negation(equal(tmp_field, 1)), + negation(equal(tmp_field, 1))))); + +TEST(cpphibernate_tests, dummy) { - (void)x; - // std::cout << test_schema << std::endl; + (void)mod; } diff --git a/test/test_schema.h b/test/test_schema.h deleted file mode 100644 index 0437940..0000000 --- a/test/test_schema.h +++ /dev/null @@ -1,236 +0,0 @@ -#pragma once - -#include -#include - -enum class test_enum -{ - test0, - test1, - test2, - test3, - - first = test0, - last = test3, -}; - -DEFINE_ENUM_TO_STRING_MAP( - test_enum, - { test_enum::test0, "test0" }, - { test_enum::test1, "test1" }, - { test_enum::test2, "test2" }, - { test_enum::test3, "test3" } -); - -DEFINE_STRING_TO_ENUM_MAP( - test_enum, - invariant_string_less, - { "test0", test_enum::test0 }, - { "test1", test_enum::test1 }, - { "test2", test_enum::test2 }, - { "test3", test_enum::test3 } -); - -struct test1 -{ - ::cpphibernate::uuid id; - std::string str_data; - ::cpphibernate::string<64> str64_data; - - utl::nullable u32_nullable; - std::unique_ptr u32_ptr_u; - std::shared_ptr u32_ptr_s; -}; - -struct test2 -{ - ::cpphibernate::uuid id; - uint8_t u8_data; - int8_t i8_data; - uint16_t u16_data; - int16_t i16_data; -}; - -struct test3 -{ - ::cpphibernate::uuid id; - uint32_t u32_data; - int32_t i32_data; - uint64_t u64_data; - int64_t i64_data; -}; - -struct base -{ - ::cpphibernate::uuid id; - std::string name; - - virtual ~base() = default; -}; - -struct derived1 - : public base -{ - ::cpphibernate::uuid derived1_id; - test1 test1_data; - test_enum enum_data; -}; - -struct derived2 - : public base -{ - ::cpphibernate::uuid derived2_id; - utl::nullable test2_nullable; - std::unique_ptr test2_ptr_u; - std::shared_ptr test2_ptr_s; -}; - -struct derived3 - : public derived2 -{ - ::cpphibernate::uuid derived3_id; - std::list test3_list; - std::vector test3_vector; -}; - -struct dummy_id -{ - int data; - - inline dummy_id(int p_data = 0) - : data(p_data) - { } -}; - -struct dummy_owner -{ - ::cpphibernate::uuid id; - std::vector dummies; -}; - -struct double_usage_item -{ - unsigned int id { 0 }; - int data { 0 }; - - double_usage_item(int p_data = 0) - : data(p_data) - { } -}; - -struct double_usage -{ - int id { 0 }; - std::unique_ptr single_item; - std::vector multiple_items; -}; - -struct double_usage_wrapper -{ - int id { 0 }; - std::unique_ptr double_usage; -}; - -constexpr decltype(auto) test_schema = cpphibernate_make_schema( - test, - cpphibernate_make_table_name( - tbl_test1, - test1, - 1, - cpphibernate_make_id (&test1::id), - cpphibernate_make_field (test1, str_data), - cpphibernate_make_field (test1, str64_data), - cpphibernate_make_field (test1, u32_nullable), - cpphibernate_make_field (test1, u32_ptr_u), - cpphibernate_make_field (test1, u32_ptr_s) - ), - cpphibernate_make_table_name( - tbl_test2, - test2, - 2, - cpphibernate_make_id (&test2::id), - cpphibernate_make_field (test2, u8_data), - cpphibernate_make_field (test2, i8_data), - cpphibernate_make_field (test2, u16_data), - cpphibernate_make_field (test2, i16_data) - ), - cpphibernate_make_table_name( - tbl_test3, - test3, - 3, - cpphibernate_make_id (&test3::id), - cpphibernate_make_field (test3, u32_data), - cpphibernate_make_field (test3, i32_data), - cpphibernate_make_field (test3, u64_data), - cpphibernate_make_field (test3, i64_data) - ), - - cpphibernate_make_table_name( - tbl_base, - base, - 10, - cpphibernate_make_id (&base::id), - cpphibernate_make_field (base, name) - ), - cpphibernate_make_table_name( - tbl_derived1, - derived1, - 11, - cpphibernate_make_id (&derived1::derived1_id), - cpphibernate_make_field (derived1, test1_data), - cpphibernate_make_field (derived1, enum_data) - ), - cpphibernate_make_table_name( - tbl_derived2, - derived2, - 12, - cpphibernate_make_id (&derived2::derived2_id), - cpphibernate_make_field (derived2, test2_nullable), - cpphibernate_make_field (derived2, test2_ptr_u), - cpphibernate_make_field (derived2, test2_ptr_s) - ), - cpphibernate_make_table_name( - tbl_derived3, - derived3, - 13, - cpphibernate_make_id (&derived3::derived3_id), - cpphibernate_make_field (derived3, test3_list), - cpphibernate_make_field (derived3, test3_vector) - ), - cpphibernate_make_table_name( - tbl_dummy_id, - dummy_id, - 14, - cpphibernate_make_temp_id (dummy_id, ::cpphibernate::uuid), - cpphibernate_make_field (dummy_id, data) - ), - cpphibernate_make_table_name( - tbl_dummy_owner, - dummy_owner, - 15, - cpphibernate_make_id (&dummy_owner::id), - cpphibernate_make_field (dummy_owner, dummies) - ), - cpphibernate_make_table_name( - tbl_double_usage_item, - double_usage_item, - 16, - cpphibernate_make_id (&double_usage_item::id), - cpphibernate_make_field (double_usage_item, data) - ), - cpphibernate_make_table_name( - tbl_double_usage, - double_usage, - 17, - cpphibernate_make_id (&double_usage::id), - cpphibernate_make_field (double_usage, single_item), - cpphibernate_make_field (double_usage, multiple_items) - ), - cpphibernate_make_table_name( - tbl_double_usage_wrapper, - double_usage_wrapper, - 18, - cpphibernate_make_id (&double_usage_wrapper::id), - cpphibernate_make_field (double_usage_wrapper, double_usage) - ) -); \ No newline at end of file