本文整理汇总了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 ) );
}
}
}
示例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;
}