#include "refl/refl.h" #include #include #include using std::string; using std::vector; using std::string_view; namespace test { struct Guid { UPROPERTY({}) unsigned int Data1; UPROPERTY({}) unsigned short Data2; UPROPERTY({}) unsigned short Data3; UPROPERTY({}) unsigned char Data4[8]; constexpr Guid() noexcept : Data1{ 0 }, Data2{ 0 }, Data3{ 0 }, Data4{ 0,0,0,0,0,0,0,0 } {} USING_OVERLOAD_CTOR(Guid, const string_view&) UFUNCTION({}, ref = USING_CTOR_NAME) Guid(const std::string_view& str) noexcept : Guid{} { sscanf_s(str.data(), "%8x-%4hx-%4hx-%2hhx%2hhx-%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx", &Data1, &Data2, &Data3, &Data4[0], &Data4[1], &Data4[2], &Data4[3], &Data4[4], &Data4[5], &Data4[6], &Data4[7]); } constexpr Guid(unsigned int a, unsigned short b, unsigned short c, unsigned long long d) : Data1{ a } , Data2{ b } , Data3{ c } , Data4{ (unsigned char)(d >> 56 & 0xFF) , (unsigned char)(d >> 48 & 0xFF) , (unsigned char)(d >> 40 & 0xFF) , (unsigned char)(d >> 32 & 0xFF) , (unsigned char)(d >> 24 & 0xFF) , (unsigned char)(d >> 16 & 0xFF) , (unsigned char)(d >> 8 & 0xFF) , (unsigned char)(d >> 0 & 0xFF) } {}; auto operator<=>(const Guid&) const noexcept = default; operator bool() const noexcept { return *reinterpret_cast(this) != GUID_NULL; } USING_OVERLOAD_CLASS_FUNC(void, Guid, int) UFUNCTION({}, ref = USING_FUNC_NAME) void test(int x) { } USING_OVERLOAD_CLASS_FUNC(void, Guid, float) UFUNCTION({}, ref = USING_FUNC_NAME) void test(float x) { } operator std::string() const { char guid_cstr[39]; snprintf(guid_cstr, sizeof(guid_cstr), "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", Data1, Data2, Data3, Data4[0], Data4[1], Data4[2], Data4[3], Data4[4], Data4[5], Data4[6], Data4[7]); return std::string{ guid_cstr }; } static Guid Make() { Guid guid; const auto res = CoCreateGuid((GUID*)&guid); return guid; } }; } #include "guid_gen.inl"