我正在用 C++ 编写一个程序,它是一些基准测试的包装器,其中包含开头的一些设置代码和结尾的 analisys 代码。
我想同时运行两个基准测试。这些的原始命令行是:
/path0/benchmark0 -switch0 -switch1 -switch2
/path1/benchmark1 -arg0 -arg1 -arg2 -arg4
我想把这些放在我的包装器的命令行上:
wrapper -setup_arg0 -setup_arg1 -analysis_arg0 --command0 /path0/benchmark0 -switch0 -switch1 -switch2 --command1 /path1/benchmark1 -arg0 -arg1 -arg2 -arg4
我想在哪里获得两个std::vector<std::string>
s,每个command0
和一个command1
,包含原始命令行。这就是我的做法(使用boost::program_options
):
("command0", po::value<std::vector< std::string> >(&command0)->multitoken(), "command line for thread 0")
("command1", po::value<std::vector< std::string> >(&command1)->multitoken(), "command line for thread 1")
这基本上有效。-
但是,如果基准测试的参数以(就像我见过的大多数程序上的大多数开关一样)开头,则program_options
尝试将它们解析为包装器开关的一部分,因为它不知道它们应该在command0
or下组合在一起command1
。
program_options
支持吗?如果是这样,怎么做?
例子:
在我工作的地方,有一个惯例是通过像这样“终止”多令牌来做到这一点:
wrapper <snip> --command0 /path0/benchmark0 -switch0 -switch1 -switch2 -command0-
--command0
(在本例中,我以.结尾-command0-
。)
我怎么能program_options
像这样处理它?