本文整理汇总了C++中yaml::Emitter::good方法的典型用法代码示例。如果您正苦于以下问题:C++ Emitter::good方法的具体用法?C++ Emitter::good怎么用?C++ Emitter::good使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yaml::Emitter
的用法示例。
在下文中一共展示了Emitter::good方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Desc
const string Desc() {
YAML::Emitter emitter;
emitter << _yaml_root;
if (! emitter.good())
THROW("Unexpected");
return emitter.c_str();
}
示例2: 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;
}
示例3: dumpConfigVectorToYaml
static void dumpConfigVectorToYaml(YAML::Emitter &emitter,
const ConfigVector &vec) {
if(vec.size() > 1) {
emitter << YAML::BeginSeq;
}
if(!(emitter.good() && 1)) {
std::string s = vec.getParentName();
fprintf(stderr, "problem with ConfigVector for: %s\n",
s.c_str());
}
assert(emitter.good() && 1);
for(unsigned int i = 0; i < vec.size(); ++i) {
dumpConfigItemToYaml(emitter, vec[i]);
}
if(vec.size() > 1) {
emitter << YAML::EndSeq;
}
}
示例4: dumpConfigMapToYaml
static void dumpConfigMapToYaml(YAML::Emitter &emitter,
const ConfigMap &configMap) {
emitter << YAML::BeginMap;
ConfigMap::const_iterator it;
for(it = configMap.begin(); it != configMap.end(); ++it) {
emitter << YAML::Key << it->first;
if(!(emitter.good())) {
fprintf(stderr, "problem with ConfigMap for: %s\n", it->first.c_str());
}
emitter << YAML::Value;
dumpConfigVectorToYaml(emitter, it->second);
}
emitter << YAML::EndMap;
}
示例5: save
void NetConfigManager::save()
{
assert(netplay.myPlayerName);
std::ofstream config(GetHomeDirectory() + "servers.yml");
if (!config.is_open()) {
printf("[net][error] Could not save network settings\n");
return;
}
YAML::Emitter content;
content << YAML::BeginMap;
content << YAML::Key << "player_name";
content << YAML::Value << netplay.myPlayerName;
assert(content.good());
content << YAML::Key << "servers";
content << YAML::Value << YAML::BeginSeq;
// Remove `(none)`
if (netplay.savedServers.size() == 1) {
if (netplay.savedServers[0].hostname.compare("(none)") == 0)
netplay.savedServers.clear();
}
for (unsigned i = 0; i < netplay.savedServers.size(); i++)
content << netplay.savedServers[i].hostname;
content << YAML::EndSeq;
content << YAML::EndMap;
assert(content.good());
config << content.c_str();
config.close();
}
示例6: operator
void fail_policy::operator()(const nyan::fail &fail_arg) const
{
#if NYAN_CAN_HAS_YAML
YAML::Emitter y;
y << fail_arg;
if (y.good())
{
std::cerr << "# unexpected fail is unexpected; the yaml speaks:\n";
std::cerr << y.c_str();
}
else
{
std::cerr << "# unexpected fail is unexpected. std::fail::what() says, \""
<< fail_arg.what() << ".\"\n";
std::cerr
<< "# unfortunately, i failed to provide details; the yaml emitter says, \""
<< y.GetLastError() << "\"\n";
}
#else
std::cerr << "# unexpected fail is unexpected. std::fail::what() says, \""
<< fail_arg.what()
<< ".\"\n# if you'd like more details, please consider compiling libnyan with yaml support enabled.\n";
#endif
}
示例7: eMesh
//.........这里部分代码省略.........
iSubDimOrd = 0u;
}
NodeIdsOnSubDimEntityType& nodeIds_onSE_0 = *( nodeRegistry.getNewNodesOnSubDimEntity(element_local, needed_entity_rank.first, iSubDimOrd));
stk_classic::mesh::Entity* node_0 = eMesh.get_bulk_data()->get_entity(stk_classic::mesh::fem::FEMMetaData::NODE_RANK, nodeIds_onSE_0[0]->identifier());
// should be the same node on each proc
std::cout << "P[" << p_rank << "] nodeId_0 = " << nodeIds_onSE_0 << " node_0= " << node_0 << std::endl;
// end_demo
#if STK_ADAPT_HAVE_YAML_CPP
if (p_size == 1)
{
if (1) {
YAML::Emitter out;
out << YAML::Anchor("NodeRegistry::map");
out << YAML::BeginMap;
out << YAML::Key << YAML::BeginSeq << 1 << 2 << YAML::EndSeq << YAML::Value << YAML::BeginSeq << -1 << -2 << YAML::EndSeq;
out << YAML::Key << 1;
out << YAML::Value << 2;
out << YAML::Key << 3;
out << YAML::Value << 4;
out << YAML::EndMap;
//std::cout << "out=\n" << out.c_str() << "\n=out" << std::endl;
std::string expected_result = "&NodeRegistry::map\n?\n - 1\n - 2\n:\n - -1\n - -2\n1: 2\n3: 4";
//std::cout << "out2=\n" << expected_result << std::endl;
STKUNIT_EXPECT_TRUE(expected_result == std::string(out.c_str()));
}
YAML::Emitter yaml;
std::cout << "\nnodeRegistry.serialize_write(yaml)" << std::endl;
SerializeNodeRegistry::serialize_write(nodeRegistry, yaml, 0);
//std::cout << yaml.c_str() << std::endl;
if (!yaml.good())
{
std::cout << "Emitter error: " << yaml.good() << " " <<yaml.GetLastError() << "\n";
STKUNIT_EXPECT_TRUE(false);
}
std::ofstream file1("out.yaml");
file1 << yaml.c_str();
file1.close();
std::ifstream file2("out.yaml");
YAML::Parser parser(file2);
YAML::Node doc;
try {
while(parser.GetNextDocument(doc)) {
std::cout << "\n read doc.Type() = " << doc.Type() << " doc.Tag()= " << doc.Tag() << " doc.size= " << doc.size() << std::endl;
if (doc.Type() == YAML::NodeType::Map)
{
for(YAML::Iterator it=doc.begin();it!=doc.end();++it) {
int key, value;
std::cout << "read it.first().Type() = " << it.first().Type() << " it.first().Tag()= " << it.first().Tag() << std::endl;
std::cout << "read it.second().Type() = " << it.second().Type() << " it.second().Tag()= " << it.second().Tag() << std::endl;
const YAML::Node& keySeq = it.first();
for(YAML::Iterator itk=keySeq.begin();itk!=keySeq.end();++itk) {
*itk >> key;
std::cout << "read key= " << key << std::endl;
}
const YAML::Node& valSeq = it.second();
for(YAML::Iterator itv=valSeq.begin();itv!=valSeq.end();++itv) {
*itv >> value;
std::cout << "read value= " << value << std::endl;
}