// Copyright Epic Games, Inc. All Rights Reserved.
using System;
using System.Collections.Generic;
using EpicGames.Core;
using EpicGames.UHT.Utils;
namespace EpicGames.UHT.Tables
{
///
/// This attribute is placed on classes that represent Unreal Engine classes.
///
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
public sealed class UhtEngineClassAttribute : Attribute
{
///
/// The name of the engine class excluding any prefix
///
public string? Name { get; set; } = null;
///
/// If true, this class is a property
///
public bool IsProperty { get; set; } = false;
}
///
/// Represents an engine class in the engine class table
///
public struct UhtEngineClass
{
///
/// The name of the engine class excluding any prefix
///
public string Name { get; set; }
///
/// If true, this class is a property
///
public bool IsProperty { get; set; }
}
///
/// Table of all known engine class names.
///
public class UhtEngineClassTable
{
///
/// Internal mapping from engine class name to information
///
private readonly Dictionary _engineClasses = new();
///
/// Test to see if the given class name is a property
///
/// Name of the class without the prefix
/// True if the class name is a property. False if the class name isn't a property or isn't an engine class.
public bool IsValidPropertyTypeName(StringView name)
{
if (_engineClasses.TryGetValue(name, out UhtEngineClass engineClass))
{
return engineClass.IsProperty;
}
return false;
}
///
/// Add an entry to the table
///
/// The located attribute
public void OnEngineClassAttribute(UhtEngineClassAttribute engineClassAttribute)
{
if (String.IsNullOrEmpty(engineClassAttribute.Name))
{
throw new UhtIceException("EngineClassNames must have a name specified");
}
_engineClasses.Add(engineClassAttribute.Name, new UhtEngineClass { Name = engineClassAttribute.Name, IsProperty = engineClassAttribute.IsProperty });
}
}
}