示例#1
0
 __INLINE AttributeRef
 ElementRef::getFirstAttr ()
 {
     ElementSegment* me = getMe<Read>();
     if (!__doesElementRefHasAttributesAndChildren(me->flags))
     {
         return AttributeRef(getDocument());
     }
     __checkElementFlag_HasAttributesAndChildren(me->flags);
     return AttributeRef(getDocument(), getElementPtr(), me->attributesAndChildren.attrPtr);
 }
示例#2
0
    __INLINE AttributeRef
    ElementRef::findAttr (KeyId _keyId, AttributeType type)
    {
        Log_Element ( "getAttr keyId=%x type=%x\n", _keyId, type );
        if (_keyId == 0)
            return AttributeRef(document);
        AttributeSegment* attr = NULL;
        ElementSegment* me = getMe<Read>();
        if (!__doesElementRefHasAttributesAndChildren(me->flags))
            return AttributeRef(getDocument());

        // __checkElementFlag_HasAttributesAndChildren ( me->flags );
        __checkElementFlag_HasAttributesAndChildren(me->flags);
        SegmentPtr attrPtr = me->attributesAndChildren.attrPtr;

        KeyId keyId = _keyId;
        if (KeyCache::getNamespaceId(keyId) == KeyCache::getNamespaceId(me->keyId))
        {
            keyId = KeyCache::getLocalKeyId(keyId);
        }

        while (attrPtr)
        {
            attr = getSegment<AttributeSegment, Read>(attrPtr);
            Log_Element ( "At attr keyId=%x, ptr=%llx, next=%llx, flag=%x, search[keyId=%x, type=%x]\n",
                    attr->keyId, attrPtr, attr->nextPtr, attr->flag, keyId, type );

            if (attr->keyId == keyId || attr->keyId == _keyId)
            {
                if ((type & (attr->flag & AttributeType_Mask)) == type)
                {
                    Log_Element ( "** return %llx\n", attrPtr );
                    return AttributeRef(document, getElementPtr(), attrPtr);
                }
            }
            attrPtr = attr->nextPtr;
        }
        Log_Element ( "** return NULL\n" );
        return AttributeRef(document, NullPtr, NullPtr);
    }
示例#3
0
AttributeRef Material::attribute(const std::string& name)
{
    auto it = attributes.find(name);
    return (it == attributes.end()) ? AttributeRef() : it->second;
}