Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
qicosmos committed Jul 24, 2023
1 parent aa59cc3 commit cea3c6c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 21 deletions.
41 changes: 21 additions & 20 deletions include/iguana/reflection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -551,26 +551,27 @@ namespace iguana::detail {
#define MAKE_STR_LIST(...) \
MACRO_CONCAT(CON_STR, GET_ARG_COUNT(__VA_ARGS__))(__VA_ARGS__)

#define MAKE_META_DATA_IMPL(STRUCT_NAME, ...) \
inline auto iguana_reflect_members(STRUCT_NAME const &) { \
struct reflect_members { \
constexpr decltype(auto) static apply_impl() { \
return std::make_tuple(__VA_ARGS__); \
} \
using size_type = \
std::integral_constant<size_t, GET_ARG_COUNT(__VA_ARGS__)>; \
constexpr static std::string_view name() { \
return std::string_view(#STRUCT_NAME, sizeof(#STRUCT_NAME) - 1); \
} \
constexpr static std::string_view fields() { \
return fields_##STRUCT_NAME; \
} \
constexpr static size_t value() { return size_type::value; } \
constexpr static std::array<frozen::string, size_type::value> arr() { \
return arr_##STRUCT_NAME; \
} \
}; \
return reflect_members{}; \
#define MAKE_META_DATA_IMPL(STRUCT_NAME, ...) \
inline auto iguana_reflect_members(STRUCT_NAME const &) { \
struct reflect_members { \
constexpr decltype(auto) static apply_impl() { \
return std::make_tuple(__VA_ARGS__); \
} \
using size_type = \
std::integral_constant<size_t, GET_ARG_COUNT(__VA_ARGS__)>; \
constexpr static std::string_view name() { return name_##STRUCT_NAME; } \
constexpr static std::string_view struct_name() { \
return std::string_view(#STRUCT_NAME, sizeof(#STRUCT_NAME) - 1); \
} \
constexpr static std::string_view fields() { \
return fields_##STRUCT_NAME; \
} \
constexpr static size_t value() { return size_type::value; } \
constexpr static std::array<frozen::string, size_type::value> arr() { \
return arr_##STRUCT_NAME; \
} \
}; \
return reflect_members{}; \
}

#define MAKE_META_DATA(STRUCT_NAME, TABLE_NAME, N, ...) \
Expand Down
2 changes: 1 addition & 1 deletion include/utility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ template <typename U>
constexpr std::string_view get_field_name(std::string_view full_name) {
using T = decltype(iguana_reflect_members(
std::declval<typename field_attribute<U>::type>()));
return full_name.substr(T::name().length() + 2, full_name.length());
return full_name.substr(T::struct_name().length() + 2, full_name.length());
}

#define FID(field) \
Expand Down

0 comments on commit cea3c6c

Please sign in to comment.