本文整理汇总了C++中XMLFile::setRootNode方法的典型用法代码示例。如果您正苦于以下问题:C++ XMLFile::setRootNode方法的具体用法?C++ XMLFile::setRootNode怎么用?C++ XMLFile::setRootNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLFile
的用法示例。
在下文中一共展示了XMLFile::setRootNode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: save
void Costume::save(string dirPath)
{
Log::write(LOG_INFO, "Costume\n");
Log::indent();
if (!IO::createDirectory(dirPath))
Log::write(LOG_ERROR, "Could not create directory \"%s\" !\n", dirPath.c_str());
XMLFile xmlFile;
XMLNode *rootNode = new XMLNode("costume");
xmlFile.setRootNode(rootNode);
rootNode->addChild(new XMLNode("name", _name));
Log::write(LOG_INFO, "name: %s\n", _name.c_str());
rootNode->addChild(new XMLNode("mirror", _mirror));
Log::write(LOG_INFO, "mirror: %d\n", _mirror);
for (int i = 0; i < _anims.size(); i++)
{
XMLNode *child = new XMLNode("anim");
rootNode->addChild(child);
_anims[i]->save(child);
}
for (int i = 0; i < _frames.size(); i++)
{
XMLNode *child = new XMLNode("frame");
rootNode->addChild(child);
_frames[i]->save(child, dirPath);
}
_paletteData->save(dirPath);
if (!xmlFile.save(dirPath + XML_FILE_NAME))
Log::write(LOG_ERROR, "Couldn't save costume to the specified directory !\n");
Log::unIndent();
}
示例2: save
void Object::save(string dirPath)
{
Log::write(LOG_INFO, "Object\n");
Log::indent();
if (!IO::createDirectory(dirPath))
Log::write(LOG_ERROR, "Could not create directory \"%s\" !\n", dirPath.c_str());
XMLFile xmlFile;
XMLNode *rootNode = new XMLNode("object");
xmlFile.setRootNode(rootNode);
rootNode->addChild(new XMLNode("name", _name));
Log::write(LOG_INFO, "name: %s\n", _name.c_str());
rootNode->addChild(new XMLNode("displayName", _displayName));
Log::write(LOG_INFO, "displayName: %s\n", _displayName.c_str());
// Change hotspots from relative to absolute positions when saving them
rootNode->addChild(new XMLNode("hotspotX", _hotspotX + _x));
Log::write(LOG_INFO, "hotspotX: %d\n", _hotspotX + _y);
rootNode->addChild(new XMLNode("hotspotY", _hotspotY));
Log::write(LOG_INFO, "hotspotY: %d\n", _hotspotY);
rootNode->addChild(new XMLNode("x", _x));
Log::write(LOG_INFO, "x: %u\n", _x);
rootNode->addChild(new XMLNode("y", _y));
Log::write(LOG_INFO, "y: %u\n", _y);
rootNode->addChild(new XMLNode("width", _width));
Log::write(LOG_INFO, "width: %u\n", _width);
rootNode->addChild(new XMLNode("height", _height));
Log::write(LOG_INFO, "height: %u\n", _height);
string actorDir;
switch (_actorDir)
{
case ACTOR_DIR_WEST:
actorDir = "west";
break;
case ACTOR_DIR_EAST:
actorDir = "east";
break;
case ACTOR_DIR_SOUTH:
actorDir = "south";
break;
case ACTOR_DIR_NORTH:
actorDir = "north";
break;
}
rootNode->addChild(new XMLNode("actorDir", actorDir));
Log::write(LOG_INFO, "actorDir: %s (%u)\n", actorDir.c_str(), _actorDir);
for (int i = 0; i < _images.size(); i++)
{
_images[i]->save(dirPath + _images[i]->getName() + '/');
rootNode->addChild(new XMLNode("image", _images[i]->getName()));
}
if (!_images.empty())
_paletteData->save(dirPath);
if (!xmlFile.save(dirPath + XML_FILE_NAME))
Log::write(LOG_ERROR, "Couldn't save object to the specified directory !\n");
Log::unIndent();
}