Open 3D Engine AzCore API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AZ::Dom::DomPrefixTree< T > Class Template Reference

A prefix tree that maps DOM paths to some arbitrary value. More...

#include <DomPrefixTree.h>

Public Types

using VisitorFunction = AZStd::function< bool(const Path &, T &)>
 
using ConstVisitorFunction = AZStd::function< bool(const Path &, const T &)>
 

Public Member Functions

 DomPrefixTree (const DomPrefixTree &)=default
 
 DomPrefixTree (DomPrefixTree &&)=default
 
 DomPrefixTree (AZStd::initializer_list< AZStd::pair< Path, T > > init)
 
template<class Range , class = AZStd::enable_if_t<RangeConvertibleToPrefixTree<Range, T>>>
 DomPrefixTree (Range &&range)
 
DomPrefixTreeoperator= (const DomPrefixTree &)=default
 
DomPrefixTreeoperator= (DomPrefixTree &&)=default
 
void VisitPath (const Path &path, const VisitorFunction &visitor, PrefixTreeTraversalFlags flags=DefaultTraversalFlags)
 Visits a path and calls a visitor for each matching path and value.
 
void VisitPath (const Path &path, const ConstVisitorFunction &visitor, PrefixTreeTraversalFlags flags=DefaultTraversalFlags) const
 
T * ValueAtPath (const Path &path, PrefixTreeMatch match)
 Visits a path and returns the most specific matching value, or null if none was found.
 
const T * ValueAtPath (const Path &path, PrefixTreeMatch match) const
 
template<class Deduced >
ValueAtPathOrDefault (const Path &path, Deduced &&defaultValue, PrefixTreeMatch match) const
 Visits a path and returns the most specific matching value or some default value.
 
T & operator[] (const Path &path)
 Get or create a value at the given exact path.
 
const T & operator[] (const Path &path) const
 
template<class Deduced >
void SetValue (const Path &path, Deduced &&value)
 Sets the value stored at path.
 
void EraseValue (const Path &path, bool removeChildren=false)
 Removes the value stored at path. If removeChildren is true, also removes any values stored at subpaths.
 
DomPrefixTree< T > DetachSubTree (const Path &path)
 
bool OverwritePath (const Path &path, DomPrefixTree &&subtree, bool shouldCreateNodes=true)
 
void Clear ()
 Removes all entries from this tree.
 
bool IsEmpty () const
 Returns true if the root node is empty.
 

Detailed Description

template<class T>
class AZ::Dom::DomPrefixTree< T >

A prefix tree that maps DOM paths to some arbitrary value.

Member Typedef Documentation

◆ VisitorFunction

template<class T >
using AZ::Dom::DomPrefixTree< T >::VisitorFunction = AZStd::function<bool(const Path&, T&)>

VisitorFunctions are callbacks invoked by VisitPath. VisitorFunction is provided with the path to a given value and a reference to the associated value. The callback returns a boolean value indicating whether or not the visit operation should continue running.

Member Function Documentation

◆ DetachSubTree()

template<class T >
DomPrefixTree< T > AZ::Dom::DomPrefixTree< T >::DetachSubTree ( const Path path)

Detaches a sub tree whose root node matches the provided path. The detach operation removes the node and its children from the existing tree.

Parameters
pathThe path which corresponds to the root node of the subtree to be detached.
Returns
The DomPrefixTree that is detached.

◆ operator[]()

template<class T >
const T & AZ::Dom::DomPrefixTree< T >::operator[] ( const Path path) const

Retrieves a value for a given exact path.

Warning
This is an unsafe operation for entries that are not already present in the tree. Prefer ValueAtPath or ValueAtPathOrDefault in those cases.

◆ OverwritePath()

template<class T >
bool AZ::Dom::DomPrefixTree< T >::OverwritePath ( const Path path,
DomPrefixTree< T > &&  subtree,
bool  shouldCreateNodes = true 
)

Overwrites the subtree at the path and replaces it with the given subtree. Old node and its children at the path would be destroyed. The new subtree will be moved to the path.

Parameters
pathThe path which corresponds to the root node to which the subtree would be overwritten.
subtreeThe subtree to move to the provided path.
shouldCreateNodesCreate nodes for the provided path if they are missing. Default to true.
Returns
True if the subtree was overwritten successfully, false if shouldCreateNodes is off and no target path exists.

◆ ValueAtPath()

template<class T >
const T * AZ::Dom::DomPrefixTree< T >::ValueAtPath ( const Path path,
PrefixTreeMatch  match 
) const
See also
ValueAtPath

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