UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
TDirectoryTree< ValueType > Class Template Reference

#include <DirectoryTree.h>

Classes

struct  FIterationSentinel
 
struct  TIterator
 
struct  TPointerIterator
 

Public Types

using FIterator = TIterator< ValueType >
 
using FConstIterator = TIterator< const ValueType >
 
using FPointerIterator = TPointerIterator< ValueType >
 
using FConstPointerIterator = TPointerIterator< const ValueType >
 

Public Member Functions

 TDirectoryTree ()
 
 TDirectoryTree (const TDirectoryTree &Other)=default
 
TDirectoryTreeoperator= (const TDirectoryTree &Other)=default
 
 TDirectoryTree (TDirectoryTree &&Other)=default
 
TDirectoryTreeoperator= (TDirectoryTree &&Other)=default
 
ValueType & FindOrAdd (FStringView Path, bool *bOutExisted=nullptr)
 
void Empty ()
 
void Remove (FStringView Path, bool *bOutExisted=nullptr)
 
void Shrink ()
 
bool IsEmpty () const
 
int32 Num () const
 
SIZE_T GetAllocatedSize () const
 
bool Contains (FStringView Path) const
 
const ValueType * Find (FStringView Path) const
 
ValueType * Find (FStringView Path)
 
bool ContainsPathOrParent (FStringView Path) const
 
const ValueType * FindClosestValue (FStringView Path) const
 
ValueType * FindClosestValue (FStringView Path)
 
bool TryFindClosestPath (FStringView Path, FStringBuilderBase &OutPath, const ValueType **OutValue=nullptr) const
 
bool TryFindClosestPath (FStringView Path, FStringBuilderBase &OutPath, ValueType **OutValue)
 
bool TryFindClosestPath (FStringView Path, FString &OutPath, const ValueType **OutValue=nullptr) const
 
bool TryFindClosestPath (FStringView Path, FString &OutPath, ValueType **OutValue)
 
bool ContainsChildPaths (FStringView Path) const
 
bool TryGetChildren (FStringView Path, TArray< FString > &OutRelativeChildNames, EDirectoryTreeGetFlags Flags=EDirectoryTreeGetFlags::None) const
 
FIterator begin ()
 
FConstIterator begin () const
 
FIterationSentinel end () const
 
FIterator CreateIterator ()
 
FConstIterator CreateConstIterator () const
 
FPointerIterator CreateIteratorForImplied ()
 
FConstPointerIterator CreateConstIteratorForImplied () const
 

Detailed Description

template<typename ValueType>
class TDirectoryTree< ValueType >

Container for path -> value that can efficiently report whether a parent directory of a given path exists. Supports relative and absolute paths. Supports LongPackageNames and LocalPaths.

Note about Value comparisons: Case-insensitive / is treated as equal to \ Presence or absence of terminating separator (/) is ignored in the comparison. Directory elements of . and .. are currently not interpreted and are treated as literal characters. Callers should not rely on this behavior as it may be corrected in the future. callers should instead conform the paths before calling. Relative paths and absolute paths are not resolved, and relative paths will never equal absolute paths. Callers should not rely on this behavior as it may be corrected in the future; callers should instead conform the paths before calling.

For functions that find parent paths, parent paths are only discovered if they are conformed to the same format as the given path: both paths must be either relative or absolute.

For functions that return Values by reference or by pointer, that reference or pointer can be invalidated by any functions that modify the tree, and should be discarded before calling any such functions.

Some functions that report results for directories behave differently for added directories versus implied directories. An added directory is one that was added specifically via FindOrAdd or other mutators. An implied directory is a directory that is not added, but that has a child path that is added to the tree.

Member Typedef Documentation

◆ FConstIterator

template<typename ValueType >
using TDirectoryTree< ValueType >::FConstIterator = TIterator<const ValueType>

◆ FConstPointerIterator

template<typename ValueType >
using TDirectoryTree< ValueType >::FConstPointerIterator = TPointerIterator<const ValueType>

◆ FIterator

template<typename ValueType >
using TDirectoryTree< ValueType >::FIterator = TIterator<ValueType>

