std::vector<UsdProperty> UsdPrim::_GetPropertiesInNamespace(const std::string &namespaces, bool onlyAuthored) const { // XXX Would be nice to someday plumb the prefix search down through pcp if (namespaces.empty()) return onlyAuthored ? GetAuthoredProperties() : GetProperties(); const char delim = UsdObject::GetNamespaceDelimiter(); TfTokenVector names = _GetPropertyNames(onlyAuthored, /*applyOrder=*/false); // Set terminator to the expected position of the delimiter after all the // supplied namespaces. We perform an explicit test for this char below // so that we don't need to allocate a new string if namespaces does not // already end with the delimiter const size_t terminator = namespaces.size() - (*namespaces.rbegin() == delim); // Prune out non-matches before we sort size_t insertionPt = 0; for (const auto& name : names) { const std::string &s = name.GetString(); if (s.size() > terminator && TfStringStartsWith(s, namespaces) && s[terminator] == delim) { names[insertionPt++] = name; } } names.resize(insertionPt); sort(names.begin(), names.end(), TfDictionaryLessThan()); _ApplyOrdering(GetPropertyOrder(), &names); return _MakeProperties(names); }
UsdShadeInterfaceAttribute::UsdShadeInterfaceAttribute( const UsdAttribute &attr) { TfToken const &interfaceAttrName = attr.GetName(); if (TfStringStartsWith(interfaceAttrName, _tokens->interface)){ _attr = attr; _name = TfToken(interfaceAttrName.GetString().substr(_tokens->interface.GetString().size())); } }
/* static */ bool UsdSkelInbetweenShape::_IsValidInbetweenName(const std::string& name, bool quiet) { // All properly namespaced attributes are legal inbetweens. // However, if we extend the schema to include any special attributes // -- say, inbetweens:foo:pointIndices, to allow each inbetween to // specify its own point indices -- then we should not consider such // names to be invalid. return TfStringStartsWith(name, _tokens->inbetweensPrefix); }
/* static */ TfToken UsdShadeInterfaceAttribute::_GetName( const TfToken& interfaceAttrName) { if (TfStringStartsWith(interfaceAttrName, _tokens->interface)) { return interfaceAttrName; } return TfToken(TfStringPrintf("%s%s", _tokens->interface.GetText(), interfaceAttrName.GetText())); }
TfToken UsdVolVolume::_MakeNamespaced(const TfToken& name) { TfToken result; if (TfStringStartsWith(name, _tokens->fieldPrefix)) { result = name; } else { result = TfToken(_tokens->fieldPrefix.GetString() + name.GetString()); } return result; }
static void _AddAttributeNameEntry( const std::string mayaAttrName, const std::map<std::string, std::string>& mayaToUsdPrefixes, bool isPrimvar, std::vector<_AttributeEntry>* outAttrs) { for (const auto& mayaAndUsdPrefix : mayaToUsdPrefixes) { const std::string& mayaPrefix = mayaAndUsdPrefix.first; const std::string& usdPrefix = mayaAndUsdPrefix.second; if (TfStringStartsWith(mayaAttrName, mayaPrefix)) { const std::string usdAttrName = usdPrefix + mayaAttrName.substr(mayaPrefix.size()); outAttrs->push_back( _AttributeEntry(mayaAttrName, usdAttrName, isPrimvar)); } } }
/* static */ bool UsdSkelInbetweenShape::_IsNamespaced(const TfToken& name) { return TfStringStartsWith(name, _tokens->inbetweensPrefix); }
/* static */ bool UsdGeomPrimvar::_IsNamespaced(const TfToken& name) { return TfStringStartsWith(name, _tokens->primvarsPrefix); }
// Validate that the given \p name contains the xform namespace. // Does not validate name as a legal property identifier static bool _IsNamespaced(const TfToken& opName) { return TfStringStartsWith(opName, _tokens->xformOpPrefix); }
// Returns whether the given op is an inverse operation. i.e, it starts with // "!invert!:xformOp:". static bool _IsInverseOp(TfToken const &opName) { return TfStringStartsWith(opName, _tokens->inverseXformOpPrefix); }