本文整理汇总了C++中XmlNode::getString方法的典型用法代码示例。如果您正苦于以下问题:C++ XmlNode::getString方法的具体用法?C++ XmlNode::getString怎么用?C++ XmlNode::getString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlNode
的用法示例。
在下文中一共展示了XmlNode::getString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: XmlException
//===========================================
// TextEntity::TextEntity
//===========================================
TextEntity::TextEntity(const XmlNode data)
: Asset(internString("TextEntity")),
Entity(data.firstChild()),
m_renderer(Renderer::getInstance()),
m_model(Renderer::TRIANGLES) {
try {
XML_NODE_CHECK(data, TextEntity);
XmlNode node = data.nthChild(1);
XML_NODE_CHECK(node, font);
XmlAttribute attr = node.firstAttribute();
XML_ATTR_CHECK(attr, ptr);
long fontId = attr.getLong();
AssetManager assetManager;
pFont_t font = boost::dynamic_pointer_cast<Dodge::Font>(assetManager.getAssetPointer(fontId));
if (!font)
throw XmlException("Bad asset id", __FILE__, __LINE__);
m_font = font;
node = node.nextSibling();
XML_NODE_CHECK(node, textSize);
m_size = Vec2f(node.firstChild());
node = node.nextSibling();
XML_NODE_CHECK(node, text);
setText(node.getString());
}
catch (XmlException& e) {
e.prepend("Error parsing XML for instance of class TextEntity; ");
throw;
}
}
示例2: assignData
//===========================================
// TextEntity::assignData
//===========================================
void TextEntity::assignData(const XmlNode data) {
try {
if (data.isNull() || data.name() != "TextEntity") return;
XmlNode node = data.nthChild(1);
if (!node.isNull() && node.name() == "font") {
XmlAttribute attr = node.firstAttribute();
if (!attr.isNull() && attr.name() == "ptr") {
long fontId = attr.getLong();
AssetManager assetManager;
pFont_t font = boost::dynamic_pointer_cast<Dodge::Font>(assetManager.getAssetPointer(fontId));
if (!font)
throw XmlException("Bad asset id", __FILE__, __LINE__);
m_font = font;
}
node = node.nextSibling();
}
if (!node.isNull() && node.name() == "textSize") {
m_size = Vec2f(node.firstChild());
node = node.nextSibling();
}
XML_NODE_CHECK(node, text);
setText(node.getString());
}
catch (XmlException& e) {
e.prepend("Error parsing XML for instance of class TextEntity; ");
throw;
}
}
示例3: parseNodeStruct
///////////////////////////////////////////////////////////////////////////////////////////////////
//parse data schema from node
//src data node
//dst schema node
bool XmlSchema::parseNodeStruct(XmlNode* dst, XmlNode* src)
{
assert(dst != NULL);
assert(src != NULL);
NodeIterator nodeIterator;
AttributeIterator attriIterator;
for (XmlAttribute* attribute = src->getFirstAttribute(attriIterator);
attribute != NULL;
attribute = src->getNextAttribute(attriIterator))
{
XmlNode* structure = dst->findChild(attribute->getName());
if (structure == NULL)
{
//first time show up
structure = dst->addChild(attribute->getName());
structure->addAttribute(ATTR_TYPE, guessType(attribute->getString()));
structure->addAttribute(ATTR_ATTRIBUTE, T("true"));
}
}
for (XmlNode* child = src->getFirstChild(nodeIterator);
child != NULL;
child = src->getNextChild(nodeIterator))
{
if (child->getType() != ELEMENT)
{
continue;
}
XmlNode* structure = dst->findChild(child->getName());
if (structure == NULL)
{
//first time show up
bool recursive = false;
const XmlNode* parent = dst;
while (parent != NULL)
{
if (Strcmp(parent->getName(), child->getName()) == 0)
{
recursive = true;
break;
}
parent = parent->getParent();
}
structure = dst->addChild(child->getName());
if (recursive)
{
structure->addAttribute(ATTR_RECURSIVE, T("true"));
}
else if (!child->hasChild() && !child->hasAttribute())
{
//simple type, must have a type attribute
structure->addAttribute(ATTR_TYPE, guessType(child->getString()));
}
}
else if (structure->findAttribute(ATTR_ATTRIBUTE) != NULL)
{
//child and attribute can't have same name
return false;
}
XmlAttribute* multiple = structure->findAttribute(ATTR_MULTIPLE);
if (multiple == NULL || !multiple->getBool())
{
NodeIterator iter;
if (src->findFirstChild(child->getName(), iter) != NULL
&& src->findNextChild(child->getName(), iter) != NULL)
{
if (multiple == NULL)
{
multiple = structure->addAttribute(ATTR_MULTIPLE);
}
multiple->setBool(true);
}
}
if (!structure->findAttribute(ATTR_RECURSIVE) && (child->hasChild() || child->hasAttribute()))
{
parseNodeStruct(structure, child);
}
}
return true;
}
示例4: Asset
//===========================================
// GameSettings::GameSettings
//===========================================
GameSettings::GameSettings(const XmlNode data)
: Asset(internString("GameSettings")) {
try {
XML_NODE_CHECK(data, GameSettings);
XmlNode node = data.firstChild();
XML_NODE_CHECK(node, soundTrack);
musicTrack = gGetWorkingDir() + "/" + node.getString();
node = node.nextSibling();
XML_NODE_CHECK(node, bgColour);
bgColour = Colour(node.firstChild());
node = node.nextSibling();
XML_NODE_CHECK(node, minefieldBoundary);
minefieldBoundary = Range(node.firstChild());
node = node.nextSibling();
XML_NODE_CHECK(node, tileSize);
tileSize = Vec2f(node.firstChild());
node = node.nextSibling();
XML_NODE_CHECK(node, startMenuId);
startMenuId = node.getLong();
node = node.nextSibling();
XML_NODE_CHECK(node, pauseMenuId);
pauseMenuId = node.getLong();
node = node.nextSibling();
XML_NODE_CHECK(node, gameOptionsMenuId);
gameOptionsMenuId = node.getLong();
node = node.nextSibling();
XML_NODE_CHECK(node, playerId);
playerId = node.getLong();
node = node.nextSibling();
XML_NODE_CHECK(node, exitId);
exitId = node.getLong();
node = node.nextSibling();
XML_NODE_CHECK(node, numericTileProtoId);
numericTileProtoId = node.getLong();
node = node.nextSibling();
XML_NODE_CHECK(node, mineProtoId);
mineProtoId = node.getLong();
node = node.nextSibling();
XML_NODE_CHECK(node, soilProtoId);
soilProtoId = node.getLong();
node = node.nextSibling();
XML_NODE_CHECK(node, coinProtoId);
coinProtoId = node.getLong();
node = node.nextSibling();
XML_NODE_CHECK(node, nuggetProtoId);
nuggetProtoId = node.getLong();
node = node.nextSibling();
XML_NODE_CHECK(node, throwableProtoId);
throwableProtoId = node.getLong();
node = node.nextSibling();
XML_NODE_CHECK(node, zombieProtoId);
zombieProtoId = node.getLong();
node = node.nextSibling();
XML_NODE_CHECK(node, timeCounterId);
timeCounterId = node.getLong();
node = node.nextSibling();
XML_NODE_CHECK(node, scoreCounterId);
scoreCounterId = node.getLong();
node = node.nextSibling();
XML_NODE_CHECK(node, txtRestartId);
txtRestartId = node.getLong();
node = node.nextSibling();
XML_NODE_CHECK(node, gameModes);
parseGameModes(node);
}
catch (XmlException& e) {
e.prepend("Error loading game settings; ");
throw;
}
}