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


C++ XMLFile类代码示例

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


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

示例1: saveFile

/// Save account information to a file
void GameEconomicGameClient::SaveConfiguration(Configuration &configuration)
{
    /// Get Resource
    ResourceCache * cache = GetSubsystem<ResourceCache>();
    FileSystem * fileSystem = GetSubsystem<FileSystem>();

    String configFileName;

    /// Set directory and path for network file
    configFileName.Append(fileSystem->GetProgramDir().CString());
    configFileName.Append("");
    configFileName.Append("Configuration.xml");


    /// Check if the account file information exist
    if(fileSystem->FileExists(configFileName.CString()))
    {
        fileSystem->Delete(configFileName.CString());
    }

    cout << "It got here "<<endl;

    File saveFile(context_, configFileName.CString(), FILE_WRITE);

    XMLFile * preferencefileconfig  = new XMLFile(context_);

    XMLElement configElem = preferencefileconfig   -> CreateRoot("Configuration");
    XMLElement GameModeConfigurationElement = configElem.CreateChild("GameModeConfiguration");
    XMLElement VideoConfigurationElement= configElem.CreateChild("VideoConfiguration");

    /// Set true false
    if(configuration.GameModeForceTablet==true)
    {
        GameModeConfigurationElement.SetAttribute("GameModeForceTablet", "true");
    }
    else
    {
        GameModeConfigurationElement.SetAttribute("GameModeForceTablet", "false");
    }

    /// Convert video bloom to float
    String VideoBloomParamValue1String(configuration.VideoBloomParam1);
    String VideoBloomParamValue2String(configuration.VideoBloomParam2);

    /// Copy values testing
    VideoConfigurationElement.SetAttribute("BloomParam1",VideoBloomParamValue1String);
    VideoConfigurationElement.SetAttribute("BloomParam2",VideoBloomParamValue2String);

    preferencefileconfig->Save(saveFile);

    return;
}
开发者ID:vivienneanthony,项目名称:Urho3D-gameeconomic,代码行数:53,代码来源:GameEconomicGameClient.cpp

示例2: URHO3D_LOGERROR

bool XMLFile::BeginLoad(Deserializer& source)
{
    unsigned dataSize = source.GetSize();
    if (!dataSize && !source.GetName().Empty())
    {
        URHO3D_LOGERROR("Zero sized XML data in " + source.GetName());
        return false;
    }

    SharedArrayPtr<char> buffer(new char[dataSize]);
    if (source.Read(buffer.Get(), dataSize) != dataSize)
        return false;

    if (!document_->load_buffer(buffer.Get(), dataSize))
    {
        URHO3D_LOGERROR("Could not parse XML data from " + source.GetName());
        document_->reset();
        return false;
    }

    XMLElement rootElem = GetRoot();
    String inherit = rootElem.GetAttribute("inherit");
    if (!inherit.Empty())
    {
        // The existence of this attribute indicates this is an RFC 5261 patch file
        ResourceCache* cache = GetSubsystem<ResourceCache>();
        // If being async loaded, GetResource() is not safe, so use GetTempResource() instead
        XMLFile* inheritedXMLFile = GetAsyncLoadState() == ASYNC_DONE ? cache->GetResource<XMLFile>(inherit) :
            cache->GetTempResource<XMLFile>(inherit);
        if (!inheritedXMLFile)
        {
            URHO3D_LOGERRORF("Could not find inherited XML file: %s", inherit.CString());
            return false;
        }

        // Patch this XMLFile and leave the original inherited XMLFile as it is
        UniquePtr<pugi::xml_document> patchDocument(document_.Detach());
        document_ = new pugi::xml_document();
        document_->reset(*inheritedXMLFile->document_);
        Patch(rootElem);

        // Store resource dependencies so we know when to reload/repatch when the inherited resource changes
        cache->StoreResourceDependency(this, inherit);

        // Approximate patched data size
        dataSize += inheritedXMLFile->GetMemoryUse();
    }

    // Note: this probably does not reflect internal data structure size accurately
    SetMemoryUse(dataSize);
    return true;
}
开发者ID:tungsteen,项目名称:Urho3D,代码行数:52,代码来源:XMLFile.cpp

示例3: SubscribeToEvent

