next up previous contents
Next: Nominus Arguments Up: GetPot Version 1.0 Powerful Previous: Variables   Contents

Flags

Flags are activated by single letters inside an argument or option4. GetPot has two functions to access flags:

options_contain(const char* Flags):
Checks if any option (argument that does start with a single '-') contains one of the flags specified in the string Flags.

argument_contains(unsigned Idx, const char* Flags):
Checks if argument number Idx contains one of the flags specified in Flags.
Here is an example:
...
    const bool  verbose_f = cl.options_contain("vV");
    const bool  extract_f = cl.argument_contains(1, "xX");
    const bool  create_f  = cl.argument_contains(1, "cC");
    if( create_f && extract_f ) 
       { cerr << "cannot create and extract at the same time.\n"; exit(-1); }
...
At first, it is checked if any option (argument that starts with a minus) contains a letter 'v' or 'V'. If it does, then the verbose flag will be set. The letters 'x', 'X', 'c', and 'C' in the first argument indicate if one uses the program to extract or create a new file. Correspondingly the flags are set.



Frank-Rene Schaefer 2002-09-14