diff --git a/include/cpphibernate.h b/include/cpphibernate.h index e899e4d..08780d6 100644 --- a/include/cpphibernate.h +++ b/include/cpphibernate.h @@ -2,5 +2,6 @@ #include #include +#include #include #include \ No newline at end of file diff --git a/include/cpphibernate/config.h b/include/cpphibernate/config.h index fa4a015..59ec49a 100644 --- a/include/cpphibernate/config.h +++ b/include/cpphibernate/config.h @@ -46,6 +46,9 @@ #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 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 { diff --git a/include/cpphibernate/modifier.h b/include/cpphibernate/modifier.h new file mode 100644 index 0000000..32b12a1 --- /dev/null +++ b/include/cpphibernate/modifier.h @@ -0,0 +1,6 @@ +#pragma once + +#include +#include +#include +#include \ No newline at end of file diff --git a/include/cpphibernate/modifier/limit.h b/include/cpphibernate/modifier/limit.h new file mode 100644 index 0000000..0889090 --- /dev/null +++ b/include/cpphibernate/modifier/limit.h @@ -0,0 +1,64 @@ +#pragma once + +#include +#include +#include + +beg_namespace_cpphibernate_modifier +{ + + namespace __impl + { + + /* limit_t */ + + template + struct limit_t + : public modifier_t + { + using value_type = T_value; + + value_type value; + + constexpr limit_t(T_value&& p_value) + : value(std::forward(p_value)) + { } + }; + + /* limit_builder */ + + template + struct limit_builder + { + template + static constexpr decltype(auto) apply(T_args&... args) + { static_assert(sizeof...(args) == -1, "Invalid parameters for hibernate::modifier::limit(...)!"); } + }; + + template + struct limit_builder< + mp::list, + mp::enable_if>> + { + static constexpr decltype(auto) apply(T_value&& value) + { + using value_type = mp::integral_constant; + return limit_t(value_type { }); + } + }; + + } + + /* meta */ + + template + struct is_limit_modifier + : public mp::is_specialization_of + { }; + + /* make */ + + constexpr decltype(auto) limit = misc::make_generic_predicate<__impl::limit_builder> { }; + +} +end_namespace_cpphibernate_modifier \ No newline at end of file diff --git a/include/cpphibernate/modifier/modifier.h b/include/cpphibernate/modifier/modifier.h new file mode 100644 index 0000000..766b202 --- /dev/null +++ b/include/cpphibernate/modifier/modifier.h @@ -0,0 +1,31 @@ +#pragma once + +#include + +beg_namespace_cpphibernate_modifier +{ + + namespace __impl + { + + /* modifier_t */ + + struct modifier_t + { }; + + } + + /* meta */ + + template + struct is_modifier + : public mp::is_base_of<__impl::modifier_t, T> + { }; + + template + struct all_are_modifier + : public mp::all_true::value...> + { }; + +} +end_namespace_cpphibernate_modifier \ No newline at end of file diff --git a/include/cpphibernate/modifier/offset.h b/include/cpphibernate/modifier/offset.h new file mode 100644 index 0000000..e1e49d1 --- /dev/null +++ b/include/cpphibernate/modifier/offset.h @@ -0,0 +1,64 @@ +#pragma once + +#include +#include +#include + +beg_namespace_cpphibernate_modifier +{ + + namespace __impl + { + + /* offset_t */ + + template + struct offset_t + : public modifier_t + { + using value_type = T_value; + + value_type value; + + constexpr offset_t(T_value&& p_value) + : value(std::forward(p_value)) + { } + }; + + /* offset_builder */ + + template + struct offset_builder + { + template + static constexpr decltype(auto) apply(T_args&... args) + { static_assert(sizeof...(args) == -1, "Invalid parameters for hibernate::modifier::offset(...)!"); } + }; + + template + struct offset_builder< + mp::list, + mp::enable_if>> + { + static constexpr decltype(auto) apply(T_value&& value) + { + using value_type = mp::integral_constant; + return offset_t(value_type { }); + } + }; + + } + + /* meta */ + + template + struct is_offset_modifier + : public mp::is_specialization_of + { }; + + /* make */ + + constexpr decltype(auto) offset = misc::make_generic_predicate<__impl::offset_builder> { }; + +} +end_namespace_cpphibernate_modifier \ No newline at end of file diff --git a/include/cpphibernate/modifier/where.h b/include/cpphibernate/modifier/where.h new file mode 100644 index 0000000..e381b88 --- /dev/null +++ b/include/cpphibernate/modifier/where.h @@ -0,0 +1,4 @@ +#pragma once + +#include +#include \ No newline at end of file diff --git a/include/cpphibernate/modifier/where/clauses.h b/include/cpphibernate/modifier/where/clauses.h new file mode 100644 index 0000000..db63fbb --- /dev/null +++ b/include/cpphibernate/modifier/where/clauses.h @@ -0,0 +1,6 @@ +#pragma once + +#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 new file mode 100644 index 0000000..9daf021 --- /dev/null +++ b/include/cpphibernate/modifier/where/clauses/and.h @@ -0,0 +1,60 @@ +#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::basic_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 new file mode 100644 index 0000000..f1ed328 --- /dev/null +++ b/include/cpphibernate/modifier/where/clauses/clause.h @@ -0,0 +1,31 @@ +#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 new file mode 100644 index 0000000..b994fd8 --- /dev/null +++ b/include/cpphibernate/modifier/where/clauses/equal.h @@ -0,0 +1,64 @@ +#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 new file mode 100644 index 0000000..e8cf36e --- /dev/null +++ b/include/cpphibernate/modifier/where/clauses/not.h @@ -0,0 +1,60 @@ +#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 new file mode 100644 index 0000000..edac57d --- /dev/null +++ b/include/cpphibernate/modifier/where/clauses/or.h @@ -0,0 +1,60 @@ +#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::basic_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/where.h b/include/cpphibernate/modifier/where/where.h new file mode 100644 index 0000000..16c33c6 --- /dev/null +++ b/include/cpphibernate/modifier/where/where.h @@ -0,0 +1,60 @@ +#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_modifier + : 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/schema/field.h b/include/cpphibernate/schema/field.h index 90deaef..976af98 100644 --- a/include/cpphibernate/schema/field.h +++ b/include/cpphibernate/schema/field.h @@ -4,6 +4,7 @@ #include #include #include +#include #include #include diff --git a/include/cpphibernate/schema/print.h b/include/cpphibernate/schema/print.h index 42ba7e1..322ab42 100644 --- a/include/cpphibernate/schema/print.h +++ b/include/cpphibernate/schema/print.h @@ -1,5 +1,6 @@ #pragma once +#include #include namespace std