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

#include "SCW_FSetProperty.h"
#include "UObject/UnrealType.h"
#include "SourcifyCoreUEWrapperModule.h"

using namespace Sourcify;

SCW_FSetProperty::SCW_FSetProperty(FSetProperty* InSetProperty) : SCW_FProperty(InSetProperty), SetProperty(InSetProperty)
{

}

wstring SCW_FSetProperty::GetCPPTypeCustom(wstring* ExtendedTypeText, SCW_EPropertyExportCPPFlags CPPExportFlags, const wstring& InnerTypeText, const wstring& InInnerExtendedTypeText) const
{
	if (ExtendedTypeText == nullptr)
	{
		return TCHAR_TO_WCHAR(*SetProperty->GetCPPTypeCustom(nullptr, static_cast<uint32>(CPPExportFlags), InnerTypeText.c_str(), InInnerExtendedTypeText.c_str()));
	}

	FString ExtendedTypeTextFString = ExtendedTypeText->c_str();
	FString CPPTypeCustomFString = SetProperty->GetCPPTypeCustom(&ExtendedTypeTextFString, static_cast<uint32>(CPPExportFlags), InnerTypeText.c_str(), InInnerExtendedTypeText.c_str());
	*ExtendedTypeText = TCHAR_TO_WCHAR(*ExtendedTypeTextFString);

	return TCHAR_TO_WCHAR(*CPPTypeCustomFString);
}
		
ISCW_FPropertyPtr SCW_FSetProperty::GetElementProp() const
{
	return FSourcifyCoreUEWrapper::Get().Wrap(*SetProperty->ElementProp);
}

FSetProperty* SCW_FSetProperty::ToFSetProperty() const
{
	return SetProperty;
}
