本文整理汇总了C++中yaml::Emitter::GetLastError方法的典型用法代码示例。如果您正苦于以下问题:C++ Emitter::GetLastError方法的具体用法?C++ Emitter::GetLastError怎么用?C++ Emitter::GetLastError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yaml::Emitter
的用法示例。
在下文中一共展示了Emitter::GetLastError方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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
}
示例2: eMesh
//.........这里部分代码省略.........
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;
}
}
}