static void AddSchemaAliases ( IterInfo & info, IterNode & iterSchema, XMP_StringPtr schemaURI ) { // We're showing the aliases also. Look them up by their namespace prefix. Yes, the alias map is // sorted so we could process just that portion. But that takes more code and the extra speed // isn't worth it. (Plus this way we avoid a dependence on the map implementation.) Lookup the // XMP node from the alias, to make sure the actual exists. #if TraceIterators printf ( " Adding aliases\n", schemaURI ); #endif XMP_StringPtr nsPrefix; XMP_StringLen nsLen; bool found = XMPMeta::GetNamespacePrefix ( schemaURI, &nsPrefix, &nsLen ); if ( ! found ) XMP_Throw ( "Unknown iteration namespace", kXMPErr_BadSchema ); XMP_AliasMapPos currAlias = sRegisteredAliasMap->begin(); XMP_AliasMapPos endAlias = sRegisteredAliasMap->end(); for ( ; currAlias != endAlias; ++currAlias ) { if ( XMP_LitNMatch ( currAlias->first.c_str(), nsPrefix, nsLen ) ) { const XMP_Node * actualProp = FindConstNode ( &info.xmpObj->tree, currAlias->second ); if ( actualProp != 0 ) { iterSchema.children.push_back ( IterNode ( (actualProp->options | kXMP_PropIsAlias), currAlias->first, 0 ) ); #if TraceIterators printf ( " %s => %s\n", currAlias->first.c_str(), actualProp->name.c_str() ); #endif } } } } // AddSchemaAliases
MOOV_Manager::BoxRef MOOV_Manager::GetBox ( const char * boxPath, BoxInfo * info ) const { size_t pathLen = strlen(boxPath); XMP_Assert ( (pathLen >= 4) && XMP_LitNMatch ( boxPath, "moov", 4 ) ); if ( info != 0 ) memset ( info, 0, sizeof(BoxInfo) ); const char * pathPtr = boxPath + 5; // Skip the "moov/" portion. const char * pathEnd = boxPath + pathLen; BoxRef currRef = &this->moovNode; while ( pathPtr < pathEnd ) { XMP_Assert ( (pathEnd - pathPtr) >= 4 ); XMP_Uns32 boxType = GetUns32BE ( pathPtr ); pathPtr += 5; // ! Don't care that the last step goes 1 too far. currRef = this->GetTypeChild ( currRef, boxType, 0 ); if ( currRef == 0 ) return 0; } this->FillBoxInfo ( *((BoxNode*)currRef), info ); return currRef; } // MOOV_Manager::GetBox
void MOOV_Manager::SetBox ( const char * boxPath, const void* dataPtr, XMP_Uns32 size , const XMP_Uns8 * idUUID ) { XMP_Enforce ( size < moovBoxSizeLimit ); size_t pathLen = strlen(boxPath); XMP_Assert ( (pathLen >= 4) && XMP_LitNMatch ( boxPath, "moov", 4 ) ); const char * pathPtr = boxPath + 5; // Skip the "moov/" portion. const char * pathEnd = boxPath + pathLen; BoxRef parentRef = 0; BoxRef currRef = &this->moovNode; while ( pathPtr < pathEnd ) { XMP_Assert ( (pathEnd - pathPtr) >= 4 ); XMP_Uns32 boxType = GetUns32BE ( pathPtr ); pathPtr += 5; // ! Don't care that the last step goes 1 too far. parentRef = currRef; currRef = this->GetTypeChild ( parentRef, boxType, 0 ); if ( currRef == 0 ) currRef = this->AddChildBox ( parentRef, boxType, 0, 0 , idUUID ); } this->SetBox ( currRef, dataPtr, size, idUUID ); } // MOOV_Manager::SetBox
static inline bool IsPathPrefix ( XMP_StringPtr fullPath, XMP_StringPtr prefix ) { bool isPrefix = false; XMP_StringLen prefixLen = std::strlen(prefix); if ( XMP_LitNMatch ( prefix, fullPath, prefixLen ) ) { char separator = fullPath[prefixLen]; if ( (separator == 0) || (separator == '/') || (separator == '[') || (separator == '*') ) isPrefix = true; } return isPrefix; }