コード例 #1
0
ファイル: api_database.cpp プロジェクト: silentdark/loot
// Writes a minimal masterlist that only contains mods that have Bash Tag suggestions,
// and/or dirty messages, plus the Tag suggestions and/or messages themselves and their
// conditions, in order to create the Wrye Bash taglist. outputFile is the path to use
// for output. If outputFile already exists, it will only be overwritten if overwrite is true.
void ApiDatabase::WriteMinimalList(const std::string& outputFile, const bool overwrite) {
  if (!boost::filesystem::exists(boost::filesystem::path(outputFile).parent_path()))
    throw std::invalid_argument("Output directory does not exist.");

  if (boost::filesystem::exists(outputFile) && !overwrite)
    throw FileAccessError("Output file exists but overwrite is not set to true.");

  Masterlist temp = game_.GetMasterlist();
  std::unordered_set<PluginMetadata> minimalPlugins;
  for (const auto &plugin : temp.Plugins()) {
    PluginMetadata p(plugin.Name());
    p.Tags(plugin.Tags());
    p.DirtyInfo(plugin.DirtyInfo());
    minimalPlugins.insert(p);
  }

  YAML::Emitter yout;
  yout.SetIndent(2);
  yout << YAML::BeginMap
    << YAML::Key << "plugins" << YAML::Value << minimalPlugins
    << YAML::EndMap;

  boost::filesystem::path p(outputFile);
  boost::filesystem::ofstream out(p);
  if (out.fail())
    throw FileAccessError("Couldn't open output file.");
  out << yout.c_str();
  out.close();
}
コード例 #2
0
ファイル: api.cpp プロジェクト: Eclipse06/loot
// Writes a minimal masterlist that only contains mods that have Bash Tag suggestions,
// and/or dirty messages, plus the Tag suggestions and/or messages themselves and their
// conditions, in order to create the Wrye Bash taglist. outputFile is the path to use
// for output. If outputFile already exists, it will only be overwritten if overwrite is true.
LOOT_API unsigned int loot_write_minimal_list (loot_db db, const char * const outputFile, const bool overwrite) {
    if (db == NULL || outputFile == NULL)
        return c_error(loot_error_invalid_args, "Null pointer passed.");

    if (boost::filesystem::exists(outputFile) && !overwrite)
        return c_error(loot_error_invalid_args, "Output file exists but overwrite is not set to true.");

    std::list<loot::Plugin> temp = db->metadata;
    for (std::list<loot::Plugin>::iterator it=temp.begin(), endIt=temp.end(); it != endIt; ++it) {
        loot::Plugin p(it->Name());
        p.Tags(it->Tags());
        p.DirtyInfo(it->DirtyInfo());

        *it = p;
    }

    YAML::Emitter yout;
    yout.SetIndent(2);
    yout << YAML::BeginMap
         << YAML::Key << "plugins" << YAML::Value << temp
         << YAML::EndMap;

    boost::filesystem::path p(outputFile);
    loot::ofstream out(p);
    if (out.fail())
        return c_error(loot_error_invalid_args, "Couldn't open output file");
    out << yout.c_str();
    out.close();

    return loot_ok;
}
コード例 #3
0
ファイル: generators.cpp プロジェクト: dbb/loot
    //Default settings file generation.
    void GenerateDefaultSettingsFile(const std::string& file) {

        BOOST_LOG_TRIVIAL(info) << "Generating default settings file.";

        YAML::Node root;
        std::vector<Game> games;

        root["Language"] = "eng";
        root["Game"] = "auto";
        root["Last Game"] = "auto";
        root["Debug Verbosity"] = 0;
        root["Update Masterlist"] = true;

        games.push_back(Game(Game::tes4));
        games.push_back(Game(Game::tes5));
        games.push_back(Game(Game::fo3));
        games.push_back(Game(Game::fonv));
        games.push_back(Game(Game::tes4, "Nehrim").SetDetails("Nehrim - At Fate's Edge", "Nehrim.esm", "https://github.com/loot-developers/loot-oblivion.git", "gh-pages", "", "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Nehrim - At Fate's Edge_is1"));

        root["Games"] = games;

        //Save settings.
        YAML::Emitter yout;
        yout.SetIndent(2);
        yout << root;

        boost::filesystem::path p(file);
        loot::ofstream out(p);
        out << yout.c_str();
        out.close();
    }
