本文整理汇总了C++中yaml::Emitter类的典型用法代码示例。如果您正苦于以下问题:C++ Emitter类的具体用法?C++ Emitter怎么用?C++ Emitter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Emitter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1:
std::string cfg::node::to_string() const
{
YAML::Emitter out;
cfg::encode(out, *this);
return {out.c_str(), out.size()};
}
开发者ID:cjpeterson,项目名称:rpcs3,代码行数:7,代码来源:Config.cpp
示例2: save_to_file
bool ParamManager::save_to_file(std::string filename)
{
// build YAML document
YAML::Emitter yaml;
yaml << YAML::BeginSeq;
std::map<std::string, Param>::iterator it;
for (it = params_.begin(); it != params_.end(); it++)
{
yaml << YAML::Flow;
yaml << YAML::BeginMap;
yaml << YAML::Key << "name" << YAML::Value << it->second.getName();
yaml << YAML::Key << "type" << YAML::Value << (int) it->second.getType();
yaml << YAML::Key << "value" << YAML::Value << it->second.getValue();
yaml << YAML::EndMap;
}
yaml << YAML::EndSeq;
// write to file
try
{
std::ofstream fout;
fout.open(filename.c_str());
fout << yaml.c_str();
fout.close();
}
catch (...)
{
return false;
}
return true;
}
开发者ID:byu-magicc,项目名称:fcu_io,代码行数:32,代码来源:param_manager.cpp
示例3:
void GenericVectorMessage::InstancedImplementation::decode(const YAML::Node& node)
{
YAML::Emitter emitter;
emitter << node;
std::cout << "vector instance: decode " << emitter.c_str() << std::endl;
value = node["values"].as<std::vector<TokenData::Ptr> >();
}
开发者ID:cogsys-tuebingen,项目名称:csapex,代码行数:7,代码来源:generic_vector_message.cpp
示例4: runProgram
void runProgram(Options opt) {
std::vector<string> peer_strs = opt.peer_strings;
bool simulation = opt.simulation;
std::string log_level = opt.log_level;
std::string log_path = opt.json_path;
std::string result_var = opt.result_var;
std::string result_path = opt.result_path;
std::vector<std::string> configurations;
for (auto p: peer_strs) {
if (p.size() > 0 && p[0] != '{') {
for (auto d: YAML::LoadAllFromFile(p)) {
YAML::Emitter out;
out << d;
configurations.push_back(std::string {out.c_str()});
}
} else {
configurations.push_back(p);
}
}
typedef std::map<Address, shared_ptr<__k3_context>> ctxt_map;
typedef shared_ptr<Engine> e_ptr;
std::list<tuple<e_ptr, ctxt_map>> engines;
shared_ptr<MessageQueues> queues = make_shared<MessageQueues>();
list<Address> peers;
for (auto& s: configurations) {
ctxt_map contexts;
e_ptr engine = make_shared<Engine>();
auto gc = make_shared<context>(*engine);
gc->__patch(s);
gc->initDecls(unit_t {});
contexts[gc->me] = gc;
queues->addQueue(gc->me);
peers.push_back(gc->me);
SystemEnvironment se = defaultEnvironment(getAddrs(contexts));
engine->configure(simulation, se, make_shared<DefaultMessageCodec>(), log_level, log_path, result_var, result_path, queues);
processRoles(contexts);
auto t = tuple<e_ptr, ctxt_map>(engine, contexts);
engines.push_back(t);
}
using boost::thread;
using boost::thread_group;
auto l = std::list<shared_ptr<thread>>();
for (auto& t : engines) {
auto engine = get<0>(t);
auto contexts = get<1>(t);
shared_ptr<thread> thread = engine->forkEngine(make_shared<virtualizing_message_processor>(contexts));
l.push_back(thread);
}
// Block until completion
for (auto th : l) {
th->join();
}
}
开发者ID:yliu120,项目名称:K3,代码行数:60,代码来源:Run.hpp
示例5: save
/**
* Saves new battle data to a YAML file.
* @param filename YAML filename.
*/
void NewBattleState::save(const std::string &filename)
{
std::string s = Options::getMasterUserFolder() + filename + ".cfg";
std::ofstream sav(s.c_str());
if (!sav)
{
Log(LOG_WARNING) << "Failed to save " << filename << ".cfg";
return;
}
YAML::Emitter out;
YAML::Node node;
node["mission"] = _cbxMission->getSelected();
node["craft"] = _cbxCraft->getSelected();
node["darkness"] = _slrDarkness->getValue();
node["terrain"] = _cbxTerrain->getSelected();
node["alienRace"] = _cbxAlienRace->getSelected();
node["difficulty"] = _cbxDifficulty->getSelected();
node["alienTech"] = _slrAlienTech->getValue();
node["base"] = _game->getSavedGame()->getBases()->front()->save();
out << node;
sav << out.c_str();
sav.close();
if (!sav)
{
Log(LOG_WARNING) << "Failed to save " << filename << ".cfg";
}
}
开发者ID:MeridianOXC,项目名称:OpenXcom,代码行数:33,代码来源:NewBattleState.cpp
示例6: keyPressed
//--------------------------------------------------------------
void testApp::keyPressed(int key){
if(key == 'r'){
parseYAML();
}
if(key == 's'){
ofColor color = ofColor(ofRandom(255),ofRandom(255),ofRandom(255));
ofPoint p1 = ofPoint(ofRandom(3,10), ofRandom(3,10));
ofPoint p2 = ofPoint(ofRandom(20,50), ofRandom(20,50));
int s1 = ofRandom(10);
int s2 = ofRandom(20);
YAML::Emitter out;
out << YAML::BeginMap;
out << YAML::Key << "name";
out << YAML::Value << "Greg Borenstein";
out << YAML::Key << "color";
out << YAML::Value << color;
out << YAML::Key << "point1";
out << YAML::Value << p1;
out << YAML::Key << "point2";
out << YAML::Value << p2;
out << YAML::Key << "size1";
out << YAML::Value << s1;
out << YAML::Key << "size2";
out << YAML::Value << s2;
out << YAML::EndMap;
int l = strlen(out.c_str());
ofBuffer yamlData;
yamlData.set((const char *)out.c_str(), l);
bool fileWritten = ofBufferToFile(ofToDataPath("my_points.yml"), yamlData);
}
}
开发者ID:atduskgreg,项目名称:ofxYAML,代码行数:36,代码来源:testApp.cpp
示例7:
/**
* @return A string representation of the full YAML output
*/
std::string &string () {
TRACE ("Emitting parameters");
YAML::Emitter out;
out << *this;
yaml_data = out.c_str ();
return yaml_data;
}
开发者ID:brownjustinmichael,项目名称:pisces,代码行数:10,代码来源:parameters.hpp
示例8: os
TrackExtractor *defaultTE(void) {
MaggotTrackExtractor *te = new MaggotTrackExtractor();
te->background_blur_sigma = 0;
te->background_resampleInterval = 200;
te->blurThresholdIm_sigma = 0;
te->endFrame = -1;
te->startFrame = 0;
te->analysisRectangle = cvRect (0,0,-1,-1);
te->extension = string(".mmf");
te->fnm = _frame_none;
te->imstacklength = 0;
te->logVerbosity = verb_debug;
te->maxArea = 2000;
te->minArea = 5;
te->maxExtractDist = 15;
te->nBackgroundFrames = 5;
te->overallThreshold = 30;
te->padding = 0;
te->showExtraction = true;
te->startFrame = 0;
te->winSize = 50;
te->setMaxAngle(1.57);
YAML::Emitter out;
ofstream os(default_tename);
te->toYAML(out);
cout << out.c_str();
os << out.c_str();
return te;
}
开发者ID:samuellab,项目名称:MAGATAnalyzer-Track-Extraction,代码行数:30,代码来源:main.cpp
示例9: update_info
// update_info writes m_next_id and m_free_ids to "info.yaml"
void update_info()
{
YAML::Emitter out;
out << YAML::BeginMap
<< YAML::Key << "next"
<< YAML::Value << m_next_id;
if(!m_free_ids.empty())
{
out << YAML::Key << "free"
<< YAML::Value << YAML::BeginSeq;
for(auto it = m_free_ids.begin(); it != m_free_ids.end(); ++it)
{
out << *it;
}
out << YAML::EndSeq;
}
out << YAML::EndMap;
fstream file;
file.open(m_foldername + "/info.yaml", ios_base::out);
if(file.is_open())
{
file << out.c_str();
file.close();
}
}
开发者ID:Echocage,项目名称:Astron,代码行数:27,代码来源:YAMLDatabase.cpp
示例10:
const std::string CFGManager::writeConfigToString(const char *group,
const unsigned char saveOption) const {
YAML::Emitter out;
mapStringToParam::const_iterator iter;
string lastGroup = "";
CFGParam *param = NULL;
out << YAML::BeginMap;
mutexCFGParams.lock();
for(iter = cfgParamsByString.begin(); iter != cfgParamsByString.end(); ++iter) {
param = iter->second;
if(!group || param->getGroup() == string(group)) {
if( (param->getOption() & saveOption) || group) {
if(lastGroup != param->getGroup()) {
if(lastGroup != "") {
out << YAML::EndSeq;
}
lastGroup = param->getGroup();
out << YAML::Key << lastGroup;
out << YAML::Value << YAML::BeginSeq;
}
param->writeToYAML(out);
}
}
} //for
out << YAML::EndSeq;
out << YAML::EndMap;
mutexCFGParams.unlock();
return out.c_str();
}
开发者ID:EwaldHartmann,项目名称:mars,代码行数:33,代码来源:CFGManager.cpp
示例11: write_yaml_object
bool write_yaml_object(doid_t do_id, const Class* dcc, const ObjectData &dbo)
{
// Build object as YAMl output
YAML::Emitter out;
out << YAML::BeginMap
<< YAML::Key << "id"
<< YAML::Value << do_id
<< YAML::Key << "class"
<< YAML::Value << dcc->get_name()
<< YAML::Key << "fields"
<< YAML::Value << YAML::BeginMap;
for(auto it = dbo.fields.begin(); it != dbo.fields.end(); ++it)
{
write_yaml_field(out, it->first, it->second);
}
out << YAML::EndMap
<< YAML::EndMap;
// Print YAML to file
fstream file;
file.open(filename(do_id), ios_base::out);
if(file.is_open())
{
file << out.c_str();
file.close();
return true;
}
return false;
}
开发者ID:Echocage,项目名称:Astron,代码行数:29,代码来源:YAMLDatabase.cpp
示例12: saveYML
void DepthObstacleGrid::saveYML(const std::string &filename){
YAML::Emitter out;
std::ofstream ofstr(filename.c_str());
out << YAML::BeginSeq;
for(std::vector<GridElement>::iterator it = grid.begin(); it != grid.end(); it++){
if( (!std::isnan(it->depth_variance)) && (!std::isnan(it->depth) ) ){
out << YAML::BeginMap;
out << YAML::Key << "position";
std::vector<double> vals;
vals.push_back(it->pos.x());
vals.push_back(it->pos.y());
vals.push_back(it->depth);
out << YAML::Value << YAML::Flow << vals;
out << YAML::EndMap;
}
}
out << YAML::EndSeq;
ofstr << out.c_str();
}
开发者ID:auv-avalon,项目名称:uw_localization,代码行数:26,代码来源:depth_obstacle_grid.cpp
示例13: main
int main(int argc, char **argv)
{
if (argc != 4 && argc != 5)
{
std::cout << "Usage: rosrun giskard extract_expression <start_link> <end_link> <urdf> (optional <output_file>)" << std::endl;
return 0;
}
std::string start_link = argv[1];
std::string end_link = argv[2];
std::string urdf_path = argv[3];
YAML::Node yaml = giskard::ExpressionExtractor::extract(start_link, end_link, urdf_path);
YAML::Emitter out;
out << yaml;
if (argc == 5)
{
std::ofstream output_file;
output_file.open(argv[4]);
if (!output_file.is_open())
throw giskard::WriteError(argv[4]);
output_file << out.c_str();
output_file.close();
}
else
{
std::cout << out.c_str() << std::endl;
}
return 0;
}
开发者ID:gaya-,项目名称:giskard,代码行数:30,代码来源:extract_expression.cpp
示例14: 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
示例15: 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
示例16: 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
示例17: Desc
const string Desc() {
YAML::Emitter emitter;
emitter << _yaml_root;
if (! emitter.good())
THROW("Unexpected");
return emitter.c_str();
}
开发者ID:hobinyoon,项目名称:crawl-twitter,代码行数:7,代码来源:conf.cpp
示例18: EmitEmptyNode
TEST EmitEmptyNode()
{
YAML::Node node;
YAML::Emitter emitter;
emitter << node;
YAML_ASSERT(std::string(emitter.c_str()) == "");
return true;
}
开发者ID:egocarib,项目名称:yaml-cpp,代码行数:8,代码来源:nodetests.cpp
示例19: toYamlStream
void ConfigMap::toYamlStream(std::ostream &out) const {
YAML::Emitter emitter;
dumpConfigMapToYaml(emitter, *this);
if(!emitter.good()) {
fprintf(stderr, "ERROR: ConfigMap::toYamlStream failed!\n");
return;
}
out << emitter.c_str() << endl;
}
开发者ID:bergatt,项目名称:mars,代码行数:9,代码来源:ConfigData.cpp
示例20: write_to_file
void Document::write_to_file(const std::string& filename)
{
YAML::Emitter emitter;
emitter << *this;
std::ofstream fout(filename.c_str());
assert(fout.is_open());
if(fout.is_open())
fout << emitter.c_str();
}
开发者ID:ctenbrink,项目名称:trek_families,代码行数:10,代码来源:document.cpp
注:本文中的yaml::Emitter类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论