首页 \ 问答 \ 使用boost :: options而不给出参数值(Using boost::options without giving argument value)

使用boost :: options而不给出参数值(Using boost::options without giving argument value)

我想使用boost :: program_option运行程序而不给出值(只有标志)。 像那样(这里有一些其他标志):

./main.x -b -f test.txt -r 26

现在你必须写:

./main.x -b 1 -f test.txt -r 26

关键字是(-b)。 我不想写例如1。

样品:

// boost fields
boost::program_options::variables_map fMap;
boost::program_options::options_description fOptions;

// Add some options to fOptions
fOptions.add_options()
("progressBar,b", po::value<int>(), "Progress bar.");
// some other options

boost::program_options::store(po::parse_command_line(argc, argv, fOptions), fMap);

if(fMap.count("progressBar"))
{
  int l_progressBar = fMap["progressBar"].as<int>();
  if(l_progressBar == 1)
  {
    // some staff
  }
}

//I would like to have something like that:
fOptions.add_options()
("progressBar,b", po::value<void>(), "Progress bar.");

if(fMap.count("progressBar"))
{
  // check if flag (-b) was set and do some staff
}

I would like running program using boost::program_option without giving value (only flag). Like that (here are some other flags):

./main.x -b -f test.txt -r 26

Now you have to write:

./main.x -b 1 -f test.txt -r 26

Keyword is (-b). I don`t want to write e.g. 1.

Sample:

// boost fields
boost::program_options::variables_map fMap;
boost::program_options::options_description fOptions;

// Add some options to fOptions
fOptions.add_options()
("progressBar,b", po::value<int>(), "Progress bar.");
// some other options

boost::program_options::store(po::parse_command_line(argc, argv, fOptions), fMap);

if(fMap.count("progressBar"))
{
  int l_progressBar = fMap["progressBar"].as<int>();
  if(l_progressBar == 1)
  {
    // some staff
  }
}

//I would like to have something like that:
fOptions.add_options()
("progressBar,b", po::value<void>(), "Progress bar.");

if(fMap.count("progressBar"))
{
  // check if flag (-b) was set and do some staff
}

原文:https://stackoverflow.com/questions/29197545
更新时间:2023-08-04 16:08

最满意答案

为什么不在类中使用贴标签名称,并使用css标记每个标签

<div expr:class='data:label.name' id='tagcat' title='ds'>

CSS

.label-name { color: your color }

Why not using post label name in class and style each label with css

<div expr:class='data:label.name' id='tagcat' title='ds'>

CSS

.label-name { color: your color }

相关问答

更多
  • 已经dit了! 保持标签的默认CSS和HTML代码完整,而不是更改它,为每个标签执行此操作: a[href^="http://www.YOURSITE.com/search/label/CINEMA"] { color: #colorcode !important; background: #colorcode !important; } 你可以看到我为Cinema添加了整个标签路径。 同样,获取所有标签的完整路径,并为每个标签添加不同的颜色规则 例如,假设另一个标签名称是“电视”。 您可以添加另一个规则 ...
  • 尝试这个: $(document).ready(function() { var paras = $('div.myWords p'); var rand = Math.floor(Math.random() * paras.length); paras.eq(rand).addClass('show'); }); 如果您试图将display: none更改为display: block ,则可以从CSS中省略show class,并仅使用jQuery显示它,如下所示: $(doc ...
  • 这是可能的,但确实需要你进入编辑器并做一些工作。 Blogger使用xml,因此您可以编写条件标记。 因此,在您的所有内容之上,您可以放置条件标记,写下所有HTML,然后将整个博客包装在else语句中。 在特定标记内,您需要包含内容的整个标记,例如:

  • 我想你正在尝试Markup Helper。 转到网站管理员工具>搜索外观>数据荧光笔,您可以在那里添加数据并发布它们。 I think you're trying Markup Helper. Go to webmaster tools > Search Appearance > Data Highlighter, there you can add data and publish them.
  • 以下是您可以在您的网站中使用该模板的步骤 - 登录Blogger信息中心 在仪表板中找到您想要更改模板的博客,然后在下拉菜单选项中选择“模板”。 查看右上角的弹出式窗口中的“备份/恢复”按钮“管理”,然后单击“选择文件”按钮,然后查找提取的文件下载后创建的文件夹。 文件夹可能有.XML文件和.TXT文件或Internet快捷方式,您应该只选择XML文件。 点击上传按钮。 现在上传过程可能会出现在你的屏幕上。 现在该模板将成功显示在您的博客中。 请享用! 欲了解更多细节和一步一步的指示,请点击这里 。 Fin ...
  • 如果您要查找空的Blogspot / Blogger模板,请将其粘贴为模板HTML代码:
  • 为什么不在类中使用贴标签名称,并使用css标记每个标签
    CSS .label-name { color: your color } Why not using post label name in class and style each label with css
    CS ...
  • 如果要获取第一个图像,可以使用模板标记 - 以下示例可能会帮助您。 这只适用于Blogger的Post Loop 使用特色图像的另一种方法是使用机箱中的图像链接并编辑模板以将机箱链接呈现为特色缩略图。 我的博客文章可能 ...
  • ...这里是Blogger.com完全正常的代码。 我在www.tcft.in上添加了这个