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


C++ XMLFile::setRootNode方法代码示例

本文整理汇总了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();
}
开发者ID:RumRogers,项目名称:scummgen,代码行数:39,代码来源:Costume.cpp

示例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();
}
开发者ID:RumRogers,项目名称:scummgen,代码行数:70,代码来源:Object.cpp


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