Ignore:
Timestamp:
05/13/11 15:48:57 (14 years ago)
Author:
tbretz
Message:
Use the functionality of boost program_options better; implemented po_bool() as a special po_switch() case; added some comments.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/Configuration.cc

    r10634 r10707  
    9292    po::options_description config("Section");
    9393    config.add_options()
    94         ("option1",    po_string(),              "This is option1")
    95         ("option2",    po_int(22),               "This is option2")
    96         ("option3,o",  po_double()->required(),  "This option is mandatory")
    97         ("option4",    po_int(&opt),             "This is option 4")
    98         ("option5",    po_strings(),             "A list of strings")
    99         ("option6",    po_strings(),             "A list of strings")
    100         ("option7",    po_strings(),             "A list of strings")
     94        ("option1",    var<string>(),                        "This is option1")
     95        ("option2",    var<int>(22),                         "This is option2")
     96        ("option3,o",  var<double>->required(),              "This option is mandatory")
     97        ("option4",    var<int>(&opt),                       "This is option 4")
     98        ("option5",    vars<string>(),                       "A list of strings")
     99        ("option6",    vars<string>(),                       "A list of strings")
     100        ("option7",    vars<string>,                         "A list of strings")
     101        ("option8",    var<string>()->implicit_value("val"), "Just a string")
     102        ("option9",    var<string>()->default_value("def"),  "Just a string")
     103        ("optionA",    var<string>("def"),                   "Just a string")
     104        ("bool",       po_bool(),                            "A special switch")
    101105        ;
    102106
     
    119123Abbreviations po_ints(), po_doubles() and po_strings() are available.
    120124
    121 In addition to options introduced by a minus, so calles positional options
    122 can be given on the command line. To describe these options use
     125There are several ways to define the behaviour of the options. In the
     126example above Parse will throw an exception if the "--option3" or "-o"
     127option is not given. "option9" will evaluate to "def" if it is not
     128given on the command line. The syntax of "optionA" is just an
     129abbreviation. "option8" will evaluate to "val" if just "--option5" but
     130no argument is given. Note, that these modifiers can be concatenated.
     131
     132A special type po_bool() is provided which is an abbreviation of
     133var<bool>()->implicit_value(true)->default_value(false). In
     134contradiction to po_switch() this allows to set a true and
     135false value in the setup file.
     136
     137In addition to options introduced by a minus or double minus, so called
     138positional options can be given on the command line. To describe these
     139options use
    123140
    124141\code
Note: See TracChangeset for help on using the changeset viewer.