Skip to content

Commit

Permalink
Add GetEnumName to EnumUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-r-elp committed Jul 31, 2024
1 parent b237673 commit aaf9770
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions shared/Utils/EnumUtils.hpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
#pragma once

#include "System/Type.hpp"
#include "System/Enum.hpp"
#include <string>

namespace MultiplayerCore::Utils {
struct EnumUtils {
template <class T>
static StringW GetEnumName(T value)
{
auto enumType = (System::Type*)csTypeOf(T);
return enumType->GetEnumName((System::Object*)il2cpp_functions::value_box(classof(T), &value));
}

template<typename T>
static T GetEnumValue(const std::string& enumName) {
return EnumUtils::GetEnumValue<T>(enumName, false);
Expand Down

0 comments on commit aaf9770

Please sign in to comment.