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)();
267 ALIB_ASSERT_ERROR( startNode.IsValid(),
"STRINGTREE",
"Invalid start-node given." )
268 this->
tree= &startNode.template Tree<TStringTree>();
274 node= startNode.Export();
277 RecursionData& rd=
stack.emplace_back();
278 node= startNode.Export();
280 rd.sortedChildren.emplace_back(
node);
286 if( startNode.HasChildren() )
355 const TStringTree::NameType
Path()
const {
370 void SetMaxDepth(
unsigned int newMaxDepth= (std::numeric_limits<unsigned>::max)())
384 "StringTreeIterator not initialized or exceeded (invalid)." )
401 "StringTreeIterator not initialized or exceeded (invalid)." )
424 "StringTreeIterator not initialized or exceeded (invalid)." )
425 auto nodeToDelete=
node;
427 auto ntd=
tree->ImportCursor(nodeToDelete);
428 return ntd.Parent().DeleteChild( ntd );
439 stack.emplace_back();
443 auto cursor=
tree->ImportCursor(
node);
448 rd.unsortedParent=
tree->ImportCursor(
node).FirstChild().Export();
449 node= (rd.actChild.unsortedHandle= rd.unsortedParent);
453 rd.sortedChildren.clear();
454 rd.sortedChildren.reserve(
size_t( cursor.CountChildren() ) );
455 cursor.GoToFirstChild();
456 while( cursor.IsValid() ) {
457 rd.sortedChildren.emplace_back( cursor.Export() );
458 cursor.GoToNextSibling();
462 std::sort( rd.sortedChildren.begin(), rd.sortedChildren.end(),
466 return rd.sorter->Compare( tree->ImportCursor(lhs),
467 tree->ImportCursor(rhs) );
472 rd.actChild.sortedIdx= 0;
473 node= rd.sortedChildren[0];
478 rd.pathStringLen=
actPath.Length();
479 if ( rd.pathStringLen == 1 ) rd.pathStringLen= 0;
499 auto cursor=
tree->ImportCursor(
node);
504 && cursor.CountChildren() )
508 stack.emplace_back();
516 if( skipMode != 2 ) {
519 if( rd.sortedChildren.size() ) {
521 if( rd.actChild.
sortedIdx < rd.sortedChildren.size() ) {
528 if (
next.IsValid() )
542 .template _<NC>(
tree->ImportCursor(
node).Name());
549 #if ALIB_DEBUG_CRITICAL_SECTIONS
560template<
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