6namespace ll::reflection {
9inline std::string_view getDynamicRawName(T
const& value)
noexcept {
10 return typeid(value).name();
14consteval std::string_view getRawName() noexcept {
16 constexpr std::string_view n{__FUNCSIG__};
17 constexpr std::string_view k{
"getRawName<"};
18 constexpr std::string_view l{
">(void) noexcept"};
20 constexpr std::string_view n{__PRETTY_FUNCTION__};
21 constexpr std::string_view k{
"[T = "};
22 constexpr std::string_view l{
"]"};
24 constexpr auto p = n.find(k) + k.size();
26 return n.substr(p, n.size() - p - l.size());
30consteval std::string_view getRawName() noexcept {
32 constexpr std::string_view n{__FUNCSIG__};
33 constexpr std::string_view k{
"getRawName<"};
34 constexpr std::string_view l{
">(void) noexcept"};
36 constexpr std::string_view n{__PRETTY_FUNCTION__};
37 constexpr std::string_view k{
"[T = "};
38 constexpr std::string_view l{
"]"};
40 constexpr auto p = n.find(k) + k.size();
42 return n.substr(p, n.size() - p - l.size());
45constexpr std::string_view removeTypePrefix(std::string_view s)
noexcept {
46 if (s.starts_with(
"enum ")) {
47 s.remove_prefix(
sizeof(
"enum"));
49 if (s.starts_with(
"class ")) {
50 s.remove_prefix(
sizeof(
"class"));
52 if (s.starts_with(
"union ")) {
53 s.remove_prefix(
sizeof(
"union"));
55 if (s.starts_with(
"struct ")) {
56 s.remove_prefix(
sizeof(
"struct"));
61constexpr std::string_view removeTypeSuffix(std::string_view s)
noexcept {
63 if (k != std::string_view::npos) {
64 return s.substr(0, k);
69constexpr std::string_view removeTypeNamespace(std::string_view s)
noexcept {
70 auto k = s.rfind(
"::", s.find(
'<'));
71 if (k != std::string_view::npos) {
72 return s.substr(k + 2);
77constexpr std::string_view typeNameStem(std::string_view s)
noexcept {
78 return removeTypeNamespace(removeTypeSuffix(removeTypePrefix(s)));
83constexpr std::string_view type_raw_name_v = getRawName<T>();
86constexpr std::string_view type_unprefix_name_v = removeTypePrefix(type_raw_name_v<T>);
89constexpr std::string_view type_name_v = removeTypeSuffix(type_unprefix_name_v<T>);
92constexpr std::string_view type_stem_name_v = removeTypeNamespace(type_name_v<T>);
95constexpr bool is_template_v = type_raw_name_v<T>.find(
"<") != std::string_view::npos;
98constexpr bool is_class_v = std::is_class_v<T> && type_raw_name_v<T>.starts_with(
"class ");
101constexpr bool is_struct_v = std::is_class_v<T> && type_raw_name_v<T>.starts_with(
"struct ");