25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 

75 satır
2.2 KiB

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