alpar@2391
|
1 |
/* -*- C++ -*-
|
alpar@2391
|
2 |
*
|
alpar@2391
|
3 |
* This file is a part of LEMON, a generic C++ optimization library
|
alpar@2391
|
4 |
*
|
alpar@2391
|
5 |
* Copyright (C) 2003-2007
|
alpar@2391
|
6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
|
alpar@2391
|
7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES).
|
alpar@2391
|
8 |
*
|
alpar@2391
|
9 |
* Permission to use, modify and distribute this software is granted
|
alpar@2391
|
10 |
* provided that this copyright notice appears in all copies. For
|
alpar@2391
|
11 |
* precise terms see the accompanying LICENSE file.
|
alpar@2391
|
12 |
*
|
alpar@2391
|
13 |
* This software is provided "AS IS" with no warranty of any kind,
|
alpar@2391
|
14 |
* express or implied, and with no claim as to its suitability for any
|
alpar@2391
|
15 |
* purpose.
|
alpar@2391
|
16 |
*
|
alpar@2391
|
17 |
*/
|
alpar@2391
|
18 |
|
alpar@2389
|
19 |
#include <lemon/arg_parser.h>
|
alpar@2389
|
20 |
|
alpar@2389
|
21 |
using namespace lemon;
|
alpar@2389
|
22 |
int main(int argc, char **argv)
|
alpar@2389
|
23 |
{
|
alpar@2389
|
24 |
ArgParser ap(argc,argv);
|
alpar@2389
|
25 |
int i;
|
alpar@2389
|
26 |
std::string s;
|
alpar@2389
|
27 |
double d;
|
alpar@2389
|
28 |
bool b,sil;
|
alpar@2389
|
29 |
bool g1,g2,g3;
|
alpar@2389
|
30 |
ap.option("n", "an integer input", i, true)
|
alpar@2389
|
31 |
.option("val", "a double input", d)
|
alpar@2389
|
32 |
.synonym("vals","val")
|
alpar@2389
|
33 |
.option("name", "a string input", s)
|
alpar@2389
|
34 |
.option("f", "a switch", b)
|
alpar@2389
|
35 |
.option("nohelp", "", sil)
|
alpar@2389
|
36 |
.option("gra","Choise A",g1)
|
alpar@2389
|
37 |
.option("grb","Choise B",g2)
|
alpar@2389
|
38 |
.option("grc","Choise C",g3)
|
alpar@2389
|
39 |
.optionGroup("gr","gra")
|
alpar@2389
|
40 |
.optionGroup("gr","grb")
|
alpar@2389
|
41 |
.optionGroup("gr","grc")
|
alpar@2389
|
42 |
.mandatoryGroup("gr")
|
alpar@2389
|
43 |
.onlyOneGroup("gr")
|
alpar@2389
|
44 |
.other("infile","The input file")
|
alpar@2389
|
45 |
.other("...");
|
alpar@2389
|
46 |
|
alpar@2389
|
47 |
ap.parse();
|
alpar@2389
|
48 |
|
alpar@2389
|
49 |
std::cout << "Parameters of '" << ap.commandName() << "':\n";
|
alpar@2389
|
50 |
|
alpar@2389
|
51 |
if(ap.given("n")) std::cout << " Value of -n: " << i << std::endl;
|
alpar@2389
|
52 |
if(ap.given("val")) std::cout << " Value of -val: " << d << std::endl;
|
alpar@2389
|
53 |
if(ap.given("name")) std::cout << " Value of -name: " << s << std::endl;
|
alpar@2389
|
54 |
if(ap.given("f")) std::cout << " -f is given\n";
|
alpar@2389
|
55 |
if(ap.given("nohelp")) std::cout << " Value of -nohelp: " << sil << std::endl;
|
alpar@2389
|
56 |
|
alpar@2389
|
57 |
switch(ap.files().size()) {
|
alpar@2389
|
58 |
case 0:
|
alpar@2389
|
59 |
std::cout << " No file argument was given.\n";
|
alpar@2389
|
60 |
break;
|
alpar@2389
|
61 |
case 1:
|
alpar@2389
|
62 |
std::cout << " 1 file argument was given. It is:\n";
|
alpar@2389
|
63 |
break;
|
alpar@2389
|
64 |
default:
|
alpar@2389
|
65 |
std::cout << " "
|
alpar@2389
|
66 |
<< ap.files().size() << " file arguments were given. They are:\n";
|
alpar@2389
|
67 |
}
|
alpar@2389
|
68 |
for(unsigned int i=0;i<ap.files().size();++i)
|
alpar@2389
|
69 |
std::cout << " '" << ap.files()[i] << "'\n";
|
alpar@2389
|
70 |
|
alpar@2389
|
71 |
}
|