当前位置: 首页>>代码示例>>C++>>正文


C++ Emitter::SetIndent方法代码示例

本文整理汇总了C++中yaml::Emitter::SetIndent方法的典型用法代码示例。如果您正苦于以下问题:C++ Emitter::SetIndent方法的具体用法?C++ Emitter::SetIndent怎么用?C++ Emitter::SetIndent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yaml::Emitter的用法示例。


在下文中一共展示了Emitter::SetIndent方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: WriteMinimalList

// 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();
}
开发者ID:silentdark,项目名称:loot,代码行数:33,代码来源:api_database.cpp

示例2: c_error

// 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;
}
开发者ID:Eclipse06,项目名称:loot,代码行数:35,代码来源:api.cpp

示例3: GenerateDefaultSettingsFile

    //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();
    }
开发者ID:dbb,项目名称:loot,代码行数:32,代码来源:generators.cpp

示例4: save

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();
}
开发者ID:silentdark,项目名称:loot,代码行数:10,代码来源:loot_settings.cpp

示例5: Save

    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();
    }
开发者ID:FTWahid,项目名称:loot,代码行数:13,代码来源:metadata_list.cpp

示例6: SimpleGlobalSettings

		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]";
		}
开发者ID:Airstriker,项目名称:viewer,代码行数:14,代码来源:emittertests.cpp

示例7: main

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;
}
开发者ID:WaveBlocks,项目名称:libwaveblocks,代码行数:46,代码来源:test_yaml_eigen.cpp

示例8: saveBlueprint

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;
}
开发者ID:rmmanseau,项目名称:terra,代码行数:45,代码来源:terrariumeditor.cpp

示例9: main

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;
}
开发者ID:Paneb-FR,项目名称:boss-code,代码行数:40,代码来源:converter.cpp

示例10: c_error

// 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;
}
开发者ID:FTWahid,项目名称:loot,代码行数:43,代码来源:api.cpp

示例11: SaveSettings

    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();
        }
    }
开发者ID:Mookzs,项目名称:loot,代码行数:22,代码来源:loot_state.cpp

示例12: emitDefaultSettings

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();
}
开发者ID:gitter-badger,项目名称:Kournal,代码行数:24,代码来源:SettingsHandler.cpp


注:本文中的yaml::Emitter::SetIndent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。