// Copyright (c) 2024 Codemongous LLC. All Rights Reserved.

#include "SCW_UEnum.h"
#include "Engine/UserDefinedEnum.h"
#include "SCW_UField.h"

using namespace Sourcify;

SCW_UEnum::SCW_UEnum(UEnum* InEnum) : SCW_UField(InEnum), Enum(InEnum)
{

}

wstring SCW_UEnum::GetDisplayNameTextByIndex(uint32_t Index) const
{
	return *Enum->GetDisplayNameTextByIndex(Index).ToString();
}

SCW_ECppForm SCW_UEnum::GetCppForm() const
{
	return static_cast<SCW_ECppForm>(Enum->GetCppForm());
}

int32_t SCW_UEnum::GetIndexByNameString(const wstring& SearchString, SCW_EGetByNameFlags Flags/* = SCW_EGetByNameFlags::None*/) const
{
	return Enum->GetIndexByNameString(SearchString.c_str(), static_cast<EGetByNameFlags>(Flags));
}

wstring SCW_UEnum::GetName() const
{
	return *Enum->GetName();
}

wstring SCW_UEnum::GetNameByIndex(uint32_t Index) const
{
	return *Enum->GetNameByIndex(Index).ToString();
}

wstring SCW_UEnum::GetNameStringByValue(int64_t Value) const
{
	return *Enum->GetNameStringByValue(Value);
}
		
int64_t SCW_UEnum::GetValueByIndex(uint32_t Index) const
{
	return Enum->GetValueByIndex(Index);
}

int64_t SCW_UEnum::GetValueByName(const wstring& Name, SCW_EGetByNameFlags Flags/* = SCW_EGetByNameFlags::None*/) const
{
	FName NameFName(Name.c_str());
	return Enum->GetValueByName(NameFName, static_cast<EGetByNameFlags>(Flags));
}

int64_t SCW_UEnum::GetValueByNameString(const wstring& Name, SCW_EGetByNameFlags Flags/* = SCW_EGetByNameFlags::None*/) const
{
	return Enum->GetValueByNameString(Name.c_str(), static_cast<EGetByNameFlags>(Flags));
}

bool SCW_UEnum::HasAnyEnumFlags(SCW_EEnumFlags Flags) const
{
	return Enum->HasAnyEnumFlags(static_cast<EEnumFlags>(Flags));
}

uint32_t SCW_UEnum::NumEnums() const
{
	return Enum->NumEnums();
}

UEnum* SCW_UEnum::ToUEnum() const
{
	return Enum;
}