My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
Parser  
Parser Syntax Details
Updated Nov 14, 2011 by hugo.arregui

GetOpt_pp parses a sequence of entries. Each entry has an option, and a list of arguments. Options can be specified in a short format, or a long format.

  • Short format: each option is represented by a character.
  • Long format: each option is represented by a word (seq. of characters).

Many short options can be specified in the same entry. If the entry contains arguments, they are considered to belong to the last character. For example:

  -abc 1 2 3 4

is equivalent to

  -a -b -c 1 2 3 4

which means, option 'a' has no arguments, option 'b' has no arguments neither, and option 'c' has the list 1 2 3 4 as its arguments.

If a list of entries is specified at the beginning without specifying an option, then they are considered to belong to the EMPTY_OPTION short option. For example:

  one two three -a

will generate the EMPTY_OPTION entry, having 'one two three' as its list of arguments, plus the 'a' option. Refer to the Basic Usage for further details on this.

You can compile and play with the example_iterators.cpp example just to experiment how the parser behaves.

//

Next: Examples

Back to Table of Contents

Comment by rjanec...@gmail.com, Dec 21, 2011

It's also important to mention that use of options list like:

-i 1 -o aaa -i 2 -i 3 -e

is equivalent to

-e -o aaa -i 1 2 3

So the same option can be specified multiple times in free order and all option's arguments will be collected in one list.


Sign in to add a comment
Powered by Google Project Hosting