本文整理汇总了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;
}
示例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());
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
示例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());
}
示例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;
}