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())
70 static constexpr bool IsConst = std::is_const_v<TStringTree>;
76 typename StringTreeType::Cursor,
77 typename StringTreeType::ConstCursor>;
86 typename StringTreeType::CursorHandle,
87 typename StringTreeType::ConstCursorHandle>;
104 virtual bool Compare(
const StringTreeType::ConstCursor& lhs,
105 const StringTreeType::ConstCursor& rhs) =0;
122 bool Compare(
const StringTreeType::ConstCursor& lhs,
123 const StringTreeType::ConstCursor& rhs)
override {
126 ? lhs.Name().template CompareTo<CHK,lang::Case::Sensitive>(rhs.Name())
127 : lhs.Name().template CompareTo<CHK,lang::Case::Ignore >(rhs.Name());
215 unsigned maxDepth =(std::numeric_limits<
unsigned int>::max)();
266 ALIB_ASSERT_ERROR( startNode.IsValid(),
"STRINGTREE",
"Invalid start-node given." )
267 this->
tree= &startNode.template Tree<TStringTree>();
273 node= startNode.Export();
276 RecursionData& rd=
stack.emplace_back();
277 node= startNode.Export();
279 rd.sortedChildren.emplace_back(
node);
285 if( startNode.HasChildren() ) {
358 const TStringTree::NameType
Path()
const {
373 void SetMaxDepth(
unsigned int newMaxDepth= (std::numeric_limits<unsigned>::max)())
387 "StringTreeIterator not initialized or exceeded (invalid)." )
408 "StringTreeIterator not initialized or exceeded (invalid)." )
433 "StringTreeIterator not initialized or exceeded (invalid)." )
434 auto nodeToDelete=
node;
436 auto ntd=
tree->ImportCursor(nodeToDelete);
437 return ntd.Parent().DeleteChild( ntd );
448 stack.emplace_back();
452 auto cursor=
tree->ImportCursor(
node);
457 rd.unsortedParent=
tree->ImportCursor(
node).FirstChild().Export();
458 node= (rd.actChild.unsortedHandle= rd.unsortedParent);
462 rd.sortedChildren.clear();
463 rd.sortedChildren.reserve(
size_t( cursor.CountChildren() ) );
464 cursor.GoToFirstChild();
465 while( cursor.IsValid() ) {
466 rd.sortedChildren.emplace_back( cursor.Export() );
467 cursor.GoToNextSibling();
471 std::sort( rd.sortedChildren.begin(), rd.sortedChildren.end(),
475 return rd.sorter->Compare( tree->ImportCursor(lhs),
476 tree->ImportCursor(rhs) );
481 rd.actChild.sortedIdx= 0;
482 node= rd.sortedChildren[0];
487 rd.pathStringLen=
actPath.Length();
488 if ( rd.pathStringLen == 1 ) rd.pathStringLen= 0;
508 auto cursor=
tree->ImportCursor(
node);
513 && cursor.CountChildren() )
517 stack.emplace_back();
525 if( skipMode != 2 ) {
528 if( rd.sortedChildren.size() ) {
530 if( rd.actChild.
sortedIdx < rd.sortedChildren.size() ) {
537 if (
next.IsValid() )
551 .template _<NC>(
tree->ImportCursor(
node).Name());
558 #if ALIB_DEBUG_CRITICAL_SECTIONS
569template<
typename TTree>
TStringTree StringTreeType
Publicly Exposes template parameter TStringTree.
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.
std::conditional_t< !IsConst, typename StringTreeType::Cursor, typename StringTreeType::ConstCursor > CursorType
void SetSorting(Sorter *sorter)
unsigned MaxDepth() const
const TStringTree::NameType Path() const
std::conditional_t<!IsConst, typename StringTreeType::CursorHandle, typename StringTreeType::ConstCursorHandle > cursorHandle
void SetPathGeneration(lang::Switch pathGeneration)
strings::TAString< CharacterType > actPath
#define ALIB_ASSERT_ERROR(cond, domain,...)
@ 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