implement: add "GetSubTags" to "Tags"
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user