implement: add "GetSubTags" to "Tags"

This commit is contained in:
Ruan Lucas
2023-04-22 13:38:54 -04:00
parent 73ff053470
commit 107bea9c2e
2 changed files with 25 additions and 0 deletions

View File

@@ -55,6 +55,24 @@ Tag Tags::Get(const StringView& tagName)
return tag;
}
Array<Tag> Tags::GetSubTags(Tag parentTag)
{
Array<Tag> subTags = Array<Tag>();
auto _parentTagName = parentTag.ToString();
for (int i = 0; i < Tags::List.Count(); i++)
{
auto& subTagName = Tags::List[i];
if (subTagName.Contains(_parentTagName) && subTagName != _parentTagName)
{
subTags.Add(Tags::Get(subTagName));
}
}
return subTags;
}
bool Tags::HasTag(const Array<Tag>& list, const Tag& tag)
{
if (tag.Index == 0)

View File

@@ -92,6 +92,13 @@ API_CLASS(Static) class FLAXENGINE_API Tags
/// <returns>The tag.</returns>
API_FUNCTION() static Tag Get(const StringView& tagName);
/// <summary>
/// Get all subtags of the specific Tag
/// </summary>
/// <param name="tag"></param>
/// <returns></returns>
API_FUNCTION() static Array<Tag> GetSubTags(Tag tag);
public:
/// <summary>
/// Checks if the list of tags contains a given tag (including parent tags check). For example, HasTag({"A.B"}, "A") returns true, for exact check use HasTagExact.