void RogueSkill4::Start()
{
	skillSprite_ = (Sprite*)(main_->mySceneNode_->GetComponent<HUD>()->
			hud_->GetChild("skill4", false)->GetChild(0)->GetChild(0));
	SubscribeToEvent(E_HUDBUTT, HANDLER(RogueSkill4, HandleHudButt));
	SetUpdateEventMask(USE_UPDATE);

	XMLFile* xmlFile = main_->cache_->GetResource<XMLFile>("Objects/terriesDagger1.xml");
	arrow_ = node_->GetScene()->InstantiateXML(xmlFile->GetRoot(),
			Vector3::ZERO, Quaternion::IDENTITY, LOCAL);

	arrow_->SetEnabled(false);
}
开发者ID:practicing01,项目名称:Terries,代码行数:13,代码来源:RogueSkill4.cpp

示例4: SubscribeToEvent

void WizardSkill0::Start()
{
	skillSprite_ = (Sprite*)(main_->mySceneNode_->GetComponent<HUD>()->
			hud_->GetChild("skill0", false)->GetChild(0)->GetChild(0));
	SubscribeToEvent(E_HUDBUTT, HANDLER(WizardSkill0, HandleHudButt));
	SetUpdateEventMask(USE_UPDATE);

	XMLFile* xmlFile = main_->cache_->GetResource<XMLFile>("Objects/terriesMeteor.xml");
	meteor_ = node_->GetScene()->InstantiateXML(xmlFile->GetRoot(),
			Vector3::ZERO, Quaternion::IDENTITY, LOCAL);

	meteor_->SetEnabled(false);
	SubscribeToEvent(E_NODEREMOVED, HANDLER(WizardSkill0, HandleNodeRemoved));
}
开发者ID:practicing01,项目名称:Terries,代码行数:14,代码来源:WizardSkill0.cpp

示例5: SubscribeToEvent

void WizardSkill4::Start()
{
	skillSprite_ = (Sprite*)(main_->mySceneNode_->GetComponent<HUD>()->
			hud_->GetChild("skill4", false)->GetChild(0)->GetChild(0));
	SubscribeToEvent(E_HUDBUTT, HANDLER(WizardSkill4, HandleHudButt));
	SetUpdateEventMask(USE_UPDATE);

	XMLFile* xmlFile = main_->cache_->GetResource<XMLFile>("Objects/terriesOrb.xml");
	orb_ = node_->GetScene()->InstantiateXML(xmlFile->GetRoot(),
			Vector3::ZERO, Quaternion::IDENTITY, LOCAL);

	orb_->SetPosition(node_->GetScene()->GetChild("tent")->GetPosition() + (Vector3::UP * 2.0f));

	SubscribeToEvent(orb_, E_NODECOLLISIONSTART, HANDLER(WizardSkill4, HandleNodeCollisionStart));

	//orb_->SetEnabled(false);
}
开发者ID:practicing01,项目名称:Terries,代码行数:17,代码来源:WizardSkill4.cpp

示例6: GetScreenJoystickPatchString

//------------------------------------------------------------------------------------------------------------------------------------------------------
void BaseApplication::InitTouchInput()
{
    touchEnabled_ = true;

    ResourceCache* cache = GetSubsystem<ResourceCache>();
    Input* input = GetSubsystem<Input>();
    XMLFile* layout = cache->GetResource<XMLFile>("UI/ScreenJoystick_Samples.xml");
    const String& patchString = GetScreenJoystickPatchString();
    if (!patchString.Empty())
    {
        // Patch the screen joystick layout further on demand
        SharedPtr<XMLFile> patchFile(new XMLFile(context_));
        if (patchFile->FromString(patchString))
            layout->Patch(patchFile);
    }
    screenJoystickIndex_ = input->AddScreenJoystick(layout, cache->GetResource<XMLFile>("UI/DefaultStyle.xml"));
    input->SetScreenJoystickVisible(screenJoystickSettingsIndex_, true);
}
开发者ID:Sasha7b9,项目名称:Platformer,代码行数:19,代码来源:BaseApplication.cpp

示例7: assemblegffexolocstr

