22#include "CoreMinimal.h"
23#include "UnrealCtre.h"
27#define MCRO_EXPLICIT_TYPE_EXTRACTION defined(MCRO_EXPLICIT_PRETTY_FUNCTION) && defined(MCRO_EXPLICIT_TYPE_EXTRACT_REGEX)
30#if MCRO_COMPILER_GCC || MCRO_COMPILER_CLANG
31#define PRETTY_FUNC __PRETTY_FUNCTION__
32#elif MCRO_COMPILER_MSVC
33#define PRETTY_FUNC __FUNCSIG__
34#elif MCRO_EXPLICIT_TYPE_EXTRACTION
35#define PRETTY_FUNC MCRO_EXPLICIT_PRETTY_FUNCTION
37#error "TTypeName is only compatible with Clang, GCC and MSVC. Please create a PR for your compiler at https://github.com/microdee/mcro/pulls.
38#error "If your compiler is under NDA add the following definitions in your target rules (values are examples):"
39#error "`MCRO_EXPLICIT_PRETTY_FUNCTION=__PRETTY_FUNCTION__`"
40#error "`MCRO_EXPLICIT_TYPE_EXTRACT_REGEX=\"GetCompileTimeTypeName\\\\<((struct|class)\\\\s)?(?<TYPE>.+?)\\\\>\\\\(\"`"
45#pragma warning(disable: 4804)
60 std::basic_string_view<TCHAR> thisFunctionName { TEXT(PRETTY_FUNC) };
62#if MCRO_COMPILER_GCC || MCRO_COMPILER_CLANG
74 auto result = ctre::search<
TEXT_ R
"(\s\[(?:with\s)?T\s=\s(?<TYPE>.+?)[;\]])">(thisFunctionName);
76#elif MCRO_COMPILER_MSVC
83 auto result = ctre::search<
TEXT_ R
"(GetCompileTimeTypeName<((struct|class)\s)?(?<TYPE>.+?)>\()">(thisFunctionName);
85#elif MCRO_EXPLICIT_TYPE_EXTRACTION
86 auto result = ctre::search<TEXT(MCRO_EXPLICIT_TYPE_EXTRACT_REGEX)>(thisFunctionName);
89 std::basic_string_view<TCHAR> output = result.get<
TEXT_"TYPE">().to_view();
90 size_t size = output.size();
91 size /= output.size() > 0;
93 return size ? output : std::basic_string_view<TCHAR>();
99 std::string_view thisFunctionName { PRETTY_FUNC };
111 template <
typename T>
114 template <
typename T>
132 constexpr operator bool()
const {
return IsValid(); }
139 return static_cast<uint32
>(self.
Hash) ^
static_cast<uint32
>(self.
Hash >> 32);
143 template <
typename T>
194 template <
typename T>
201 template <
typename T>
205 template <
typename T>
212 template <
typename T>
222 template <
typename T>
size_t size(TArray< T, A > const &r)
Use leading TEXT_ without parenthesis for Unreal compatible text literals.
#define TEXT_
A convenience alternative to Unreal's own TEXT macro but this one doesn't require parenthesis around ...
consteval std::basic_string_view< TCHAR > GetCompileTimeTypeName()
Get a string view of the compile time typename.
consteval uint64 GetCompileTimeTypeHash()
Mixed text utilities and type traits.
FName TTypeFName()
Same as TTypeName converted to FName. This is not cached and a new FName is created every time this i...
constexpr FStringView TTypeName
Get a friendly string of an input type without using typeid(T).name().
constexpr uint64 TTypeHash
Get a fixed uint64 hash representation of the given type. Have similar caveats as TTypeName
FString TTypeString()
Same as TTypeName converted to FString. This is not cached and a new FString is created every time th...
constexpr std::basic_string_view< TCHAR > TTypeNameStd
Same as TTypeName just stored as STL string made during compile time.
consteval uint64_t XXH3_64bits_const(const T *input, size_t len) noexcept
Basic interfaces.
Group together type info for identification. Can have an invalid state when no type is specified.
constexpr FType(TTag< T > &&)
FString ToStringCopy() const
friend constexpr bool operator==(FType const &left, FType const &right)
friend constexpr bool operator!=(FType const &left, FType const &right)
constexpr bool IsValid() const
constexpr FStringView ToString() const
friend constexpr uint32 GetTypeHash(FType const &self)