当前位置: 首页>>代码示例>>C++>>正文


C++ XmlElement::GetAttribute方法代码示例

本文整理汇总了C++中XmlElement::GetAttribute方法的典型用法代码示例。如果您正苦于以下问题:C++ XmlElement::GetAttribute方法的具体用法?C++ XmlElement::GetAttribute怎么用?C++ XmlElement::GetAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XmlElement的用法示例。


在下文中一共展示了XmlElement::GetAttribute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: WriteToFilePosRotScaleBoxFlags

/**
*  @brief
*    Writes the scene node position, rotation, scale, bounding box and flags into a file
*/
void PLSceneNode::WriteToFilePosRotScaleBoxFlags(XmlElement &cNodeElement) const
{
	// Currently ONLY the center of the container the node is in use used to make it relative
	const Point3 vParentWorldSpaceCenter = GetContainer() ? GetContainer()->GetWorldSpaceCenter() : Point3(0.0f, 0.0f, 0.0f);

	// Write down the position
	PLTools::XmlElementSetAttributeWithDefault(cNodeElement, "Position", (GetType() != TypeScene && GetType() != TypeCell) ? m_vPos-vParentWorldSpaceCenter : static_cast<const PLSceneContainer*>(this)->GetWorldSpaceCenter(), Point3(0.0f, 0.0f, 0.0f));

	// Write down the rotation
	PLTools::XmlElementSetAttributeWithDefault(cNodeElement, "Rotation", m_vRot, Point3(0.0f, 0.0f, 0.0f));

	// Write down the scale
	PLTools::XmlElementSetAttributeWithDefault(cNodeElement, "Scale", m_vScale, Point3(1.0f, 1.0f, 1.0f));

	// Are there any flags?
	if (m_sFlags.GetLength()) {
		String sFlags = cNodeElement.GetAttribute("Flags");
		if (sFlags.GetLength())
			sFlags += '|' + m_sFlags;
		else
			sFlags = m_sFlags;
		sFlags.Trim();
		cNodeElement.SetAttribute("Flags", sFlags);
	}
}
开发者ID:ByeDream,项目名称:pixellight,代码行数:29,代码来源:PLSceneNode.cpp

示例2: WriteVariables

/**
*  @brief
*    Writes the flexible scene node variables
*/
void PLSceneNode::WriteVariables(XmlElement &cNodeElement) const
{
	// Export variables?
	if (g_SEOptions.bUserPropVariables) {
		// Is there a 3ds Max node (No 3ds Max node, no properties)
		INode *pMaxNode = GetMaxNode();
		if (pMaxNode) {
			// Check for variables
			TSTR s3dsMaxString;
			if (pMaxNode->GetUserPropString(_T("Vars"), s3dsMaxString)) {
				// Get all expressions
				static RegEx cExpressionRegEx("\\s*((\\w*\\s*=\\s*\"[^\"]*\")|(\\w*\\s*=\\s*[\\w|]*))");
				const String sString = s3dsMaxString;
				uint32 nExpressionParsePos = 0;
				while (cExpressionRegEx.Match(sString, nExpressionParsePos)) {
					// Get expression
								 nExpressionParsePos = cExpressionRegEx.GetPosition();
					const String sExpression		 = cExpressionRegEx.GetResult(0);

					// Process the found expression
					static RegEx cRegEx("\\s*(\\w*)\\s*=\\s*\"?\\s*([^\"]*)\\s*\"?");
					if (cRegEx.Match(sExpression)) {
						// Get name and value
						const String sName  = cRegEx.GetResult(0);
						const String sValue = cRegEx.GetResult(1);

						// Flags variable?
						if (sName == "Flags") {
							// Update attribute
							String sFlags = cNodeElement.GetAttribute(sName);
							if (sFlags.GetLength())
								sFlags += '|' + sValue;
							else
								sFlags = sValue;
							sFlags.Trim();
							cNodeElement.SetAttribute(sName, sFlags);
						} else {
							// Set attribute
							cNodeElement.SetAttribute(sName, sValue);
						}
					}
				}
			}
		}
	}
}
开发者ID:ByeDream,项目名称:pixellight,代码行数:50,代码来源:PLSceneNode.cpp


注:本文中的XmlElement::GetAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。