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

#include "SCW_UStruct.h"

#include "ISCW_FProperty.h"
#include "SourcifyCoreUEWrapperModule.h"
#include "UObject/Class.h"

using namespace Sourcify;

SCW_UStruct::SCW_UStruct(UStruct* InStruct) : SCW_UField(InStruct), Struct(InStruct)
{

}

ISCW_FPropertyPtr SCW_UStruct::FindPropertyByName(const wstring& InName) const
{
	FProperty* Property = Struct->FindPropertyByName(InName.c_str());
	if (Property)
	{
		return FSourcifyCoreUEWrapper::Get().Wrap(*Property);
	}
	return nullptr;
}

const wchar_t* SCW_UStruct::GetPrefixCPP() const
{
	return Struct->GetPrefixCPP();
}

shared_ptr<ISCW_UStruct> SCW_UStruct::GetSuperStruct() const
{
	if (Struct->GetSuperStruct())
	{
		return FSourcifyCoreUEWrapper::Get().Wrap(*Struct->GetSuperStruct())->ToISCW_UStructPtr();
	}
	return nullptr;
}

shared_ptr<ISCW_UStruct> SCW_UStruct::ToISCW_UStructPtr()
{
	return GetSharedThisAs<SCW_UStruct>();
}

shared_ptr<const ISCW_UStruct> SCW_UStruct::ToISCW_UStructPtr() const
{
	return GetSharedThisAs<SCW_UStruct>();
}

UStruct* SCW_UStruct::ToUStructPtr() const
{
	return Struct;
}