boat
C++23 geospatial library
Loading...
Searching...
No Matches
reflection.hpp
Go to the documentation of this file.
1// Andrew Naplavkov
2
3#ifndef BOAT_DB_REFLECTION_HPP
4#define BOAT_DB_REFLECTION_HPP
5
7#include <boat/db/meta.hpp>
8#include <boost/pfr/core.hpp>
9#include <boost/pfr/core_name.hpp>
10#include <boost/type_index/ctti_type_index.hpp>
11
12namespace boat::db {
13
14template <class T>
16{
17 auto ret = table{.table_name{
18 boost::typeindex::ctti_type_index::type_id<T>().pretty_name()}};
19 ret.table_name.erase(0, ret.table_name.find_last_of(' ') + 1);
20 [&]<size_t... Is>(std::index_sequence<Is...>) {
21 ret.columns = {column{
23 .column_name{boost::pfr::get_name<Is, T>()}}...};
24 }(std::make_index_sequence<boost::pfr::tuple_size_v<T>>{});
25 for (auto& col : ret.columns)
27 col.epsg = 4326;
28 return ret;
29}
30
31} // namespace boat::db
32
33#endif // BOAT_DB_REFLECTION_HPP
Definition geometry.hpp:9
table to_table()
Definition reflection.hpp:15
Definition meta.hpp:27
Definition variant.hpp:57
Definition meta.hpp:54
std::string table_name
Definition meta.hpp:57