コード例 #4
0
ファイル: loot_settings.cpp プロジェクト: silentdark/loot
void LootSettings::save(const boost::filesystem::path& file) {
  lock_guard<recursive_mutex> guard(mutex_);

  YAML::Emitter yout;
  yout.SetIndent(2);
  yout << toYaml();

  boost::filesystem::ofstream out(file);
  out << yout.c_str();
}
コード例 #5
0
ファイル: metadata_list.cpp プロジェクト: FTWahid/loot
    void MetadataList::Save(const boost::filesystem::path& filepath) {
        BOOST_LOG_TRIVIAL(trace) << "Saving metadata list to: " << filepath;
        YAML::Emitter yout;
        yout.SetIndent(2);
        yout << YAML::BeginMap
            << YAML::Key << "plugins" << YAML::Value << Plugins()
            << YAML::Key << "globals" << YAML::Value << messages
            << YAML::EndMap;

        boost::filesystem::ofstream uout(filepath);
        uout << yout.c_str();
        uout.close();
    }
コード例 #6
0
ファイル: emittertests.cpp プロジェクト: Airstriker/viewer
		void SimpleGlobalSettings(YAML::Emitter& out, std::string& desiredOutput)
		{
			out.SetIndent(4);
			out.SetMapFormat(YAML::LongKey);

			out << YAML::BeginSeq;
			out << YAML::BeginMap;
			out << YAML::Key << "key 1" << YAML::Value << "value 1";
			out << YAML::Key << "key 2" << YAML::Value << YAML::Flow << YAML::BeginSeq << "a" << "b" << "c" << YAML::EndSeq;
			out << YAML::EndMap;
			out << YAML::EndSeq;
			
			desiredOutput = "-   ? key 1\n    : value 1\n    ? key 2\n    : [a, b, c]";
		}