◆ FPointerIterator

template<typename ValueType >
using TDirectoryTree< ValueType >::FPointerIterator = TPointerIterator<ValueType>

Constructor & Destructor Documentation

◆ TDirectoryTree() [1/3]

template<typename ValueType >
TDirectoryTree< ValueType >::TDirectoryTree ( )
inline

◆ TDirectoryTree() [2/3]

template<typename ValueType >
TDirectoryTree< ValueType >::TDirectoryTree ( const TDirectoryTree< ValueType > &  Other)
default

◆ TDirectoryTree() [3/3]

template<typename ValueType >
TDirectoryTree< ValueType >::TDirectoryTree ( TDirectoryTree< ValueType > &&  Other)
default

Member Function Documentation

◆ begin() [1/2]

template<typename ValueType >
TDirectoryTree< ValueType >::FIterator TDirectoryTree< ValueType >::begin ( )
inline

Ranged-for accessor for elements in the tree. Same behavior as

See also
CreateIterator.

◆ begin() [2/2]

template<typename ValueType >
TDirectoryTree< ValueType >::FConstIterator TDirectoryTree< ValueType >::begin ( ) const
inline

◆ Contains()

template<typename ValueType >
bool TDirectoryTree< ValueType >::Contains ( FStringView  Path) const
inline

Return whether the given path has been added to the tree.

◆ ContainsChildPaths()

template<typename ValueType >
bool TDirectoryTree< ValueType >::ContainsChildPaths ( FStringView  Path) const
inline

Return whether any children of the given path have been added to the tree.

◆ ContainsPathOrParent()

template<typename ValueType >
bool TDirectoryTree< ValueType >::ContainsPathOrParent ( FStringView  Path) const
inline

Return whether the given path or any of its parent paths exist in the tree.

◆ CreateConstIterator()

template<typename ValueType >
TDirectoryTree< ValueType >::FConstIterator TDirectoryTree< ValueType >::CreateConstIterator ( ) const
inline

◆ CreateConstIteratorForImplied()

template<typename ValueType >
TDirectoryTree< ValueType >::FConstPointerIterator TDirectoryTree< ValueType >::CreateConstIteratorForImplied ( ) const
inline

◆ CreateIterator()

template<typename ValueType >
TDirectoryTree< ValueType >::FIterator TDirectoryTree< ValueType >::CreateIterator ( )
inline

Iterator accessor for path,value pairs that were added to the tree.

See also
FIterator.

◆ CreateIteratorForImplied()

template<typename ValueType >
TDirectoryTree< ValueType >::FPointerIterator TDirectoryTree< ValueType >::CreateIteratorForImplied ( )
inline

Iterator accessor for all paths, added or implied, in the tree. For paths that were added to the tree, the ValueType* on the iterator is non-null and points to the added Value. For implied paths that are parent directories of child paths in the tree the Value pointer of the iterator is the value of their closest parent in the tree, or nullptr if none of their parents were added to the tree.

See also
FPointerIterator.

◆ Empty()

template<typename ValueType >
void TDirectoryTree< ValueType >::Empty ( )
inline

Remove all paths and all memory usage from the tree.

◆ end()

template<typename ValueType >
TDirectoryTree< ValueType >::FIterationSentinel TDirectoryTree< ValueType >::end ( ) const
inline

◆ Find() [1/2]

template<typename ValueType >
ValueType * TDirectoryTree< ValueType >::Find ( FStringView  Path)
inline

Return a pointer to the Value set for the given path, or null if it does not exist.

◆ Find() [2/2]

template<typename ValueType >
const ValueType * TDirectoryTree< ValueType >::Find ( FStringView  Path) const
inline

Return a const pointer to the Value set for the given path, or null if it does not exist.

◆ FindClosestValue() [1/2]

template<typename ValueType >
ValueType * TDirectoryTree< ValueType >::FindClosestValue ( FStringView  Path)
inline

Return a pointer to the path's value if it exists, or to its closest parent path's value, if any of them exist. Otherwise return nullptr.

◆ FindClosestValue() [2/2]

