COIN-OR::LEMON - Graph Library

Changeset 88:18444049848b in lemon-1.0


Ignore:
Timestamp:
03/16/08 01:39:19 (11 years ago)
Author:
Peter Kovacs <kpeter@…>
Branch:
default
Phase:
public
Message:

Minor improvements in arg_parser files

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • demo/arg_parser_demo.cc

    r85 r88  
    2121///\brief Argument parser demo
    2222///
    23 /// This example shows how can the argument parser used.
     23/// This example shows how the argument parser can be used.
    2424///
    25 /// \include arg_parser.cc
     25/// \include arg_parser_demo.cc
    2626
    2727#include <lemon/arg_parser.h>
     
    3636  bool b,sil;
    3737  bool g1,g2,g3;
    38   ap.refOption("n", "an integer input", i, true)
    39     .refOption("val", "a double input", d)
     38  ap.refOption("n", "An integer input.", i, true)
     39    .refOption("val", "A double input.", d)
    4040    .synonym("vals","val")
    41     .refOption("name", "a string input", s)
    42     .refOption("f", "a switch", b)
     41    .refOption("name", "A string input.", s)
     42    .refOption("f", "A switch.", b)
    4343    .refOption("nohelp", "", sil)
    44     .refOption("gra","Choise A",g1)
    45     .refOption("grb","Choise B",g2)
    46     .refOption("grc","Choise C",g3)
     44    .refOption("gra","Choice A",g1)
     45    .refOption("grb","Choice B",g2)
     46    .refOption("grc","Choice C",g3)
    4747    .optionGroup("gr","gra")
    4848    .optionGroup("gr","grb")
     
    5050    .mandatoryGroup("gr")
    5151    .onlyOneGroup("gr")
    52     .other("infile","The input file")
     52    .other("infile","The input file.")
    5353    .other("...");
    5454 
     
    6262  if(ap.given("f")) std::cout << "  -f is given\n";
    6363  if(ap.given("nohelp")) std::cout << "  Value of -nohelp: " << sil << std::endl;
    64 
     64  if(ap.given("gra")) std::cout << "  -gra is given\n";
     65  if(ap.given("grb")) std::cout << "  -grb is given\n";
     66  if(ap.given("grc")) std::cout << "  -grc is given\n";
     67                                     
    6568  switch(ap.files().size()) {
    6669  case 0:
  • lemon/arg_parser.cc

    r85 r88  
    7070    p.type=INTEGER;
    7171    p.mandatory=obl;
    72     p.self_delete=true;
    7372    _opts[name]=p;
    7473    return *this;
     
    10099    p.mandatory=obl;
    101100    _opts[name]=p;
    102 
    103     value = false;
    104 
    105101    return *this;
    106102  }
  • lemon/arg_parser.h

    r87 r88  
    3131///\ingroup misc
    3232///\file
    33 ///\brief A tools to parse command line arguments.
    34 ///
    35 ///\author Alpar Juttner
     33///\brief A tool to parse command line arguments.
    3634
    3735namespace lemon {
     
    4038
    4139  ///\ingroup misc
    42   ///Command line arguments parser
     40  ///Command line arguments parser.
    4341  ///
     42  ///For a complete example see the \ref arg_parser_demo.cc demo file.
    4443  class ArgParser {
    4544   
     
    166165                      std::string value="", bool obl=false);
    167166
    168     ///\name Options with an external strorage.
     167    ///\name Options with external storage
    169168    ///Using this functions, the value of the option will be directly written
    170169    ///into a variable once the option appears in the command line.
     
    223222
    224223    /// You can group some option by calling this function repeatedly for each
    225     /// option to be grupped with the same groupname.
    226     ///\param group The group name
    227     ///\param opt The option name
     224    /// option to be grouped with the same groupname.
     225    ///\param group The group name.
     226    ///\param opt The option name.
    228227    ArgParser &optionGroup(const std::string &group,
    229228                           const std::string &opt);
     
    243242    ///Create synonym to an option
    244243
    245     ///With this function you can create a sysnonym called \c sys of the
     244    ///With this function you can create a synonym \c syn of the
    246245    ///option \c opt.
    247246    ArgParser &synonym(const std::string &syn,
     
    253252
    254253    ///With this function you can give help string for non-parsed arguments.
    255     ///the parameter \c name will be printed in the short usage line, while
     254    ///The parameter \c name will be printed in the short usage line, while
    256255    ///\c help gives a more detailed description.
    257256    ArgParser &other(const std::string &name,
    258257                     const std::string &help="");
    259258   
    260     ///Non option type arguments.
    261 
    262     ///Gives back a reference to a vector consisting of the program arguments
     259    ///Give back the non-option type arguments.
     260
     261    ///Give back a reference to a vector consisting of the program arguments
    263262    ///not starting with a '-' character.
    264263    std::vector<std::string> &files() { return _file_args; }
     
    299298   
    300299    ///This is the type of the return value of ArgParser::operator[]().
    301     ///It automatically converts to int, double, bool or std::string if
    302     ///the type of the option matches, otherwise it throws an exception.
    303     ///(i.e. it performs runtime type checking).
     300    ///It automatically converts to \c int, \c double, \c bool or
     301    ///\c std::string if the type of the option matches, otherwise it
     302    ///throws an exception (i.e. it performs runtime type checking).
    304303    class RefType
    305304    {
     
    356355    ///Give back the value of an option
    357356   
    358     ///Give back the value of an option
     357    ///Give back the value of an option.
    359358    ///\sa RefType
    360359    RefType operator[](const std::string &n)
Note: See TracChangeset for help on using the changeset viewer.