54template<
typename TStringTree>
57 #if ALIB_DEBUG_CRITICAL_SECTIONS
60 #define DCS ALIB_DCS_WITH( tree->DbgGetDCS())
61 #define DCSSHRD ALIB_DCS_SHARED_WITH(tree->DbgGetDCS())
73 static constexpr bool IsConst = std::is_const_v<TStringTree>;
79 typename StringTreeType::Cursor,
80 typename StringTreeType::ConstCursor>;
89 typename StringTreeType::CursorHandle,
90 typename StringTreeType::ConstCursorHandle>;
107 virtual bool Compare(
const StringTreeType::ConstCursor& lhs,
108 const StringTreeType::ConstCursor& rhs) =0;
125 bool Compare(
const StringTreeType::ConstCursor& lhs,
126 const StringTreeType::ConstCursor& rhs)
override {
129 ? lhs.Name().template CompareTo<CHK,lang::Case::Sensitive>(rhs.Name())
130 : lhs.Name().template CompareTo<CHK,lang::Case::Ignore >(rhs.Name());
216 unsigned maxDepth =(std::numeric_limits<
unsigned int>::max)();
268 ALIB_ASSERT_ERROR( startNode.IsValid(),
"STRINGTREE",
"Invalid start-node given." )
269 this->
tree= &startNode.template Tree<TStringTree>();
275 node= startNode.Export();
278 RecursionData& rd=
stack.emplace_back();
279 node= startNode.Export();
281 rd.sortedChildren.emplace_back(
node);
287 if( startNode.HasChildren() )
356 const TStringTree::NameType
Path()
const {
371 void SetMaxDepth(
unsigned int newMaxDepth= (std::numeric_limits<unsigned>::max)())
385 "StringTreeIterator not initialized or exceeded (invalid)." )
402 "StringTreeIterator not initialized or exceeded (invalid)." )
425 "StringTreeIterator not initialized or exceeded (invalid)." )
426 auto nodeToDelete=
node;
428 auto ntd=
tree->ImportCursor(nodeToDelete);
429 return ntd.Parent().DeleteChild( ntd );
440 stack.emplace_back();
444 auto cursor=
tree->ImportCursor(
node);
449 rd.unsortedParent=
tree->ImportCursor(
node).FirstChild().Export();
450 node= (rd.actChild.unsortedHandle= rd.unsortedParent);
454 rd.sortedChildren.clear();
455 rd.sortedChildren.reserve(
size_t( cursor.CountChildren() ) );
456 cursor.GoToFirstChild();
457 while( cursor.IsValid() ) {
458 rd.sortedChildren.emplace_back( cursor.Export() );
459 cursor.GoToNextSibling();
463 std::sort( rd.sortedChildren.begin(), rd.sortedChildren.end(),
467 return rd.sorter->Compare( tree->ImportCursor(lhs),
468 tree->ImportCursor(rhs) );
473 rd.actChild.sortedIdx= 0;
474 node= rd.sortedChildren[0];
479 rd.pathStringLen=
actPath.Length();
480 if ( rd.pathStringLen == 1 ) rd.pathStringLen= 0;
500 auto cursor=
tree->ImportCursor(
node);
505 && cursor.CountChildren() )
509 stack.emplace_back();
517 if( skipMode != 2 ) {
520 if( rd.sortedChildren.size() ) {
522 if( rd.actChild.
sortedIdx < rd.sortedChildren.size() ) {
529 if (
next.IsValid() )
543 .template _<NC>(
tree->ImportCursor(
node).Name());
550 #if ALIB_DEBUG_CRITICAL_SECTIONS
561template<
typename TTree>
#define ALIB_ASSERT_ERROR(cond, domain,...)
TStringTree StringTreeType
Publicly Exposes template parameter TStringTree.
std::conditional_t< !IsConst, typename StringTreeType::Cursor, typename StringTreeType::ConstCursor > CursorType
std::vector< RecursionData > stack
static constexpr bool IsConst
StringTreeIterator()=default
Default constructor.
unsigned CurrentDepth() const
void SetMaxDepth(unsigned int newMaxDepth=(std::numeric_limits< unsigned >::max)())
void Initialize(CursorType startNode, lang::Inclusion includeStartNode)
typename StringTreeType::CharacterType CharacterType
Exposes #"StringTree::CharacterType;*" #"StringTreeType".
void SetSorting(Sorter *sorter)
unsigned MaxDepth() const
const TStringTree::NameType Path() const
void SetPathGeneration(lang::Switch pathGeneration)
std::conditional_t<!IsConst, typename StringTreeType::CursorHandle, typename StringTreeType::ConstCursorHandle > cursorHandle
strings::TAString< CharacterType > actPath
@ On
Switch it on, switched on, etc.
@ Clear
Chooses to clear existing data.
Inclusion
Denotes how members of a set something should be taken into account.
@ Include
Chooses inclusion.
constexpr String NULL_STRING
A nulled string of the default character type.
constexpr const String EMPTY_STRING
An empty string of the default character type.
lang::integer integer
Type alias in namespace #"%alib".
lang::uinteger uinteger
Type alias in namespace #"%alib".
containers::StringTreeIterator< TTree > StringTreeIterator
Type alias in namespace #"%alib".
bool Compare(const StringTreeType::ConstCursor &lhs, const StringTreeType::ConstCursor &rhs) override
bool CaseSensitive
Unless changed by the caller, this is copied with every recursion step.
bool Descending
Unless changed by the caller, this is copied with every recursion step.
integer pathStringLen
The path string length of the actual recursion depth.
std::vector< cursorHandle > sortedChildren
A pointer to a dynamically allocated vector of children used with sorting.
cursorHandle unsortedParent
ActChildIdentifier actChild
The actual child handle, respectively index.
RecursionData() noexcept=default
Trivial default constructor.
virtual bool Compare(const StringTreeType::ConstCursor &lhs, const StringTreeType::ConstCursor &rhs)=0
virtual ~Sorter()=default
Necessary virtual destructor.
cursorHandle unsortedHandle