Exemplo n.º 1
0
ChunkPath::ChunkPath( const ChunkPath& path )
{
	for( XMP_Int32 i=0; i<path.length(); i++ )
	{
		this->append( path.identifier(i) );
	}
}
void ChunkController::findChunks( const ChunkPath& path, ChunkPath& currentPath, const Chunk& chunk )
{
	if( path.length() > currentPath.length() )
	{
		for( XMP_Uns32 i=0; i<chunk.numChildren(); i++ )
		{
			Chunk* child = NULL;

			try
			{
				child = chunk.getChildAt(i);
			}
			catch(...)
			{
				child = NULL;
			}

			if( child != NULL )
			{
				currentPath.append( child->getIdentifier() );

				switch( path.match( currentPath ) )
				{
					case ChunkPath::kFullMatch:
					{
						mSearchResults.push_back( child );
					}
					break;

					case ChunkPath::kPartMatch:
					{
						this->findChunks( path, currentPath, *child );
					}
					break;

					case ChunkPath::kNoMatch:
					{
						// Nothing to do
					}
					break; 
				}

				currentPath.remove();
			}
		}
	}
}//findChunks
Exemplo n.º 3
0
ChunkPath::MatchResult ChunkPath::match( const ChunkPath& path ) const
{
	MatchResult ret			= kNoMatch;

	if( path.length() > 0 )
	{
		XMP_Int32 depth			= ( this->length() > path.length() ? path.length() : this->length() );
		XMP_Int32 matchCount	= 0;

		for( XMP_Int32 i=0; i<depth; i++ )
		{
			const ChunkIdentifier& id1 = this->identifier(i);
			const ChunkIdentifier& id2 = path.identifier(i);

			if( id1.id == id2.id )
			{
				if( i == this->length() - 1 && id1.type == kType_NONE )
				{
					matchCount++;
				}
				else if( id1.type == id2.type )
				{
					matchCount++;
				}
			}
			else
				break;
		}

		if( matchCount == depth )
		{
			ret = ( path.length() >= this->length() ? kFullMatch : kPartMatch );
		}
	}

	return ret;
}