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

#pragma once

#include "ISCW_UField.h"
#include <memory>
#include <string>

using std::shared_ptr;
using std::wstring;

namespace Sourcify
{
	enum class SCW_EEnumFlags : uint8_t
	{
		None,

		Flags = 0x00000001, // Whether the UEnum represents a set of flags
		NewerVersionExists = 0x00000002, // If set, this UEnum has been replaced by a newer version
	};

	// Mirror of EGetByNameFlags in Class.h
	/** Optional flags for the UEnum::Get*ByName() functions. */
	enum class SCW_EGetByNameFlags
	{
		None = 0,

		/** Outputs an warning if the enum lookup fails */
		ErrorIfNotFound = 0x01,

		/** Does a case sensitive match */
		CaseSensitive = 0x02,

		/** Checks the GetAuthoredNameStringByIndex value as well as normal names */
		CheckAuthoredName = 0x04,
	};

	/** How this enum is declared in C++, affects the internal naming of enum values */
	enum class SCW_ECppForm : uint8_t
	{
		Regular,
		Namespaced,
		EnumClass
	};

	class ISCW_UEnum : public virtual ISCW_UField
	{
	public:
		virtual ~ISCW_UEnum() = default;

		virtual wstring GetDisplayNameTextByIndex(uint32_t Index) const = 0;

		virtual SCW_ECppForm GetCppForm() const = 0;

		virtual int32_t GetIndexByNameString(const wstring& SearchString, SCW_EGetByNameFlags Flags = SCW_EGetByNameFlags::None) const = 0;

		virtual wstring GetNameByIndex(uint32_t Index) const = 0;

		virtual wstring GetNameStringByValue(int64_t Value) const = 0;

		virtual int64_t GetValueByIndex(uint32_t Index) const = 0;

		virtual int64_t GetValueByName(const wstring& Name, SCW_EGetByNameFlags Flags = SCW_EGetByNameFlags::None) const = 0;

		virtual int64_t GetValueByNameString(const wstring& Name, SCW_EGetByNameFlags Flags = SCW_EGetByNameFlags::None) const = 0;

		virtual bool HasAnyEnumFlags(SCW_EEnumFlags Flags) const = 0;

		virtual uint32_t NumEnums() const = 0;
	};

	using ISCW_UEnumConstPtr = shared_ptr<const ISCW_UEnum>;
	using ISCW_UEnumPtr = shared_ptr<ISCW_UEnum>;
} // namespace Sourcify