从新源重新加载 boost::program_options 中的选项值

发布于 2024-08-17 18:33:04 字数 285 浏览 3 评论 0原文

我刚刚开始第一次深入研究 boost::program_options。我非常喜欢它。然而,我试图用它完成的事情似乎并不是它的设计者所考虑的。

我想使用 boost::program_options 来解析命令行选项和配置文件。到目前为止,一切都很好。此外,我希望能够检查更新的设置(例如从新的配置文件中),这些设置可以覆盖变量映射中先前解析的设置。

当然,我可以进行单独的解析并尝试合并两个映射。也许这就是我最终要做的事情。不过,我只是想知道是否有人以前做过类似的事情并提出了一个巧妙的解决方案。

I'm just starting to dig into boost::program_options for the first time. I like it quite a bit. However, what I'm trying to accomplish with it doesn't seem to be something its designers have accounted for.

I want to use boost::program_options to parse both command line options as well as config files. So far so good. Additionally, though, I would like to be able to check for updated settings (say from a new config file) that could override the previously parsed settings in my variables_map.

Granted, I could do a separate parse and try to merge the two maps. Perhaps that's what I'll end up doing. I'm just wondering, though, if anyone has done anything like this before and has come up with a slick solution.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文