bool assemblegffexolocstr(XMLFile &xml, GFFFile &gff, uint32 n)
{
	int pr, lang=0;
	std::string lbl;
	ExoLocString exo;
	uint64 tmp;

	while((pr = xml.parse()) >= 0)
	{
		switch(pr)
		{
			case 0:
				if(rsubstr(xml.section, 6) == ".label") lbl = xml.value;
				if(rsubstr(xml.section, 7) == ".strref")
				{
					sscanf(xml.value.c_str(), S_UINT64, &tmp);
					exo.stringref = (uint32) tmp;
				}
				if(rsubstr(xml.section, 16) == ".substr.language")
				{
					if((lang = getpos(langs, LANGS, xml.value)) == -1)
						return printxmlerr(xml, "Invalid language");
				}
				if(rsubstr(xml.section, 7) == ".substr")
					exo.str[lang] = unquotestr(xml.value);
				break;
			case 1:
				if(rsubstr(xml.section, 7) != ".substr")
					return printxmlerr(xml, "Invalid tag");
				break;
			case 2:
				if(rsubstr(xml.value, 10) == ".exolocstr")
				{
					if(gff.writeExoLocString(n, lbl, exo))
						return printxmlerr(xml, gff.getStrError());
					return true;
				}
				break;
		}
	}
	if(pr != -6) return printxmlerr(xml, xml.getStrError());
	printxmlerr(xml, "Unexpected end of file");
	return false;
}
开发者ID:EffWun,项目名称:xoreos-tools,代码行数:44,代码来源:assemble.cpp

示例8: QueryMasterServer

void GameMenu::QueryMasterServer()
{
	if (!masterServerConnected_)
	{
		XMLFile* xmlFile = main_->cache_->GetResource<XMLFile>("Objects/serverInfo.xml");
		Node* serverInfo = main_->scene_->InstantiateXML(xmlFile->GetRoot(), Vector3::ZERO, Quaternion(), LOCAL);

		masterServerIP_ = serverInfo->GetVar("masterServerIP").GetString();

		main_->scene_->RemoveChild(serverInfo);

		if (masterServerIP_ == "127.0.0.1")
		{
			return;
		}

		masterServerConnected_ = network_->Connect(masterServerIP_, 9001, 0);
	}
}
开发者ID:practicing01,项目名称:Urho3DTemplate,代码行数:19,代码来源:GameMenu.cpp

示例9: ReplaceExtension

void Sound::LoadParameters()
{
    ResourceCache* cache = GetSubsystem<ResourceCache>();
    String xmlName = ReplaceExtension(GetName(), ".xml");
    
    if (!cache->Exists(xmlName))
        return;
    
    XMLFile* file = cache->GetResource<XMLFile>(xmlName);
    if (!file)
        return;
    
    XMLElement rootElem = file->GetRoot();
    XMLElement paramElem = rootElem.GetChild();
    
    while (paramElem)
    {
        String name = paramElem.GetName();
        
        if (name == "format" && !compressed_)
        {
            if (paramElem.HasAttribute("frequency"))
                frequency_ = paramElem.GetInt("frequency");
            if (paramElem.HasAttribute("sixteenbit"))
                sixteenBit_ = paramElem.GetBool("sixteenbit");
            if (paramElem.HasAttribute("16bit"))
                sixteenBit_ = paramElem.GetBool("16bit");
            if (paramElem.HasAttribute("stereo"))
                stereo_ = paramElem.GetBool("stereo");
        }
        
        if (name == "loop")
        {
            if (paramElem.HasAttribute("enable"))
                SetLooped(paramElem.GetBool("enable"));
            if (paramElem.HasAttribute("start") && paramElem.HasAttribute("end"))
                SetLoop(paramElem.GetInt("start"), paramElem.GetInt("end"));
        }
        
        paramElem = paramElem.GetNext();
    }
}
开发者ID:CarloMaker,项目名称:Urho3D,代码行数:42,代码来源:Sound.cpp

示例10: assembleerfdesc

