本文整理汇总了C++中SimObject::findObject方法的典型用法代码示例。如果您正苦于以下问题:C++ SimObject::findObject方法的具体用法?C++ SimObject::findObject怎么用?C++ SimObject::findObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimObject
的用法示例。
在下文中一共展示了SimObject::findObject方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: findObject
SimObject* findObject(const char* name)
{
PROFILE_SCOPE(SimFindObject);
// Play nice with bad code - JDD
if( !name )
return NULL;
SimObject *obj;
char c = *name;
if (c == '%')
{
if (gEvalState.getStackDepth())
{
Dictionary::Entry* ent = gEvalState.getCurrentFrame().lookup(StringTable->insert(name));
if (ent)
return Sim::findObject(ent->getIntValue());
}
}
if(c == '/')
return gRootGroup->findObject(name + 1 );
if(c >= '0' && c <= '9')
{
// it's an id group
const char* temp = name + 1;
for(;;)
{
c = *temp++;
if(!c)
return findObject(dAtoi(name));
else if(c == '/')
{
obj = findObject(dAtoi(name));
if(!obj)
return NULL;
return obj->findObject(temp);
}
}
}
S32 len;
for(len = 0; name[len] != 0 && name[len] != '/'; len++)
;
StringTableEntry stName = StringTable->lookupn(name, len);
if(!stName)
return NULL;
obj = gNameDictionary->find(stName);
if(!name[len])
return obj;
if(!obj)
return NULL;
return obj->findObject(name + len + 1);
}
示例2:
SimObject *SimGroup::findObject(const char *namePath)
{
// find the end of the object name
S32 len;
for(len = 0; namePath[len] != 0 && namePath[len] != '/'; len++)
;
StringTableEntry stName = StringTable->lookupn(namePath, len);
if(!stName)
return NULL;
SimObject *root = mNameDictionary.find( stName );
if( !root )
return NULL;
if(namePath[len] == 0)
return root;
return root->findObject(namePath + len + 1);
}