コード例 #7
0
int main(int argc, char* argv[])
{
    (void) argc;
    (void) argv;


    // Create a new yaml document
    std::cout << "Creating a yaml file:" << std::endl;

    RMatrix<1,1> s;
    s << 42;

    RMatrix<3,1> col;
    col << 1,2,3;

    RMatrix<1,3> row;
    row << 1,2,3;

    RMatrix<2,2> R;
    R << 1, 2,
         3, 4;

    CMatrix<3,3> C;
    C << 1.1,            1.2,                1.3,
         complex_t(1,1), complex_t(1.2,3.4), 0,
         3.1,            3.2,                3.3;

    YAML::Node root;

    root["scalar"] = s;
    root["row"] = row;
    root["col"] = col;
    root["R"] = R;
    root["C"] = C;

    YAML::Emitter out;
    out.SetIndent(4);
    //out.SetMapFormat(YAML::Flow);
    out.SetSeqFormat(YAML::Flow);
    out << root;

    std::cout << out.c_str() << std::endl;

    std::ofstream fout("matrices.yaml");
    fout << out.c_str() << std::endl;
}
コード例 #8
0
ファイル: terrariumeditor.cpp プロジェクト: rmmanseau/terra
void TerrariumEditor::saveBlueprint(const std::string& blueprintName)
{
    YAML::Emitter out;
    out.SetIndent(4);
    out << YAML::BeginMap
        << YAML::Key << "width" << YAML::Value << blueprint.width
        << YAML::Key << "height" << YAML::Value << blueprint.height 
        << YAML::Key << "tile_size" << YAML::Value << blueprint.tileSize 
        << YAML::Key << "sprite_sheet" << YAML::Value << blueprint.spriteSheetPath 
        << YAML::Key << "dirt_texture" << YAML::Value << blueprint.dirtTexturePath
        << YAML::Key << "dirt_color" << YAML::Value
            << YAML::Flow << YAML::BeginSeq
            << (int)blueprint.dirtColor.r
            << (int)blueprint.dirtColor.g
            << (int)blueprint.dirtColor.b
            << YAML::EndSeq
        << YAML::Key << "initial_entities" << YAML::Value
            << YAML::BeginSeq;

    for (auto itr = blueprint.entities.begin();
         itr != blueprint.entities.end(); ++itr)
    {
        Vec2i pos = (itr->first);
        if (pos.x >= 0 && pos.x < blueprint.width &&
            pos.y >= 0 && pos.y < blueprint.height)
        {
            out << YAML::Flow << YAML::BeginMap
                << YAML::Key << "type"
                << YAML::Value << glbl::constants.eName(itr->second)
                << YAML::Key << "pos"
                << YAML::Value
                    << YAML::Flow << YAML::BeginSeq
                    << pos.x
                    << pos.y
                    << YAML::EndSeq
                << YAML::EndMap;
        }
    }

    out << YAML::EndSeq << YAML::EndMap;

    glbl::assets.writeTerrariumBlueprint(blueprintName, out);

    std::cout << "Terrarium saved!" << std::endl;
}
コード例 #9
0
ファイル: converter.cpp プロジェクト: Paneb-FR/boss-code
int main(int argc, char * argv[]) {
    string in_str, out_str;
    if (argc < 3) {
        in_str = "masterlist.txt";
        out_str = "masterlist.yaml";
    } else {
        in_str = argv[1];
        out_str = argv[2];
    }

    boost::log::core::get()->set_logging_enabled(false);

    // Set up emitter.
    YAML::Emitter yout;
    yout.SetIndent(2);

    list<boss::Plugin> test_plugins;
    list<boss::Message> globalMessages;

    //Parse the v2 masterlist and output it as a YAML masterlist.
    try {
        Loadv2Masterlist(boost::filesystem::path(in_str), test_plugins, globalMessages);
    } catch (exception& e) {
        cout << "An error was encountered during masterlist parsing. Message: " << e.what() << endl;
        return 1;
    }

    yout << YAML::BeginMap
        << YAML::Key << "globals" << YAML::Value << globalMessages
        << YAML::Key << "plugins" << YAML::Value << test_plugins
        << YAML::EndMap;

    // Save output.
    boost::filesystem::path out_path(out_str);
    boss::ofstream out(out_path);
    out << yout.c_str();
    out.close();

    return 0;
}
コード例 #10
0
ファイル: api.cpp プロジェクト: FTWahid/loot
// Writes a minimal masterlist that only contains mods that have Bash Tag suggestions,
// and/or dirty messages, plus the Tag suggestions and/or messages themselves and their
// conditions, in order to create the Wrye Bash taglist. outputFile is the path to use
// for output. If outputFile already exists, it will only be overwritten if overwrite is true.
LOOT_API unsigned int loot_write_minimal_list(loot_db * const db, const char * const outputFile, const bool overwrite) {
    if (db == nullptr || outputFile == nullptr)
        return c_error(loot_error_invalid_args, "Null pointer passed.");

    if (!boost::filesystem::exists(boost::filesystem::path(outputFile).parent_path()))
        return c_error(loot_error_invalid_args, "Output directory does not exist.");

    if (boost::filesystem::exists(outputFile) && !overwrite)
        return c_error(loot_error_file_write_fail, "Output file exists but overwrite is not set to true.");

    loot::Masterlist temp = db->GetMasterlist();
    std::unordered_set<loot::PluginMetadata> minimalPlugins;
    for (const auto &plugin : temp.Plugins()) {
        loot::PluginMetadata p(plugin.Name());
        p.Tags(plugin.Tags());
        p.DirtyInfo(plugin.DirtyInfo());
        minimalPlugins.insert(p);
    }

    YAML::Emitter yout;
    yout.SetIndent(2);
    yout << YAML::BeginMap
        << YAML::Key << "plugins" << YAML::Value << minimalPlugins
        << YAML::EndMap;

    boost::filesystem::path p(outputFile);
    try {
        boost::filesystem::ofstream out(p);
        if (out.fail())
            return c_error(loot_error_file_write_fail, "Couldn't open output file.");
        out << yout.c_str();
        out.close();
    }
    catch (std::exception& e) {
        return c_error(loot_error_file_write_fail, e.what());
    }

    return loot_ok;
}
コード例 #11
0
ファイル: loot_state.cpp プロジェクト: Mookzs/loot
    void LootState::SaveSettings() {
        // Acquire the lock for the scope of this method.
        base::AutoLock lock_scope(_lock);

        _settings["lastGame"] = _currentGame->FolderName();
        _settings["lastVersion"] = to_string(g_version_major) + "." + to_string(g_version_minor) + "." + to_string(g_version_patch);

        //Save settings.
        try {
            BOOST_LOG_TRIVIAL(debug) << "Saving LOOT settings.";
            YAML::Emitter yout;
            yout.SetIndent(2);
            yout << _settings;

            loot::ofstream out(loot::g_path_settings);
            out << yout.c_str();
            out.close();
        }
        catch (std::exception &e) {
            BOOST_LOG_TRIVIAL(error) << "Failed to save LOOT's settings. Error: " << e.what();
        }
    }
コード例 #12
0
void SettingsHandler::emitDefaultSettings()
{
    QFileInfo settingsFileInfo(settingsFile->fileName());
    settingsFileInfo.absoluteDir().mkpath(QStringLiteral("."));

    YAML::Emitter out;
    out.SetIndent(4);
    out.SetMapFormat(YAML::Flow);

    out << YAML::BeginMap
            << YAML::Key << "general"
            << YAML::Value << YAML::BeginMap
                << YAML::Key << "userInfo"
                << YAML::Value << YAML::BeginMap
                    << YAML::Key << "userName"
                    << YAML::Value << tr("User", "Default user name in settings")
                << YAML::EndMap
            << YAML::EndMap
        << YAML::EndMap;

    settingsFile->open(QFile::WriteOnly | QFile::Text);
    settingsFile->write(out.c_str(), out.size());
    settingsFile->close();
}