本文整理汇总了C++中XNode::GetAttr方法的典型用法代码示例。如果您正苦于以下问题:C++ XNode::GetAttr方法的具体用法?C++ XNode::GetAttr怎么用?C++ XNode::GetAttr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XNode
的用法示例。
在下文中一共展示了XNode::GetAttr方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetChild
XAttr *XNode::GetChildAttr( const char* name, const char* attrname )
{
XNode *node = GetChild(name);
return node ? node->GetAttr(attrname) : NULL;
}
示例2: GetLegacyActorClass
Actor *ActorUtil::LoadFromNode( const XNode* _pNode, Actor *pParentActor )
{
ASSERT( _pNode != NULL );
XNode node = *_pNode;
// Remove this in favor of using conditionals in Lua. -Chris
// There are a number of themes out there that depend on this (including
// sm-ssc default). Probably for the best to leave this in. -aj
{
bool bCond;
if( node.GetAttrValue("Condition", bCond) && !bCond )
return NULL;
}
RString sClass;
bool bHasClass = node.GetAttrValue( "Class", sClass );
if( !bHasClass )
bHasClass = node.GetAttrValue( "Type", sClass );
bool bLegacy = (node.GetAttr( "_LegacyXml" ) != NULL);
if( !bHasClass && bLegacy )
sClass = GetLegacyActorClass( &node );
map<RString,CreateActorFn>::iterator iter = g_pmapRegistrees->find( sClass );
if( iter == g_pmapRegistrees->end() )
{
RString sFile;
if (bLegacy && node.GetAttrValue("File", sFile) && sFile != "")
{
RString sPath;
// Handle absolute paths correctly
if (sFile.Left(1) == "/")
sPath = sFile;
else
sPath = Dirname(GetSourcePath(&node)) + sFile;
if (ResolvePath(sPath, GetWhere(&node)))
{
Actor *pNewActor = MakeActor(sPath, pParentActor);
if (pNewActor == NULL)
return NULL;
if (pParentActor)
pNewActor->SetParent(pParentActor);
pNewActor->LoadFromNode(&node);
return pNewActor;
}
}
// sClass is invalid
RString sError = ssprintf( "%s: invalid Class \"%s\"",
ActorUtil::GetWhere(&node).c_str(), sClass.c_str() );
LuaHelpers::ReportScriptError(sError);
return new Actor; // Return a dummy object so that we don't crash in AutoActor later.
}
const CreateActorFn &pfn = iter->second;
Actor *pRet = pfn();
if( pParentActor )
pRet->SetParent( pParentActor );
pRet->LoadFromNode( &node );
return pRet;
}