本文整理汇总了C++中pugi::xml_document::save_file方法的典型用法代码示例。如果您正苦于以下问题:C++ xml_document::save_file方法的具体用法?C++ xml_document::save_file怎么用?C++ xml_document::save_file使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pugi::xml_document
的用法示例。
在下文中一共展示了xml_document::save_file方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: saveXML
static bool saveXML(pugi::xml_document& document, const std::string& outputFile)
{
pugi::xml_node decl = document.prepend_child(pugi::node_declaration);
decl.append_attribute("version").set_value("1.0");
decl.append_attribute("encoding").set_value("utf-8");
if(!document.save_file(outputFile.c_str(), " ", 1U, pugi::encoding_utf8))
{
return false;
}
return true;
}
示例2: InitConfig
int InitConfig(pugi::xml_document& config) {
//check folders, create in dont exist
wstring appDataPath = AppPath();
wstring logPath;
wstring rawCurrentPath;
wstring logDailyPath;
//config
wstring configFile = appDataPath + L"\\etc\\sdr.xml";
//because service runs at windows/System32 folder
//we forced to use absolute path
pugi::xml_parse_result result = config.load_file(configFile.data());
if (result.status != pugi::status_ok) {
return status_config_file_not_found;
}
//first install build directory tree
logPath = L"\\log";
rawCurrentPath = logPath + L"\\current\\";
logDailyPath = logPath + L"\\daily\\";
config.select_single_node(L"/sdr/recording/logs/base").node().attribute(
L"path").set_value(logPath.data());
config.select_single_node(L"/sdr/recording/logs/current").node().attribute(
L"path").set_value(rawCurrentPath.data());
config.select_single_node(L"/sdr/recording/logs/daily").node().attribute(
L"path").set_value(logDailyPath.data());
config.save_file(configFile.data());
logPath = appDataPath + logPath;
rawCurrentPath = appDataPath + rawCurrentPath;
logDailyPath = appDataPath + logDailyPath;
//create config folderst
CreateDirectory(logPath.data(), 0);
if (GetLastError() == ERROR_PATH_NOT_FOUND)
return status_path_not_found;
CreateDirectory(rawCurrentPath.data(), 0);
if (GetLastError() == ERROR_PATH_NOT_FOUND)
return status_path_not_found;
CreateDirectory(logDailyPath.data(), 0);
if (GetLastError() == ERROR_PATH_NOT_FOUND)
return status_path_not_found;
return status_ok;
}