本文整理汇总了C++中XNode::GetChildAttr方法的典型用法代码示例。如果您正苦于以下问题:C++ XNode::GetChildAttr方法的具体用法?C++ XNode::GetChildAttr怎么用?C++ XNode::GetChildAttr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XNode
的用法示例。
在下文中一共展示了XNode::GetChildAttr方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void
BackupExecuter::_RestoreDataDirectory(shared_ptr<Backup> pBackup, XNode *pBackupNode)
{
XNode *pBackupInfoNode = pBackupNode->GetChild(_T("BackupInformation"));
// Create the path to the zip file.
String sBackupFile = pBackup->GetBackupFile();
String sPath = sBackupFile.Mid(0, sBackupFile.ReverseFind(_T("\\")));
String sDirContainingDataFiles;
String sDataFileFormat = pBackupInfoNode->GetChildAttr(_T("DataFiles"), _T("Format"))->value;
String sExtractedFilesDirectory;
if (sDataFileFormat.CompareNoCase(_T("7Z")) == 0)
{
// Create the path to the directory that will contain the extracted files.
// This directory is temporary and will be removed when we're done.
sExtractedFilesDirectory = Utilities::GetUniqueTempDirectory();
// Extract the files to this directory.
Compression oComp;
oComp.Uncompress(sBackupFile, sExtractedFilesDirectory);
// The data files in the zip file are stored in
// a directory called DataBackup.
sDirContainingDataFiles = sExtractedFilesDirectory + "\\DataBackup";
}
else
{
// Fetch the path to the data files.
String sFolderName = pBackupInfoNode->GetChildAttr(_T("DataFiles"), _T("FolderName"))->value;
sDirContainingDataFiles = sPath + "\\" + sFolderName;
}
// Delete all directories from the data directory
// so that we're sure that we're doing a clean restore
String sDataDirectory = IniFileSettings::Instance()->GetDataDirectory();
std::set<String> vecExcludes;
FileUtilities::DeleteFilesInDirectory(sDataDirectory);
FileUtilities::DeleteDirectoriesInDirectory(sDataDirectory, vecExcludes);
String errorMessage;
FileUtilities::CopyDirectory(sDirContainingDataFiles, sDataDirectory, errorMessage);
if (sDataFileFormat.CompareNoCase(_T("7z")) == 0)
{
// The temporary directory we created while
// unzipping should be deleted now.
FileUtilities::DeleteDirectory(sExtractedFilesDirectory);
}
}
示例2:
shared_ptr<Backup>
BackupManager::LoadBackup(const String &sZipFile) const
{
LOG_DEBUG("BackupManager::LoadBackup");
shared_ptr<Backup> pResult = shared_ptr<Backup>(new Backup);
// First uncompress our specification file.
String sTempDir = IniFileSettings::Instance()->GetTempDirectory();
String sXMLFile = sTempDir + "\\hMailServerBackup.xml";
FileUtilities::DeleteFile(sXMLFile);
Compression oComp;
oComp.Uncompress(sZipFile, sTempDir, "hMailServerBackup.xml");
// Load the XML document
String sXMLBuffer = FileUtilities::ReadCompleteTextFile(sXMLFile);
XDoc oXMLDocument;
oXMLDocument.Load(sXMLBuffer);
XNode *pBackupNode = oXMLDocument.GetChild(_T("Backup"));
if (!pBackupNode)
{
LOG_DEBUG("BackupManager::~LoadBackup - E1");
return pResult;
}
int iMode = _ttoi(pBackupNode->GetChildAttr(_T("BackupInformation"), _T("Mode"))->value);
pResult->SetBackupFile(sZipFile);
pResult->SetContains(iMode);
// Delete the XML file we temporarly created
FileUtilities::DeleteFile(sXMLFile);
LOG_DEBUG("BackupManager::~LoadBackup - E2");
return pResult;
}