bool assembleerfdesc(XMLFile &xml, ERFFile &erf)
{
	int pr, lang=0;
	ExoLocString exo;
	uint64 tmp;

	while((pr = xml.parse()) >= 0)
	{
		switch(pr)
		{
			case 0:
				if(rsubstr(xml.section, 7) == ".strref")
				{
					sscanf(xml.value.c_str(), S_UINT64, &tmp);
					exo.stringref = (uint32) tmp;
				}
				if(rsubstr(xml.section, 16) == ".substr.language")
				{
					if((lang = getpos(langs, LANGS, xml.value)) == -1)
						return printxmlerr(xml, "Invalid language");
				}
				if(rsubstr(xml.section, 7) == ".substr")
					exo.str[lang] = unquotestr(xml.value);
				break;
			case 1:
				if(rsubstr(xml.section, 7) != ".substr")
					return printxmlerr(xml, "Invalid tag");
				break;
			case 2:
				if(rsubstr(xml.value, 12) == ".description")
				{
					erf.desc = exo;
					return true;
				}
				break;
		}
	}
	if(pr != -6) return printxmlerr(xml, xml.getStrError());
	printxmlerr(xml, "Unexpected end of file");
	return false;
}
开发者ID:EffWun,项目名称:xoreos-tools,代码行数:41,代码来源:assemble.cpp

示例11: MoveCamera

void SceneView3D::HandleUpdate(StringHash eventType, VariantMap& eventData)
{

    // Timestep parameter is same no matter what event is being listened to
    float timeStep = eventData[Update::P_TIMESTEP].GetFloat();

    if (MouseInView())
        MoveCamera(timeStep);

    QueueUpdate();

    if (preloadResourceScene_.NotNull())
    {
        if (preloadResourceScene_->GetAsyncProgress() == 1.0f)
        {
            ResourceCache* cache = GetSubsystem<ResourceCache>();
            XMLFile* xml = cache->GetResource<XMLFile>(dragAssetGUID_);

            if (dragNode_.NotNull())
            {
                dragNode_->LoadXML(xml->GetRoot());
                UpdateDragNode(0, 0);

                AnimationController* controller = dragNode_->GetComponent<AnimationController>();
                if (controller)
                {
                    controller->PlayExclusive("Idle", 0, true);

                    dragNode_->GetScene()->SetUpdateEnabled(true);
                }
            }

            preloadResourceScene_ = 0;
            dragAssetGUID_ = "";

        }
    }

}
开发者ID:WorldofOpenDev,项目名称:AtomicGameEngine,代码行数:39,代码来源:SceneView3D.cpp

示例12: 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

示例13: load

void Costume::load(string dirPath)
{
	Log::write(LOG_INFO, "Costume\n");
	Log::indent();

	XMLFile xmlFile;
	xmlFile.open(dirPath + XML_FILE_NAME);
	XMLNode *rootNode = xmlFile.getRootNode();

	_name = rootNode->getChild("name")->getStringContent();
	Log::write(LOG_INFO, "name: %s\n", _name.c_str());

	_mirror = rootNode->getChild("mirror")->getBooleanContent();
	Log::write(LOG_INFO, "mirror: %d\n", _mirror);

	int i = 0;
	XMLNode *child;
	while ((child = rootNode->getChild("anim", i++)) != NULL)
	{
		Anim *anim = new Anim();
		anim->load(child);
		_anims.push_back(anim);
	}

	i = 0;
	while ((child = rootNode->getChild("frame", i++)) != NULL)
	{
		Frame *frame = new Frame();
		frame->load(child, dirPath);
		_frames.push_back(frame);
	}

	_paletteData = new PaletteData();
	_paletteData->load(dirPath);

	Log::unIndent();
}
开发者ID:RumRogers,项目名称:scummgen,代码行数:37,代码来源:Costume.cpp

