5#include "Containers/Array.h"
83template <
typename ValueType>
87 template <
typename ViewedValueType>
struct TIterator;
95 struct FIteratorInternal;
184 FIterationSentinel
end()
const;
214 template <
typename ViewedValueType>
222 explicit operator bool()
const;
237 template <
typename ViewedValueType>
245 explicit operator bool()
const;
277 FTreeNode() =
default;
278 FTreeNode(FTreeNode&&
Other);
279 FTreeNode& operator=(FTreeNode&&
Other);
280 FTreeNode(
const FTreeNode&
Other);
281 FTreeNode& operator=(
const FTreeNode&
Other);
286 int32 GetNumChildNodes()
const;
318 SIZE_T GetAllocatedSize()
const;
328 bool HasValue()
const;
330 ValueType& GetValue();
332 const ValueType& GetValue()
const;
334 void SetValue(ValueType&&
InValue);
336 void SetDefaultValue();
343 static constexpr uint32 NumFlagBits = 1u;
344 static constexpr uint32 FlagsShift = (8u *
sizeof(
uint32) - NumFlagBits);
357 void RemoveChildNodeAt(
int32 RemoveIndex);
360 static void ConditionalCompactNode(FString& RelPath, FTreeNode&
ChildNode);
365 friend struct FIteratorInternal;
370 uint32 NumChildNodesAndFlags = 0;
371 int32 CapacityChildNodes = 0;
374 struct FIteratorInternal
382 FIteratorInternal(FIteratorInternal&&
Other) =
delete;
383 FIteratorInternal& operator=(FIteratorInternal&&
Other) =
delete;
384 FIteratorInternal(
const FIteratorInternal&
Other) =
delete;
385 FIteratorInternal& operator=(
const FIteratorInternal&
Other) =
delete;
388 bool operator!=(
const FIterationSentinel&)
const;
389 FIteratorInternal& operator++();
391 explicit operator bool()
const;
400 ValueType* ClosestValue;
402 int32 PathLenBeforeChildNode;
403 bool bChildRelPathInitialized;
404 bool bChildNodeInitialized;
408 void TraverseToValid();
409 void IncrementRemainingChildRelPath(FStackData* Data);
427 TCHAR PathSeparator =
'/';
428 bool bPathSeparatorInitialized =
false;
429 bool bNeedDriveWithoutPathFixup =
false;
433template <
typename ValueType>
439template <
typename ValueType>
448 if (!
Root.HasValue())
450 Root.SetDefaultValue();
453 return Root.GetValue();
456 if (!bPathSeparatorInitialized)
461 InitializePathSeparator(
'/');
465 InitializePathSeparator(
'\\');
487template <
typename ValueType>
493 bPathSeparatorInitialized =
false;
496template <
typename ValueType>
526template <
typename ValueType>
532template <
typename ValueType>
535 return Root.IsEmpty();
538template <
typename ValueType>
544template <
typename ValueType>
547 return Root.GetAllocatedSize();
550template <
typename ValueType>
553 return Find(Path) !=
nullptr;
556template <
typename ValueType>
562template <
typename ValueType>
567 return Root.HasValue() ? &
Root.GetValue() :
nullptr;
573 return Root.Find(Path);
576template <
typename ValueType>
579 return FindClosestValue(Path) !=
nullptr;
582template <
typename ValueType>
585 return const_cast<TDirectoryTree*
>(
this)->TryFindClosestPathInternal(Path,
nullptr);
588template <
typename ValueType>
591 return TryFindClosestPathInternal(Path,
nullptr);
594template <
typename ValueType>
609template <
typename ValueType>
614 ValueType* Result = TryFindClosestPathInternal(Path, &Builder);
630template <
typename ValueType>
645template <
typename ValueType>
648 ValueType* Result = TryFindClosestPathInternal(Path, &
OutPath);
663template <
typename ValueType>
685 return Root.HasValue() ? &
Root.GetValue() :
nullptr;
688template <
typename ValueType>
714template <
typename ValueType>
722 bNeedDriveWithoutPathFixup = !bPathSeparatorInitialized;
728template <
typename ValueType>
731 check(!bPathSeparatorInitialized);
737 if (bNeedDriveWithoutPathFixup)
742 bNeedDriveWithoutPathFixup =
false;
746 bPathSeparatorInitialized =
true;
749template<
typename ValueType>
755 return Root.ContainsChildPaths(Path);
758template<
typename ValueType>
773template<
typename ValueType>
779template<
typename ValueType>
784 if (
Other.HasValue())
789 Realloc(
Other.CapacityChildNodes);
791 for (
int32 i = 0; i < NumChildren; ++i)
793 RelPaths[i] =
Other.RelPaths[i];
795 for (
int32 i = 0; i < NumChildren; ++i)
797 ChildNodes[i] =
Other.ChildNodes[i];
800 SetNumChildNodes(
Other.GetNumChildNodes());
804template <
typename ValueType>
810template <
typename ValueType>
813 if (
Other.HasValue())
824 SetNumChildNodes(
Other.GetNumChildNodes());
827 Other.SetNumChildNodes(0);
828 Other.CapacityChildNodes = 0;
832template <
typename ValueType>
838 NumChildNodesAndFlags = 0;
839 CapacityChildNodes = 0;
842template <
typename ValueType>
848template <
typename ValueType>
852 NumChildNodesAndFlags =
857template <
typename ValueType>
860 return (NumChildNodesAndFlags &
FlagsMask) != 0;
863template <
typename ValueType>
866 return *
reinterpret_cast<ValueType*
>(&
Value);
869template<
typename ValueType>
872 return *
reinterpret_cast<const ValueType*
>(&
Value);
875template <
typename ValueType>
881 NumChildNodesAndFlags =
887template <
typename ValueType>
893 NumChildNodesAndFlags =
896 new (&
Value) ValueType();
899template <
typename ValueType>
905 NumChildNodesAndFlags =
911 ((ValueType*)&
Value)->FDirectoryTreeDestructValueType::~FDirectoryTreeDestructValueType();
915template <
typename ValueType>
1032template <
typename ValueType>
1088template <
typename ValueType>
1123template<
typename ValueType>
1129 return GetNumChildNodes() > 0;
1202template <
typename ValueType>
1416template <
typename ValueType>
1483template <
typename ValueType>
1486 return !HasValue() && GetNumChildNodes() == 0;
1489template <
typename ValueType>
1493 Size = CapacityChildNodes * (
sizeof(FTreeNode) +
sizeof(FString));
1497 Size += RelPath.GetAllocatedSize();
1506template <
typename ValueType>
1522template <
typename ValueType>
1528template <
typename ValueType>
1539 if (CapacityChildNodes == 0)
1543 else if (CapacityChildNodes < 8)
1567template <
typename ValueType>
1582template <
typename ValueType>
1604template <
typename ValueType>
1635template <
typename ValueType>
1646template <
typename ValueType>
1651 FStackData& RootData = Stack.Emplace_GetRef(Root,
nullptr );
1655 if (!RootData.Node->HasValue())
1659 RootData.ChildIndex = 0;
1664template <
typename ValueType>
1667 check(!Stack.IsEmpty());
1668 const FStackData&
Data = Stack.Last();
1669 FTreeNode* Node =
Data.Node;
1673template <
typename ValueType>
1679template <
typename ValueType>
1685template <
typename ValueType>
1691 FStackData*
Data = &Stack.Last();
1692 if (
Data->ChildIndex == -1)
1695 Data->ChildIndex = 0;
1705 check(!
Data->RemainingChildRelPath.IsEmpty());
1708 IncrementRemainingChildRelPath(Data);
1715template <
typename ValueType>
1718 while (!Stack.IsEmpty())
1720 FStackData*
Data = &Stack.Last();
1723 if (
Data->ChildIndex == -1)
1727 ||
Data->Node->HasValue())
1737 Data->ChildIndex =
Data->Node->GetNumChildNodes();
1741 Data->ChildIndex = 0;
1744 else if (
Data->ChildIndex <
Data->Node->GetNumChildNodes())
1746 if (!
Data->bChildRelPathInitialized)
1748 Data->bChildRelPathInitialized =
true;
1749 Data->PathLenBeforeChildNode =
Path.Len();
1761 Data->RemainingChildRelPath =
Data->Node->RelPaths[
Data->ChildIndex];
1765 IncrementRemainingChildRelPath(Data);
1768 else if (!
Data->RemainingChildRelPath.IsEmpty())
1774 else if (!
Data->bChildNodeInitialized)
1776 Data->bChildNodeInitialized =
true;
1777 Stack.Add(FStackData(
Data->Node->ChildNodes[
Data->ChildIndex],
Data->ClosestValue));
1785 Data->bChildRelPathInitialized =
false;
1786 Data->bChildNodeInitialized =
false;
1788 Path.RemoveSuffix(
Path.Len() -
Data->PathLenBeforeChildNode);
1789 Data->PathLenBeforeChildNode = 0;
1802template <
typename ValueType>
1815template <
typename ValueType>
1821 , PathLenBeforeChildNode(0)
1822 , bChildRelPathInitialized(
false)
1823 , bChildNodeInitialized(
false)
1827template <
typename ValueType>
1828template <
typename ViewedValueType>
1835template <
typename ValueType>
1836template <
typename ViewedValueType>
1845template <
typename ValueType>
1846template <
typename ViewedValueType>
1853template <
typename ValueType>
1854template <
typename ViewedValueType>
1860template <
typename ValueType>
1861template <
typename ViewedValueType>
1869template <
typename ValueType>
1870template <
typename ViewedValueType>
1876template <
typename ValueType>
1877template <
typename ViewedValueType>
1884template <
typename ValueType>
1885template <
typename ViewedValueType>
1894template <
typename ValueType>
1895template <
typename ViewedValueType>
1902template <
typename ValueType>
1903template <
typename ViewedValueType>
1909template <
typename ValueType>
1910template <
typename ViewedValueType>
1918template <
typename ValueType>
1919template <
typename ViewedValueType>
1925template <
typename ValueType>
1933template <
typename ValueType>
1941template <
typename ValueType>
1949template <
typename ValueType>
1957template <
typename ValueType>
1963template <
typename ValueType>
1969template <
typename ValueType>
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
#define check(expr)
Definition AssertionMacros.h:314
#define checkf(expr, format,...)
Definition AssertionMacros.h:315
@ INDEX_NONE
Definition CoreMiscDefines.h:150
#define CA_ASSUME(Expr)
Definition CoreMiscDefines.h:126
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
EDirectoryTreeGetFlags
Definition DirectoryTree.h:28
constexpr bool EnumHasAnyFlags(Enum Flags, Enum Contains)
Definition EnumClassFlags.h:35
#define ENUM_CLASS_FLAGS(Enum)
Definition EnumClassFlags.h:6
const bool
Definition NetworkReplayStreaming.h:178
TIndexedContainerIterator< TArray< FPreviewAttachedObjectPair >, FPreviewAttachedObjectPair, int32 > TIterator
Definition PreviewAssetAttachComponent.h:68
TStringView< TCHAR > FStringView
Definition StringFwd.h:45
UE_REWRITE T CopyTemp(T &Val)
Definition UnrealTemplate.h:554
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
uint32 Size
Definition VulkanMemory.cpp:4034
static CORE_API bool IsDriveSpecifierWithoutRoot(FStringView InPath)
Definition PathViews.cpp:934
static CORE_API void AppendPath(FStringBuilderBase &InOutPath, FStringView AppendPath)
Definition PathViews.cpp:1093
static CORE_API void SplitFirstComponent(FStringView InPath, FStringView &OutFirstComponent, FStringView &OutRemainder)
Definition PathViews.cpp:866
static CORE_API bool Equals(FStringView A, FStringView B)
Definition PathViews.cpp:365
static CORE_API void SplitVolumeSpecifier(FStringView InPath, FStringView &OutVolumeSpecifier, FStringView &OutRemainder)
Definition PathViews.cpp:974
static void Append(TStringBuilderBase< CharType > &Builder, ArgTypes &&... Args)
Definition PathViews.h:215
static CORE_API bool TryMakeChildPathRelativeTo(FStringView Child, FStringView Parent, FStringView &OutRelPath)
Definition PathViews.cpp:395
Definition ArrayView.h:139
Definition DirectoryTree.h:85
void Remove(FStringView Path, bool *bOutExisted=nullptr)
Definition DirectoryTree.h:497
bool TryFindClosestPath(FStringView Path, FString &OutPath, const ValueType **OutValue=nullptr) const
Definition DirectoryTree.h:595
FConstIterator CreateConstIterator() const
Definition DirectoryTree.h:1934
void Shrink()
Definition DirectoryTree.h:527
FPointerIterator CreateIteratorForImplied()
Definition DirectoryTree.h:1942
bool IsEmpty() const
Definition DirectoryTree.h:533
TDirectoryTree(TDirectoryTree &&Other)=default
const ValueType * FindClosestValue(FStringView Path) const
Definition DirectoryTree.h:583
FConstPointerIterator CreateConstIteratorForImplied() const
Definition DirectoryTree.h:1950
const ValueType * Find(FStringView Path) const
Definition DirectoryTree.h:557
FIterationSentinel end() const
Definition DirectoryTree.h:1970
bool TryGetChildren(FStringView Path, TArray< FString > &OutRelativeChildNames, EDirectoryTreeGetFlags Flags=EDirectoryTreeGetFlags::None) const
Definition DirectoryTree.h:759
int32 Num() const
Definition DirectoryTree.h:539
bool Contains(FStringView Path) const
Definition DirectoryTree.h:551
TIterator< const ValueType > FConstIterator
Definition DirectoryTree.h:89
TDirectoryTree & operator=(TDirectoryTree &&Other)=default
bool ContainsChildPaths(FStringView Path) const
Definition DirectoryTree.h:750
TDirectoryTree()
Definition DirectoryTree.h:434
ValueType * FindClosestValue(FStringView Path)
Definition DirectoryTree.h:589
ValueType * Find(FStringView Path)
Definition DirectoryTree.h:563
TDirectoryTree & operator=(const TDirectoryTree &Other)=default
FConstIterator begin() const
Definition DirectoryTree.h:1964
ValueType & FindOrAdd(FStringView Path, bool *bOutExisted=nullptr)
Definition DirectoryTree.h:440
SIZE_T GetAllocatedSize() const
Definition DirectoryTree.h:545
FIterator CreateIterator()
Definition DirectoryTree.h:1926
bool TryFindClosestPath(FStringView Path, FString &OutPath, ValueType **OutValue)
Definition DirectoryTree.h:610
bool TryFindClosestPath(FStringView Path, FStringBuilderBase &OutPath, ValueType **OutValue)
Definition DirectoryTree.h:646
void Empty()
Definition DirectoryTree.h:488
FIterator begin()
Definition DirectoryTree.h:1958
bool ContainsPathOrParent(FStringView Path) const
Definition DirectoryTree.h:577
bool TryFindClosestPath(FStringView Path, FStringBuilderBase &OutPath, const ValueType **OutValue=nullptr) const
Definition DirectoryTree.h:631
TPointerIterator< const FMountPoint * > FConstPointerIterator
Definition DirectoryTree.h:92
TIterator< ValueType > FIterator
Definition DirectoryTree.h:88
TPointerIterator< FMountPoint * > FPointerIterator
Definition DirectoryTree.h:91
TDirectoryTree(const TDirectoryTree &Other)=default
void Reset()
Definition StringBuilder.h:190
Definition StringBuilder.h:509
Definition UniquePtr.h:107
CORE_API void Reset(int32 NewReservedSize=0)
Definition String.cpp.inl:326
UE_FORCEINLINE_HINT int32 Len() const
Definition UnrealString.h.inl:954
IAnalyticsPropertyStore::EStatusCode SetValue(TGetter &&GetterFn, TSetter &&SetterFn, const T &ProposedValue, TCompare &&ConditionFn)
Definition AnalyticsPropertyStore.cpp:34
GeometryCollection::Facades::FMuscleActivationData Data
Definition MuscleActivationConstraints.h:15
@ IgnoreCase
Definition CString.h:26
T::FDataType GetValue(const UBlackboardComponent &Blackboard, const FName &Name, FBlackboard::FKey &InOutCachedKey, const typename T::FDataType &DefaultValue)
Definition ValueOrBBKey.h:51
const FColor Path(255, 255, 255)
FORCEINLINE T * Get(const FObjectPtr &ObjectPtr)
Definition ObjectPtr.h:426
Definition DirectoryTree.cpp:10
void FixupPathSeparator(FStringBuilderBase &InOutPath, int32 StartIndex, TCHAR InPathSeparator)
Definition DirectoryTree.cpp:12
int32 FindInsertionIndex(int32 NumChildNodes, const TUniquePtr< FString[]> &RelPaths, FStringView FirstPathComponent, bool &bOutExists)
Definition DirectoryTree.cpp:26
UE_STRING_CLASS Result(Forward< LhsType >(Lhs), RhsLen)
Definition String.cpp.inl:732
@ false
Definition radaudio_common.h:23
U16 Index
Definition radfft.cpp:71
Definition ArrowWrapper.h:28
Definition DirectoryTree.h:206
Definition DirectoryTree.h:216
bool operator!=(const FIterationSentinel &) const
Definition DirectoryTree.h:1855
TIterator & operator++()
Definition DirectoryTree.h:1863
TPair< FStringView, ViewedValueType & > operator*() const
Definition DirectoryTree.h:1837
TArrowWrapper< TPair< FStringView, ViewedValueType & > > operator->() const
Definition DirectoryTree.h:1848
Definition DirectoryTree.h:239
TPointerIterator & operator++()
Definition DirectoryTree.h:1912
TPair< FStringView, ViewedValueType * > operator*() const
Definition DirectoryTree.h:1887
TArrowWrapper< TPair< FStringView, ViewedValueType * > > operator->() const
Definition DirectoryTree.h:1897
bool operator!=(const FIterationSentinel &) const
Definition DirectoryTree.h:1904
Definition TypeCompatibleBytes.h:24