template<typename ValueType >
const ValueType * TDirectoryTree< ValueType >::FindClosestValue ( FStringView  Path) const
inline

Return a const pointer to the path's value if it exists, or to its closest parent path's value, if any of them exist. Otherwise return nullptr.

◆ FindOrAdd()

template<typename ValueType >
ValueType & TDirectoryTree< ValueType >::FindOrAdd ( FStringView  Path,
bool bOutExisted = nullptr 
)

Add a path to the tree if it does not already exist. Construct default Value for it if it did not already exist. Return a reference to the added or existing Value. Optionally report whether the path already existed. This reference can be invalidated by any operations that modify the tree.

◆ GetAllocatedSize()

template<typename ValueType >
SIZE_T TDirectoryTree< ValueType >::GetAllocatedSize ( ) const
inline

How much memory is used by *this, not counting sizeof(*this).

◆ IsEmpty()

template<typename ValueType >
bool TDirectoryTree< ValueType >::IsEmpty ( ) const
inline

Return true if no paths are in the tree.

◆ Num()

template<typename ValueType >
int32 TDirectoryTree< ValueType >::Num ( ) const
inline

Return the number of paths in the tree.

◆ operator=() [1/2]

template<typename ValueType >
TDirectoryTree & TDirectoryTree< ValueType >::operator= ( const TDirectoryTree< ValueType > &  Other)
default

◆ operator=() [2/2]

template<typename ValueType >
TDirectoryTree & TDirectoryTree< ValueType >::operator= ( TDirectoryTree< ValueType > &&  Other)
default

◆ Remove()

template<typename ValueType >
void TDirectoryTree< ValueType >::Remove ( FStringView  Path,
bool bOutExisted = nullptr 
)

Remove a path from the tree and optionally report whether it existed.

◆ Shrink()

template<typename ValueType >
void TDirectoryTree< ValueType >::Shrink ( )
inline

Free unused slack memory throughout the tree by reallocating containers tightly to their current size.

◆ TryFindClosestPath() [1/4]

template<typename ValueType >
bool TDirectoryTree< ValueType >::TryFindClosestPath ( FStringView  Path,
FString &  OutPath,
const ValueType **  OutValue = nullptr 
) const
inline

Return whether the given path or any of its parent paths exist in the tree. If it exists, return the discovered path, and optionally return a const pointer to the value of that path.

◆ TryFindClosestPath() [2/4]

template<typename ValueType >
bool TDirectoryTree< ValueType >::TryFindClosestPath ( FStringView  Path,
FString &  OutPath,
ValueType **  OutValue 
)
inline

Return whether the given path or any of its parent paths exist in the tree. If it exists, return the discovered path, and optionally return a pointer to the value of that path.

◆ TryFindClosestPath() [3/4]

template<typename ValueType >
bool TDirectoryTree< ValueType >::TryFindClosestPath ( FStringView  Path,
FStringBuilderBase OutPath,
const ValueType **  OutValue = nullptr 
) const
inline

Return whether the given path or any of its parent paths exist in the tree. If it exists, return the discovered path, and optionally return a const pointer to the value of that path.

◆ TryFindClosestPath() [4/4]

template<typename ValueType >
bool TDirectoryTree< ValueType >::TryFindClosestPath ( FStringView  Path,
FStringBuilderBase OutPath,
ValueType **  OutValue 
)
inline

Return whether the given path or any of its parent paths exist in the tree. If it exists, return the discovered path, and optionally return a pointer to the value of that path.

◆ TryGetChildren()

template<typename ValueType >
bool TDirectoryTree< ValueType >::TryGetChildren ( FStringView  Path,
TArray< FString > &  OutRelativeChildNames,
EDirectoryTreeGetFlags  Flags = EDirectoryTreeGetFlags::None 
) const
inline

Report the children (optionally recursive or not, optionally implied or not) in the tree of a given Path (optionally skipped if implied).

See also
EDirectoryTreeGetFlags. Relative paths of discovered children will be appended to OutRelativeChildNames.
Returns
true iff (the path is found in the tree and either it is an added path or ImpliedParent was requested).

The documentation for this class was generated from the following file: