treebox treats root paths / and \ as a node
This commit is contained in:
parent
3f446e9a0c
commit
5c50bd7a56
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* A Tree Container class implementation
|
||||
* Copyright(C) 2003-2017 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2018 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@ -479,6 +479,8 @@ namespace detail
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// foreach elements of key.
|
||||
// the root name "/" and "\\" are treated as a node. This is a feature that can easily support the UNIX-like path.
|
||||
template<typename Function>
|
||||
void _m_for_each(const ::std::string& key, Function function) const
|
||||
{
|
||||
@ -491,18 +493,24 @@ namespace detail
|
||||
{
|
||||
if(beg != end)
|
||||
{
|
||||
if(function(key.substr(beg, end - beg)) == false)
|
||||
if(!function(key.substr(beg, end - beg)))
|
||||
return;
|
||||
}
|
||||
|
||||
auto next = key.find_first_not_of("\\/", end);
|
||||
if(next != ::std::string::npos)
|
||||
{
|
||||
beg = next;
|
||||
end = key.find_first_of("\\/", beg);
|
||||
}
|
||||
else
|
||||
|
||||
if ((next == ::std::string::npos) && end)
|
||||
return;
|
||||
|
||||
if (0 == end)
|
||||
{
|
||||
if ((!function(key.substr(0, 1))) || (next == ::std::string::npos))
|
||||
return;
|
||||
}
|
||||
|
||||
beg = next;
|
||||
end = key.find_first_of("\\/", beg);
|
||||
|
||||
}
|
||||
|
||||
function(key.substr(beg, key.size() - beg));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user