示例#1
0
文件: SApp.cpp 项目: FuckGOV/soui
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
0
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
0
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
0
/// @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
0
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
0
	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;
	}