本文整理汇总了C++中ArgParse::allowOneCharOptionsToBeCombined方法的典型用法代码示例。如果您正苦于以下问题:C++ ArgParse::allowOneCharOptionsToBeCombined方法的具体用法?C++ ArgParse::allowOneCharOptionsToBeCombined怎么用?C++ ArgParse::allowOneCharOptionsToBeCombined使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArgParse
的用法示例。
在下文中一共展示了ArgParse::allowOneCharOptionsToBeCombined方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, const char** argv)
{
ArgParse::apflag showhelp = false;
ArgParse::apint myint = 0;
ArgParse ap;
ap.allowOneCharOptionsToBeCombined();
ap.usageHeader(ArgParse::apstring("Usage: ") + argv[0] + " [options]");
ap.argFlag("help", "\aprint this help, then exit", &showhelp);
ap.argInt("integer", "=value\aa random integer you can give for no reason",
&myint);
ap.alias("help", "h");
ap.alias("integer", "i");
if (!ap.parse(argc-1, argv+1))
{
Aqsis::log() << ap.errmsg() << std::endl << ap.usagemsg();
return 1;
}
if (ap.leftovers().size() > 0)
{
Aqsis::log() << "Extra crud \"" << ap.leftovers()[0] << "\" on command line";
Aqsis::log() << std::endl << ap.usagemsg();
return 1;
}
if (myint != 0)
{
cout << "Your favorite integer is " << myint << endl;
}
if (showhelp)
{
cout << ap.usagemsg();
return 0;
}
int bad = 0;
cout << "Testing flags and integers... ";
myint = 3;
showhelp = false;
int ok = 0;
const char* av[100];
if (ap.parse(0, av) && !showhelp && myint == 3 && ap.leftovers().size() == 0)
ok++;
av[0] = "-h";
if (ap.parse(1, av) && showhelp && myint == 3 && ap.leftovers().size() == 0)
ok++;
showhelp = false;
av[0] = "--help";
if (ap.parse(1, av) && showhelp && myint == 3 && ap.leftovers().size() == 0)
ok++;
showhelp = false;
av[0] = "--integer";
av[1] = "5";
if (ap.parse(2, av) && !showhelp && myint == 5 && ap.leftovers().size() == 0)
ok++;
myint = 3;
av[0] = "-i";
if (ap.parse(2, av) && !showhelp && myint == 5 && ap.leftovers().size() == 0)
ok++;
myint = 3;
av[2] = "--help";
if (ap.parse(3, av) && showhelp && myint == 5 && ap.leftovers().size() == 0)
ok++;
av[0] = "-h";
av[1] = "-i";
av[2] = "5";
myint = 3;
showhelp = false;
if (ap.parse(3, av) && showhelp && myint == 5 && ap.leftovers().size() == 0)
ok++;
av[0] = "-hi";
av[1] = "5";
myint = 3;
showhelp = false;
if (ap.parse(2, av) && showhelp && myint == 5 && ap.leftovers().size() == 0)
ok++;
av[0] = "-hi=5";
myint = 3;
showhelp = false;
if (ap.parse(1, av) && showhelp && myint == 5 && ap.leftovers().size() == 0)
ok++;
av[0] = "-help";
if (!ap.parse(1, av) &&
ap.errmsg() == "-help: 'e' is an unrecognized option")
ok++;
av[0] = "--integer=5";
//.........这里部分代码省略.........