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


C++ XMLNode::GetText方法代码示例

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


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

示例1: loadSoundsFromXMLFile

	//------------------------------------------------
	void Sound::loadSoundsFromXMLFile( const std::string& filePath, const std::string& file )
	{
		std::string fullFilePath = filePath + file;
		XMLParser parser( fullFilePath.c_str() );
		XMLDocument& doc = parser.getDocument();

		if( !doc.Error() )
		{
			XMLNode* root = doc.FirstChildElement( "Sounds" );
			XMLNode* soundElement;
			for( soundElement = root->FirstChildElement( "Sound" ); soundElement != 0; soundElement = soundElement->NextSiblingElement( "Sound" ) )
			{
				parser.validateXMLAttributes( soundElement, "name,mode", "" );
				std::string soundName = parser.getXMLAttributeAsString( soundElement, "name", "" );
				std::string soundMode = parser.getXMLAttributeAsString( soundElement, "mode", "" );
				const char* soundFile = soundElement->GetText();
				Sound::createOrGetSound( soundName, filePath + std::string( soundFile ), getModeFromString( soundMode ) );
			}
		}
	}
开发者ID:hulcyp,项目名称:GuildhallProjects,代码行数:21,代码来源:Sound.cpp

示例2: Initlize

//----------------------------------------------------------------------------
bool FontBitmapImpl::Initlize (int fontWidth, int fontHeight, 
	const char *fontFilename, CharCodingType codingType, unsigned int fontExtStyle)
{
	Font::Initlize(fontWidth, fontHeight, fontFilename, codingType, fontExtStyle);

	mFontFilename = fontFilename;

	if (CCT_UTF8 == codingType)
	{
		mCharCodingObj = new0 CharCodingUTF8();
	}
	else if (CCT_GBK == codingType)
	{
		mCharCodingObj = new0 CharCodingGBK();
	}

	mGlyphMap = this;

	std::string outPath;
	std::string outBaseFilename;
	StringHelp::SplitFilename(fontFilename, outPath, outBaseFilename);

	int bufferSize = 0;
	char *buffer = 0;
	if (PX2_RM.LoadBuffer(fontFilename, bufferSize, buffer))
	{
		XMLData data;
		if (data.LoadBuffer(buffer, bufferSize))
		{
			float imageWidth = 0.0f;
			float imageHeight = 0.0f;

			XMLNode rootNode = data.GetRootNode();
			XMLNode child = rootNode.IterateChild();
			while (!child.IsNull())
			{
				const std::string &nodeName = child.GetName();

				if ("image" == nodeName)
				{
					const char *text = child.GetText();
					std::string imagePath = outPath + text;

					mFontTex = DynamicCast<Texture2D>(PX2_RM.BlockLoad(imagePath));
					if (mFontTex)
					{
						imageWidth = (float)mFontTex->GetWidth();
						imageHeight = (float)mFontTex->GetHeight();
					}
				}
				else if ("symbol" == nodeName)
				{
					std::string ch = child.GetChild("char").GetText();
					int x = StringHelp::StringToInt(child.GetChild("x").GetText());
					int y = StringHelp::StringToInt(child.GetChild("y").GetText());
					int width = StringHelp::StringToInt(child.GetChild("width").GetText());
					int height = StringHelp::StringToInt(child.GetChild("height").GetText());

					unsigned int unicode = mCharCodingObj->ToUnicode((const unsigned char*)ch.c_str());

					BitmapFontGlyph glyph;
					glyph.X = x;
					glyph.Y = y;
					glyph.numWidth = width;
					glyph.numHeight = height;

					float u0 = (float)x/imageWidth;
					float v0 = 1.0f-(float)(y+height)/imageHeight;
					float u1 = (x+width)/imageWidth;
					float v1 = v0 + (float)height/imageHeight;
					glyph.RectUV = Rectf(u0, v0, u1, v1);

					mMapGlyph[unicode] = glyph;
				}

				child = rootNode.IterateChild(child);
			}
		}
	}

	return true;
}
开发者ID:SylviaTanenbaum,项目名称:3d-simulation-and-game,代码行数:83,代码来源:PX2FontBitmapImpl.cpp


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