You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

64 line
2.0 KiB

  1. #pragma once
  2. #include "attributes.h"
  3. #include <cpphibernate/schema/attribute.h>
  4. #include <cpphibernate/schema/attributes.h>
  5. namespace cpphibernate {
  6. namespace mariadb {
  7. namespace __impl
  8. {
  9. /* attribute_converter */
  10. template<typename T_attribute>
  11. struct attribute_converter;
  12. template<>
  13. struct attribute_converter<schema::attribute::hex_type>
  14. { static constexpr decltype(auto) value = attribute_t::hex; };
  15. template<>
  16. struct attribute_converter<schema::attribute::compress_type>
  17. { static constexpr decltype(auto) value = attribute_t::compress; };
  18. template<>
  19. struct attribute_converter<schema::attribute::primary_key_type>
  20. { static constexpr decltype(auto) value = attribute_t::primary_key; };
  21. /* attributes_builder */
  22. template<typename T, typename>
  23. struct attributes_builder
  24. {
  25. template<typename... T_args>
  26. static constexpr decltype(auto) apply(T_args&&... args)
  27. { static_assert(sizeof...(args) == 0, "Invalid parameters for mariadb::make_attributes(...)!"); }
  28. };
  29. template<typename T_attributes>
  30. struct attributes_builder<
  31. mp::list<T_attributes>,
  32. mp::enable_if_t<schema::is_attributes_v<mp::decay_t<T_attributes>>>>
  33. {
  34. template<size_t... I>
  35. static constexpr decltype(auto) helper(T_attributes&&, const std::index_sequence<I...>&)
  36. {
  37. return attributes_t({
  38. attribute_converter<mp::decay_t<decltype(std::declval<T_attributes>()[hana::size_c<I>])>>::value...
  39. });
  40. }
  41. static constexpr decltype(auto) apply(const T_attributes& attributes)
  42. {
  43. using size = mp::decay_t<decltype(hana::size(attributes))>;
  44. return helper(attributes, std::make_index_sequence<size::value> { });
  45. }
  46. };
  47. }
  48. } }