Exemplo n.º 1
0
void Settings::ParseInitConfig() {
    QFile launcherFile(DirectoryManager::GetInstance()->GetConfigDir() + InitFile);
    if (!launcherFile.open(QFile::ReadOnly)) {
        Logger::GetInstance()->AddLog(tr("Error read launcher config"));
        return;
    }
    YAML::Parser launcherParser;
    std::istringstream launcherStream(launcherFile.readAll().data());
    launcherParser.Load(launcherStream);
    launcherFile.close();

    YAML::Node launcherSettings;
    if (!launcherParser.GetNextDocument(launcherSettings)) {
        Logger::GetInstance()->AddLog(tr("Error parse launcher settings."));
        return;
    }

    AppsConfig newConfig;
    const YAML::Node* pTimer = launcherSettings.FindValue(CONFIG_UPDATE_INTERVAL);
    if (pTimer) {
        QString interval;
        setString(interval, pTimer);
        m_nUpdateTimer = interval.toInt() * 60 * 1000;
    }
    const YAML::Node* Launcher = launcherSettings.FindValue(LAUNCHER);
    if (Launcher) {
        const YAML::Node* LauncherVer = Launcher->FindValue(LAUNCHER_VER);
        if (LauncherVer)
            setString(newConfig.m_Launcher.m_Version, LauncherVer);
        const YAML::Node* LauncherUrl = Launcher->FindValue(LAUNCHER_UPDATE_URL);
        if (LauncherUrl)
            setString(newConfig.m_Launcher.m_Url, LauncherUrl);
    }

    QFile docFile(DirectoryManager::GetInstance()->GetDocumentsDirectory() + InitFile);
    if(docFile.open(QFile::ReadOnly)) {
        YAML::Parser docParser;
        std::istringstream docStream(docFile.readAll().data());
        docParser.Load(docStream);
        docFile.close();

        YAML::Node docSettings;
        docParser.GetNextDocument(docSettings);

        ParseAppConfig(&docSettings, STABLE, newConfig.m_Stable);
        ParseAppConfig(&docSettings, QA, newConfig.m_Test);
        ParseAppConfig(&docSettings, DEVELOPMENT, newConfig.m_Development);
        ParseAppConfig(&docSettings, DEPENDENCIES, newConfig.m_Dependencies);
    }


    m_Config = newConfig;

}
Exemplo n.º 2
0
bool SkXMLParser::parse(const char doc[], size_t len)
{
    SkMemoryStream docStream(doc, len);
    return this->parse(docStream);
}