本文整理汇总了C++中pugi::xml_document::load_file方法的典型用法代码示例。如果您正苦于以下问题:C++ xml_document::load_file方法的具体用法?C++ xml_document::load_file怎么用?C++ xml_document::load_file使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pugi::xml_document
的用法示例。
在下文中一共展示了xml_document::load_file方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _LoadXmlDocment
BOOL SApplication::_LoadXmlDocment( LPCTSTR pszXmlName ,LPCTSTR pszType ,pugi::xml_document & xmlDoc,IResProvider *pResProvider/* = NULL*/)
{
if(!pResProvider)
{
if(IsFileType(pszType))
{
pugi::xml_parse_result result= xmlDoc.load_file(pszXmlName,pugi::parse_default,pugi::encoding_utf8);
SASSERT_FMTW(result,L"parse xml error! xmlName=%s,desc=%s,offset=%d",pszXmlName,result.description(),result.offset);
return result;
}else
{
pResProvider = GetMatchResProvider(pszType,pszXmlName);
}
}
if(!pResProvider) return FALSE;
DWORD dwSize=pResProvider->GetRawBufferSize(pszType,pszXmlName);
if(dwSize==0) return FALSE;
CMyBuffer<char> strXml;
strXml.Allocate(dwSize);
pResProvider->GetRawBuffer(pszType,pszXmlName,strXml,dwSize);
pugi::xml_parse_result result= xmlDoc.load_buffer(strXml,strXml.size(),pugi::parse_default,pugi::encoding_utf8);
SASSERT_FMTW(result,L"parse xml error! xmlName=%s,desc=%s,offset=%d",pszXmlName,result.description(),result.offset);
return result;
}
示例2: open_xml_document
pugi::xml_parse_result configuration::open_xml_document(pugi::xml_document &document, const std::string &filename)
{
std::string search_filename = filename;
pugi::xml_parse_result result;
result = document.load_file(search_filename.c_str());
if(result.status != pugi::status_ok)
{
search_filename = bundlepath().append(search_filename);
result = document.load_file(search_filename.c_str());
}
#if defined(__EDITOR__)
if(result.status == pugi::status_ok)
{
configuration::set_filename(search_filename);
}
#endif
return result;
};
示例3: 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;
}
示例4: idoc_select_input_file
/// @brief Select the input file from the Repository
/// @param the file name (including path) of the IDoc to use as input for any IDoc parameters
/// @return true if the file exists and was selected successfully
IDOCREPLAYDLL_API BOOL idoc_select_input_file(const LPCSTR filePath)
{
g_idocParamInputFilePath.erase();
g_idocParamInputFile.reset();
if (!ensure_valid_license())
{
return FALSE;
}
if (filePath == NULL)
{
lr_error_message("[%s] File path cannot be NULL.", __FUNCTION__);
return FALSE;
}
if (!Utils::FileExists(filePath))
{
lr_error_message("[%s] File \"%s\" is not found.", __FUNCTION__, filePath);
return FALSE;
}
using namespace pugi;
const xml_parse_result parseResult = g_idocParamInputFile.load_file(filePath);
if (!parseResult)
{
lr_error_message("[%s] Invalid input file XML (%s).", __FUNCTION__, parseResult.description());
return FALSE;
}
g_idocParamInputFilePath = filePath;
if (is_trace_log_enabled())
{
lr_output_message("Selected IDoc input file: %s", filePath);
}
return TRUE;
}
示例5: load_preprocess
bool load_preprocess(pugi::xml_document& doc, const char* path)
{
pugi::xml_parse_result result = doc.load_file(path, pugi::parse_default | pugi::parse_pi); // for <?include?>
return result ? preprocess(doc) : false;
}
示例6: LoadConfig
int LoadConfig(const char* filename)
{
m_system_config = m_system_doc.load_file(filename);
cout << "xml loaded: "<<filename<<" -> "<<m_system_config.description()<<endl;
return EXIT_SUCCESS;
}