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.

62 lines
2.0 KiB

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