Fix bug caused by m4 consuming pairs of square brackets (#108).
3 * This file is a part of LEMON, a generic C++ optimization library
5 * Copyright (C) 2003-2008
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 * (Egervary Research Group on Combinatorial Optimization, EGRES).
9 * Permission to use, modify and distribute this software is granted
10 * provided that this copyright notice appears in all copies. For
11 * precise terms see the accompanying LICENSE file.
13 * This software is provided "AS IS" with no warranty of any kind,
14 * express or implied, and with no claim as to its suitability for any
21 ///\brief Argument parser demo
23 /// This example shows how the argument parser can be used.
25 /// \include arg_parser_demo.cc
27 #include <lemon/arg_parser.h>
29 using namespace lemon;
30 int main(int argc, const char **argv)
32 ArgParser ap(argc,argv);
38 ap.refOption("n", "An integer input.", i, true)
39 .refOption("val", "A double input.", d)
40 .doubleOption("val2", "A double input.", d)
41 .synonym("vals","val")
42 .refOption("name", "A string input.", s)
43 .refOption("f", "A switch.", b)
44 .refOption("nohelp", "", sil)
45 .refOption("gra","Choice A",g1)
46 .refOption("grb","Choice B",g2)
47 .refOption("grc","Choice C",g3)
48 .optionGroup("gr","gra")
49 .optionGroup("gr","grb")
50 .optionGroup("gr","grc")
53 .other("infile","The input file.")
58 std::cout << "Parameters of '" << ap.commandName() << "':\n";
60 if(ap.given("n")) std::cout << " Value of -n: " << i << std::endl;
61 if(ap.given("val")) std::cout << " Value of -val: " << d << std::endl;
62 if(ap.given("name")) std::cout << " Value of -name: " << s << std::endl;
63 if(ap.given("f")) std::cout << " -f is given\n";
64 if(ap.given("nohelp")) std::cout << " Value of -nohelp: " << sil << std::endl;
65 if(ap.given("gra")) std::cout << " -gra is given\n";
66 if(ap.given("grb")) std::cout << " -grb is given\n";
67 if(ap.given("grc")) std::cout << " -grc is given\n";
69 switch(ap.files().size()) {
71 std::cout << " No file argument was given.\n";
74 std::cout << " 1 file argument was given. It is:\n";
78 << ap.files().size() << " file arguments were given. They are:\n";
80 for(unsigned int i=0;i<ap.files().size();++i)
81 std::cout << " '" << ap.files()[i] << "'\n";