示例#1
0
TTErr TTAddressItem::append(TTAddress addressToAppend, TTAddressItemPtr *returnedItem)
{
	TTAddressItemPtr	anItem = this;
	TTAddressItemPtr	nextItem;
	TTList				nameInstanceList;
	TTSymbol			nameInstance(kTTSymEmpty);
	
	addressToAppend.listNameInstance(nameInstanceList);
	
	for (nameInstanceList.begin(); nameInstanceList.end(); nameInstanceList.next()) {
		nameInstance = nameInstanceList.current()[0];
		
		nextItem = anItem->getItem(nameInstance);
		
		if (!nextItem) {
			nextItem = new TTAddressItem(nameInstance, anItem);
			((TTListPtr)anItem)->append((TTPtr)nextItem);
		}
		
		anItem = nextItem;
	}
    
    anItem->options->appendUnique(addressToAppend.getAttribute());
	
	*returnedItem = anItem;
	return kTTErrNone;
}
示例#2
0
TTErr TTAddressItem::find(TTAddress addressToFind, TTAddressItemPtr *returnedItem)
{
	TTAddressItemPtr	anItem = this;
	TTAddressItemPtr	nextItem;
	TTList				nameInstanceList;
	TTSymbol			nameInstance(kTTSymEmpty);
    TTValue             v;
	
	addressToFind.listNameInstance(nameInstanceList);
    
    if (nameInstanceList.isEmpty())
        return kTTErrGeneric;
    
	for (nameInstanceList.begin(); nameInstanceList.end(); nameInstanceList.next()) {
		
		nameInstance = nameInstanceList.current()[0];
		
		nextItem = anItem->getItem(nameInstance);
		
		if (!nextItem)
			return kTTErrValueNotFound;
		else
			anItem = nextItem;
	}
    
    if (anItem->options->isEmpty() && addressToFind.getAttribute() == NO_ATTRIBUTE) {
        *returnedItem = anItem;
        return kTTErrNone;
    }
	
    if (!anItem->options->findEquals(addressToFind.getAttribute(), v)) {
        
        *returnedItem = anItem;
        return kTTErrNone;
    }
    
    return kTTErrValueNotFound;
}