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


C++ Archive::SetXmlNode方法代码示例

本文整理汇总了C++中Archive::SetXmlNode方法的典型用法代码示例。如果您正苦于以下问题:C++ Archive::SetXmlNode方法的具体用法?C++ Archive::SetXmlNode怎么用?C++ Archive::SetXmlNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Archive的用法示例。


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

示例1: StaticWriteObject

bool XmlUtils::StaticWriteObject(wxXmlNode* root, const wxString& name, SerializedObject* obj)
{
	if(!root)
		return false;

	Archive arch;
	wxXmlNode *child = XmlUtils::FindNodeByName(root, wxT("ArchiveObject"), name);
	if (child) {
		wxXmlNode *n = root;
		n->RemoveChild(child);
		delete child;
	}

	//create new xml node for this object
	child = new wxXmlNode(NULL, wxXML_ELEMENT_NODE, wxT("ArchiveObject"));
	root->AddChild(child);
	
	wxString objectVersion = obj->GetVersion();
	if(objectVersion.IsEmpty() == false)
		child->AddProperty(wxT("Version"), objectVersion);
		
	child->AddProperty(wxT("Name"), name);

	arch.SetXmlNode(child);
	//serialize the object into the archive
	obj->Serialize(arch);
	return true;
}
开发者ID:05storm26,项目名称:codelite,代码行数:28,代码来源:xmlutils.cpp

示例2: Save

bool SessionManager::Save(const wxString& name,
                          SessionEntry& session,
                          const wxString& suffix /*=wxT("")*/,
                          const wxChar* Tag /*=sessionTag*/)
{
    if(!m_doc.GetRoot()) {
        return false;
    }

    if(name.empty()) return false;

    wxXmlNode* child = new wxXmlNode(NULL, wxXML_ELEMENT_NODE, Tag);
    child->AddProperty(wxT("Name"), name);

    Archive arch;
    arch.SetXmlNode(child);
    session.Serialize(arch);

    wxXmlDocument doc;
    doc.SetRoot(child);

    // If we're saving a tabgroup, suffix will be ".tabgroup", not the default ".session"
    const wxFileName& sessionFileName = GetSessionFileName(name, suffix);
    return doc.Save(sessionFileName.GetFullPath());
}
开发者ID:stahta01,项目名称:codelite,代码行数:25,代码来源:sessionmanager.cpp

示例3: GetSession

bool SessionManager::GetSession(const wxString& workspaceFile,
                                SessionEntry& session,
                                const wxString& suffix,
                                const wxChar* Tag)
{
    if(!m_doc.GetRoot()) {
        return false;
    }

    wxFileName sessionFileName = GetSessionFileName(workspaceFile, suffix);
    wxXmlDocument doc;
    
    if(sessionFileName.FileExists()) {
        if(!doc.Load(sessionFileName.GetFullPath()) || !doc.IsOk()) return false;
    } else {
        doc.SetRoot(new wxXmlNode(NULL, wxXML_ELEMENT_NODE, Tag));
    }

    wxXmlNode* const node = doc.GetRoot();
    if(!node || node->GetName() != Tag) return false;

    Archive arch;
    arch.SetXmlNode(node);
    session.DeSerialize(arch);

    return true;
}
开发者ID:stahta01,项目名称:codelite,代码行数:27,代码来源:sessionmanager.cpp

示例4: SetUserData

bool Project::SetUserData(const wxString& name, SerializedObject* obj)
{
    if(!m_doc.IsOk()) {
        return false;
    }

    Archive arch;

    // locate the 'UserData' node
    wxXmlNode *userData = XmlUtils::FindFirstByTagName(m_doc.GetRoot(), wxT("UserData"));
    if( !userData ) {
        userData = new wxXmlNode(m_doc.GetRoot(), wxXML_ELEMENT_NODE, wxT("UserData"));
    }

    // try to find a previous data stored under the same name, if we succeed - remove it
    wxXmlNode *dataNode = XmlUtils::FindNodeByName(userData, wxT("Data"), name);
    if(dataNode) {
        // remove old node
        userData->RemoveChild(dataNode);
        delete dataNode;
    }

    // create a new node and set the userData node as the parent
    dataNode = new wxXmlNode(userData, wxXML_ELEMENT_NODE, wxT("Data"));
    dataNode->AddProperty(wxT("Name"), name);

    // serialize the data
    arch.SetXmlNode(dataNode);
    obj->Serialize(arch);
    return SaveXmlFile();
}
开发者ID:Hmaal,项目名称:codelite,代码行数:31,代码来源:project.cpp

示例5: ReadObject

bool EditorConfig::ReadObject(const wxString &name, SerializedObject *obj)
{
	//find the object node in the xml file
	wxXmlNode *node = XmlUtils::FindNodeByName(m_doc->GetRoot(), wxT("ArchiveObject"), name);
	if(node){
		Archive arch;
		arch.SetXmlNode(node);
		obj->DeSerialize(arch);
		return true;
	}
	return false;
}
开发者ID:BackupTheBerlios,项目名称:codelite-svn,代码行数:12,代码来源:editor_config.cpp

示例6: GetUserData

bool Project::GetUserData(const wxString& name, SerializedObject* obj)
{
    if(!m_doc.IsOk()) {
        return false;
    }

    Archive arch;
    wxXmlNode *userData = XmlUtils::FindFirstByTagName(m_doc.GetRoot(), wxT("UserData"));
    if(userData) {
        wxXmlNode *dataNode = XmlUtils::FindNodeByName(userData, wxT("Data"), name);
        if(dataNode) {
            arch.SetXmlNode(dataNode);
            obj->DeSerialize(arch);
            return true;
        }
    }
    return false;
}
开发者ID:Hmaal,项目名称:codelite,代码行数:18,代码来源:project.cpp

示例7: WriteObject

bool EditorConfig::WriteObject(const wxString &name, SerializedObject *obj)
{
	Archive arch;
	
	wxXmlNode *child = XmlUtils::FindNodeByName(m_doc->GetRoot(), wxT("ArchiveObject"), name);
	if(child){
		wxXmlNode *n = m_doc->GetRoot();
		n->RemoveChild(child);
		delete child;
	} // if(child)

	//create new xml node for this object
	child = new wxXmlNode(NULL, wxXML_ELEMENT_NODE, wxT("ArchiveObject"));
	m_doc->GetRoot()->AddChild(child);
	child->AddProperty(wxT("Name"), name);

	arch.SetXmlNode(child);
	//serialize the object into the archive
	obj->Serialize(arch);
	//save the archive
	return m_doc->Save(m_fileName.GetFullPath());
}
开发者ID:BackupTheBerlios,项目名称:codelite-svn,代码行数:22,代码来源:editor_config.cpp

示例8: StaticReadObject

bool XmlUtils::StaticReadObject(wxXmlNode* root, const wxString& name, SerializedObject* obj)
{
	//find the object node in the xml file
	
	wxXmlNode *node = XmlUtils::FindNodeByName(root, wxT("ArchiveObject"), name);
	if (node) {
		
		// Check to see if we need a version check
		wxString objectVersion = obj->GetVersion();
		if(objectVersion.IsEmpty() == false) {
			if(node->GetPropVal(wxT("Version"), wxT("")) != objectVersion) {
				return false;
			}
		}
		
		Archive arch;
		arch.SetXmlNode(node);
		obj->DeSerialize(arch);
		return true;
	}
	return false;
}
开发者ID:05storm26,项目名称:codelite,代码行数:22,代码来源:xmlutils.cpp


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