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.
 
 
 

55 rivejä
1.8 KiB

  1. #pragma once
  2. #include <cpphibernate/driver/mariadb/schema/tables.h>
  3. beg_namespace_cpphibernate_driver_mariadb
  4. {
  5. namespace __impl
  6. {
  7. /* make_tables_impl */
  8. template<typename T, typename>
  9. struct make_tables_impl
  10. {
  11. template<typename... T_args>
  12. static constexpr decltype(auto) apply(T_args&&... args)
  13. { static_assert(sizeof...(args) == -1, "Invalid parameters for mariadb::make_tables(...)!"); }
  14. };
  15. template<typename T_schema>
  16. struct make_tables_impl<
  17. mp::list<T_schema>,
  18. mp::enable_if_c<
  19. schema::is_schema<mp::decay_t<T_schema>>::value>>
  20. {
  21. template<typename T_index>
  22. static constexpr void emplace(tables_t& tables, const T_schema& schema, T_index&& index)
  23. {
  24. decltype(auto) table = make_table(schema, schema.tables[index]);
  25. using table_type = mp::clean_type<decltype(table)>;
  26. auto key = table.dataset_id;
  27. tables.emplace(key, std::make_unique<table_type>(std::move(table)));
  28. }
  29. template<size_t... I>
  30. static decltype(auto) helper(const T_schema& schema, std::index_sequence<I...>)
  31. {
  32. tables_t tables;
  33. int dummy[] = {0, (emplace(tables, schema, hana::size_c<I>), void(), 0)...};
  34. (void) dummy;
  35. return tables;
  36. }
  37. static constexpr decltype(auto) apply(const T_schema& schema)
  38. {
  39. using size = decltype(hana::size(schema.tables));
  40. return helper(schema, std::make_index_sequence<size::value> { });
  41. }
  42. };
  43. }
  44. }
  45. end_namespace_cpphibernate_driver_mariadb