13 template<
class T,
class char_t>
14 constexpr
typename type_strings<T, char_t>::string_view_type type_strings<T, char_t>::create_full_signature()
18 #elif QX_CLANG || QX_GNU
20 std::is_same_v<char_t, char>,
21 "Can't use __PRETTY_FUNCTION__ with wchar_t as it is not a macro but a function");
23 return __PRETTY_FUNCTION__;
27 template<
class T,
class char_t>
28 constexpr
typename type_strings<T, char_t>::string_view_type type_strings<T, char_t>::create_signature()
30 constexpr string_view_type svFunctionSignature = create_full_signature();
33 constexpr string_view_type svStartMarker =
QX_STR_PREFIX(char_t,
"type_strings<");
34 constexpr string_view_type svEndMarker =
QX_STR_PREFIX(char_t,
">::create_full_signature(");
36 constexpr string_view_type svStartMarker =
QX_STR_PREFIX(char_t,
"T = ");
37 constexpr string_view_type svEndMarker =
QX_STR_PREFIX(char_t,
", char_t = ");
39 constexpr string_view_type svStartMarker =
QX_STR_PREFIX(char_t,
"T = ");
40 constexpr string_view_type svEndMarker =
QX_STR_PREFIX(char_t,
";");
43 size_t nStartMarker = svFunctionSignature.find(svStartMarker);
44 size_t nStart = nStartMarker != string_view_type::npos ? (nStartMarker + svStartMarker.size()) : 0;
46 constexpr string_view_type classMarker =
QX_STR_PREFIX(char_t,
"class ");
47 size_t nClassMarker = svFunctionSignature.find(classMarker, nStart);
48 if (nClassMarker != string_view_type::npos)
49 nStart = nClassMarker + classMarker.size();
51 size_t nEndMarker = svFunctionSignature.find(svEndMarker, nStart);
52 size_t nEnd = nEndMarker != string_view_type::npos ? nEndMarker : svFunctionSignature.size();
55 size_t nCharCommaMarker = svFunctionSignature.rfind(
QX_CHAR_PREFIX(char_t,
','), nEnd);
56 if (nCharCommaMarker != string_view_type::npos)
57 nEnd = nCharCommaMarker;
60 return string_view_type(svFunctionSignature.data() + nStart, nEnd - nStart);
63 template<
class T,
class char_t>
64 constexpr
size_t type_strings<T, char_t>::get_num_template_parameters()
66 const string_view_type svSignature = create_signature();
68 size_t nBraceCounter = 0;
72 for (
size_t i = 0; i < svSignature.size(); ++i)
74 switch (svSignature[i])
81 if (svSignature.find(lambdaMarker, i + 1) == i + 1)
83 else if (nParams == 0 && nBraceCounter == 1)
97 if (nBraceCounter == 1)
107 template<
class T,
class char_t>
110 return create_signature();
113 template<
class T,
class char_t>
116 constexpr string_view_type svStartMarker =
QX_STR_PREFIX(char_t,
"<");
117 const string_view_type svSignature = create_signature();
118 size_t nStartMarker = svSignature.find(svStartMarker);
120 if (nStartMarker != string_view_type::npos && svSignature.find(lambdaMarker, nStartMarker) == nStartMarker + 1)
121 nStartMarker = string_view_type::npos;
123 return string_view_type(
125 nStartMarker != string_view_type::npos ? nStartMarker : svSignature.size());
128 template<
class T,
class char_t>
131 std::array<string_view_type, get_num_template_parameters()> tokens;
133 const string_view_type svSignature = create_signature();
135 size_t nTokenStart = 0;
136 size_t nBraceCounter = 0;
139 const auto add_token = [&tokens, &svSignature](
size_t nToken,
size_t nStart,
size_t nEnd)
147 constexpr string_view_type classMarker =
QX_STR_PREFIX(char_t,
"class ");
148 if (string_view_type(svSignature.data() + nStart, nEnd - nStart).starts_with(classMarker))
149 nStart += classMarker.size();
151 tokens[nToken] = string_view_type(svSignature.data() + nStart, nEnd + 1 - nStart);
154 bool bLambda =
false;
156 for (
size_t i = 0; i < svSignature.size(); ++i)
158 switch (svSignature[i])
163 if (nTokenStart == 0)
165 else if (!bLambda && svSignature.find(lambdaMarker, i + 1) == i + 1)
178 if (nBraceCounter == 1)
180 add_token(nParam, nTokenStart, i - 1);
188 if (tokens.size() > 0)
190 size_t nTokenEnd = svSignature.size() - 1;
198 add_token(nParam, nTokenStart, nTokenEnd);
static constexpr auto get_template_parameters()
Get type template parameters.
static constexpr string_view_type get_name()
Get type name (short name without template parameters)
static constexpr string_view_type get_signature()
Get type signature (full name with template parameters)
#define QX_CHAR_PREFIX(value_t, ch)
Chose witch of prefixes add to char : L or none.
#define QX_STR_PREFIX(value_t, str)
Chose witch of prefixes add to string : L or none.