【发布时间】:2021-01-31 20:36:06
【问题描述】:
我在使用yaml-cpp 解析yaml 文件时遇到问题,我正在使用wxWidgets 制作一个应用程序,并且我正在尝试从yaml 文件中读取帧大小,看起来像,
---
This is the configuration file for the Sample Browser,
feel free to edit this file as needed
...
Window:
SizeW: 1280
SizeH: 720
Media:
Autoplay: false
这是应该处理解析的代码,
int sizeH, sizeW;
try
{
YAML::Node config = YAML::LoadFile("/home/apoorv/repos/cpp-projects/wxWidgets/SampleBrowser/build/config.yaml");
if (!config["Window"])
{
wxLogDebug("Error! Cannot fetch values.");
}
sizeH = config["SizeH"].as<int>();
sizeW = config["SizeW"].as<int>();
}
catch(const YAML::ParserException& ex)
{
std::cout << ex.what() << std::endl;
}
this->SetSize(sizeW, sizeH);
但是当我尝试解析这个文件并设置帧大小 this->SetSize() 时,它会出错说 *** Caught unhandled unknown exception; terminating。
【问题讨论】:
标签: c++ yaml wxwidgets yaml-cpp