DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
A Flexible UNIX Command Line Processing Facility - Args(C++)

`+' options

The `-' character preceding an option or option block is called the option ``flag''. Some program wish to treat the `+' character as a flag as well. Usually the `+' version of an option has the opposite meaning of the `-' version:

       cc -c foo.c  // compile-only
       cc +c foo.c  // do not compile-only (the default)

Sometimes, however, the `+' and `-' versions have completely different meanings:

       cc -p foo.c  // profiling
       cc +p foo.c  // do not allow anachronistic constructs

Treatment of `+' as an option flag is specified as follows:

       Args args(argc, argv, "co:OI:D;p",
           Args::intermix | Args::plusoptions);

The choice of how to interpret the relation between `+' and `-' options is completely up to the program. Here is how the +p and -p options above would be programmed:

       int allow_anachronisms = 1;
       int profiling = 0;
   

main(int argc, const char*const* argv) { Args args(argc, argv, "co:OI:D;p", Args::intermix | Args::plusoptions); // ... switch (opt->chr()) { // ... case 'p': if (opt->flag() == '+') allow_anachronisms = 0; else profiling = 1; break; } } // ... }


Next topic: Keyword options
Previous topic: Intermixing

© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005