Exemplo n.º 1
0
bool Hierarchy::Entry::prefixIterateAfter(Hierarchy::EntryIterator &callback)
{
	if (!prefixIterate(callback))
		return false;

	Entry *child=this;

	Entry *parent;

	while ((parent=child->getParent()) != NULL)
	{
		vector<Entry *>::iterator b=parent->begin(), e=parent->end();

		while (b != e)
			if ( *b++ == child)
				break;

		while (b != e)
			if (!(*b++)->prefixIterate(callback))
				return false;

		child=parent;
	}
	return true;
}
Exemplo n.º 2
0
		EntryBase::ConstIterator EntryBase::getEntryIterator( const std::string& path ) const
		{
			std::vector< std::string > tokens = util::tokenize( path, "/" );
			for ( auto it = tokens.begin(); it != tokens.end(); ++it )
			{
				if ( it->empty() )
				{
					tokens.erase( it );
					it = tokens.begin() - 1;
					continue;
				}
			}
			
			std::size_t currToken = 0;
			auto currEnd = end();
			for ( auto it = begin(); it != currEnd; ++it )
			{
				Entry* entry = it->get();
				if ( entry->getName() == tokens[ currToken ] )
				{
					if ( currToken >= tokens.size() - 1 )
					{
						return it;
					}
					else if ( entry->isDirectory() and entry->children.size() >= 1 )
					{
						it = entry->begin() - 1;
						currEnd = entry->end();
						++currToken;
						continue;
					}
					else
					{
						return end();
					}
				}
			}
			
			return end();
		}