void snapshot(XMLNode xmlNode, TTNodePtr ttNode) { TTSymbolPtr OSCaddress; TTValue v, attributeNames; TTList childList; TTNodePtr p_node; TTString s; ttNode->getOscAddress(&OSCaddress); ttNode->getChildren(S_WILDCARD, S_WILDCARD, childList); const char* address = OSCaddress->getCString(); char* nodeName; XMLNode childNode = xmlNode; // don't write the first node AppName in xml because already written in application xml header // don't write the node name if is an instance, don't want it in xml file, replaced by dynamic instances attribute if (strcmp(address, AppName.c_str()) != 0 && strrchr(address, '.') == NULL) { // get the substring representing the last node name if (strlen(address) > 1) { const char* c = strrchr(address, '/'); int start = c-address+1; int end = strlen(address)-1; nodeName = str_sub(address, start, end); childNode = xmlNode.addChild(nodeName); } if (childList.isEmpty()) { // get the Data object of the Node TTObjectPtr param = ttNode->getObject(); if (param != NULL) { addAttributeToXml(param, childNode, kTTSym_type); addAttributeToXml(param, childNode, kTTSym_valueDefault); addAttributeToXml(param, childNode, kTTSym_rangeBounds); addAttributeToXml(param, childNode, kTTSym_rangeClipmode); addAttributeToXml(param, childNode, kTTSym_valueStepsize); addAttributeToXml(param, childNode, TTSymbol("dynamicInstances")); addAttributeToXml(param, childNode, TTSymbol("instanceBounds")); addAttributeToXml(param, childNode, kTTSym_priority); addAttributeToXml(param, childNode, kTTSym_description); addAttributeToXml(param, childNode, kTTSym_repetitionsFilter); addAttributeToXml(param, childNode, kTTSym_readonly); } } } // repeat recursively for each child for (childList.begin(); childList.end(); childList.next()) { childList.current().get(0,(TTPtr*)&p_node); snapshot(childNode, p_node); } }
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; }