ChatPlexSDK-BS 1.0.1-v6.2.0
C++ ChatPlex BeatSaber SDK
Loading...
Searching...
No Matches
Il2cpp_enum.hpp
1#define CP_SDK_IL2CPP_ENUM_UTILS() \
2 static constexpr int ValueCount() { return S.size(); }; \
3 \
4 static int ToInt(std::u16string_view p_Str) \
5 { \
6 auto l_It = std::find_if(S.begin(), S.end(), [&](const std::u16string_view& p_A) -> bool { \
7 return p_A.size() == p_Str.size() && std::memcmp(p_A.data(), p_Str.data(), p_A.size() * sizeof(char16_t)) == 0; \
8 }); \
9 auto l_Index = l_It != S.end() ? l_It - S.begin() : -1; \
10 return std::clamp<int>(l_Index, 0, ValueCount() - 1); \
11 } \
12 static int ToInt(E p_Enum) { return std::clamp<int>((int)p_Enum, 0, ValueCount() - 1); } \
13 \
14 static E ToEnum(std::u16string_view p_Str) { return (E)ToInt(p_Str); } \
15 static E ToEnum(int p_Int) { return (E)std::clamp<int>(p_Int, 0, ValueCount() - 1); } \
16 \
17 static std::u16string_view ToStr(int p_Int) { return S[std::clamp<int>(p_Int, 0, ValueCount() - 1)]; } \
18 static std::u16string_view ToStr(E p_Enum) { return S[std::clamp<int>((int)p_Enum, 0, ValueCount() - 1)]; }