我正在尝试使用 boost::property_tree 从 XML 配置文件中读取某些配置的无限时间持续时间(其他配置为非无限时间持续时间)。此代码适用于非无限持续时间。
我的代码读取的值:
boost::property_tree::ptree property_tree;
boost::property_tree::read_xml(filepath, property_tree);
auto config = property_tree.get_child("Config");
std::chrono::seconds my_duration_value = std::chrono::seconds(config.get<unsigned int>("MyDurationField"));
我希望能够在配置文件中执行以下操作:
<Config>
<MyDurationField>inf</MyDurationField>
</Config>
有没有一种方法可以做到这一点,既适用于无限时间,也适用于非无限时间?提前致谢。