Exemplo n.º 1
0
/**
 * Compares the various parts of the wildcard name with the id
 * Indexing is messy here because we may refer to any of 3 things:
 * - Regular array indexing
 * - Wildcards within the braces
 * - Simple elements with index as part of their names.
 */
bool matchName( Id parent, Id id, 
	const string& beforeBrace, const string& insideBrace, 
	unsigned int index )
{
	string temp = id()->name();
	assert( temp.length() > 0 );
	bool bracesInName = 
		( temp.length() > 3 && 
		temp[temp.length() - 1] == ']' && 
		id()->elementType() == "Simple" );

	if ( !( index == Id::AnyIndex || id.index() == index || bracesInName ||
		index == NOINDEX ) )
		return 0;
	
	if (index == NOINDEX){
		if ( parent()->elementType() == "Simple" ){
			index = 0;
			if (id.index() != 0) return 0;
		}
		else if ( parent()->elementType() == "Array" )
			index = parent.index();
	}
	
	if ( matchBeforeBrace( id, beforeBrace, bracesInName, index ) ) {
		if ( insideBrace.length() == 0 ) {
			return 1;
		} else {
			return matchInsideBrace( id, insideBrace );
		}
	}
	return 0;
}