示例14: loadBodyParts

    void ResourceManager::loadBodyParts(const std::string &filename)
    {
        XMLFile file;
        int size;
        char *data = loadFile(filename, size);

		if (data && file.parse(data))
		{
		    // set size
		    file.setElement("size");
		    mBodyWidth = file.readInt("size", "width");
		    mBodyHeight = file.readInt("size", "height");

            // set defaults
            file.setElement("default");
		    mDefaultBody = file.readInt("default", "body");
            mDefaultFemale = file.readInt("default", "female");
		    mDefaultHair = file.readInt("default", "hair");
		    mDefaultChest = file.readInt("default", "chest");
		    mDefaultLegs = file.readInt("default", "legs");
		    mDefaultFeet = file.readInt("default", "feet");

            // add all the body parts
            file.setElement("body");
            do
            {
                file.setSubElement("image");
                int id = file.readInt("body", "id");
                std::string icon = file.readString("body", "icon");
                int part = file.readInt("body", "part");
                std::string colour = file.readString("body", "colour");

                Texture *iconTex = NULL;
                if (icon != "")
                {
                    if (getDataPath(icon).find(".zip") == std::string::npos)
                    {
                        iconTex = graphicsEngine->loadTexture(getDataPath(icon));
                    }
                    else
                    {
                        int iconBufSize = 0;
                        char *buffer = loadFile(icon, iconBufSize);
                        iconTex = graphicsEngine->loadTexture(icon, buffer, iconBufSize);
                        free(buffer);
                    }

                    if (iconTex == NULL)
                    {
                        logger->logError("Unable to load icon: " + icon);
                    }
                }

                BodyPart *body = new BodyPart(id, part, iconTex);

                do
                {
                    int dir = -1;
                    // check if img is in a content update
                    std::string img = file.readString("image", "file");
                    std::string dirstr = file.readString("image", "dir");

                    if (dirstr == "SE")
                        dir = DIRECTION_SOUTHEAST;
                    else if (dirstr == "SW")
                        dir = DIRECTION_SOUTHWEST;
                    else if (dirstr == "NE")
                        dir = DIRECTION_NORTHEAST;
                    else if (dirstr == "NW")
                        dir = DIRECTION_NORTHWEST;

                    std::string path = getDataPath(img);
                    size_t found = path.find(".zip");
                    if (found == std::string::npos)
                    {
                        body->addTexture(dir, path);
                    }
                    else
                    {
                        int imgBufSize = 0;
                        char *buffer = loadFile(img, imgBufSize);
                        body->addTexture(dir, img, buffer, imgBufSize);
                        free(buffer);
                    }

                } while (file.nextSubElement("image"));

                mBodyParts.push_back(body);
                file.clear("image");

            } while (file.nextElement("body"));
		}
    }
开发者ID:suprafun,项目名称:smalltowns,代码行数:93,代码来源:resourcemanager.cpp

示例15: loadAnimations

    void ResourceManager::loadAnimations(const std::string &filename)
    {
        XMLFile file;
        int size;
        bool loaded = false;
        char *data = loadFile(filename, size);

		if (data && file.parse(data))
		{
		    // add all the animations
		    file.setElement("animation");
            do
            {
                file.setSubElement("body");

                int id = file.readInt("animation", "id");
                std::string name = file.readString("animation", "name");
                int frames = file.readInt("animation", "frames");
                int width = file.readInt("animation", "width");
                int height = file.readInt("animation", "height");

                // get list of animations for each body part
                std::list<BeingAnimation*> animList;
                do
                {
                    std::string img = file.readString("body", "file");
                    int part = file.readInt("body", "part");

                    std::stringstream texName;
                    texName << part << name;

                    // check if animation is in content update
                    if (getDataPath(img).find(".zip") == std::string::npos)
                    {
                        img = getDataPath(img);
                        loaded = graphicsEngine->loadTextureSet(texName.str(), img, width, height);
                    }
                    else
                    {
                        int imgBufSize = 0;
                        char *buffer = loadFile(img, imgBufSize);
                        loaded = graphicsEngine->loadTextureSet(texName.str(), buffer, imgBufSize, width, height);
                        free(buffer);
                    }

                    // load in all the frames of animation
                    if (loaded)
                    {
                        BeingAnimation *anim = new BeingAnimation(id, part);
                        for (int i = 1; i <= frames; ++i)
                        {
                            std::stringstream str;
                            str << texName.str() << i;
                            anim->addTexture(graphicsEngine->getTexture(str.str()));
                        }
                        animList.push_back(anim);
                    }
                } while (file.nextSubElement("body"));

                mAnimations.insert(std::pair<std::string, std::list<BeingAnimation*> >(name, animList));
                file.clear("body");

            } while (file.nextElement("animation"));
        }
    }
开发者ID:suprafun,项目名称:smalltowns,代码行数:65,代码来源:resourcemanager.cpp


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