]>
cygwin.com Git - cygwin-apps/setup.git/blob - libgetopt++/src/OptionSet.cc
2 * Copyright (c) 2002 Robert Collins.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * A copy of the GNU General Public License can be found at
12 * Written by Robert Collins <robertc@hotmail.com>
19 #include "getopt++/OptionSet.h"
20 #include "getopt++/Option.h"
22 OptionSet::OptionSet () : options(0), optCount (0) {}
23 OptionSet::~OptionSet ()
35 bool OptionSet::Process (int argc
, char **argv
)
39 // log (LOG_TIMESTAMP, "No command line options pass\n");
44 // log (LOG_TIMESTAMP,
45 // "%d Command line options passed, and no options registered\n",
49 // log (LOG_TIMESTAMP, "Process command line options\n");
50 struct option longopts
[optCount
+ 1];
53 for (int i
= 0; i
< optCount
; ++i
)
55 Option
*anOption
= options
[i
];
56 shortopts
+= anOption
->shortOption ();
57 longopts
[i
] = anOption
->longOption ();
60 opts
= shortopts
.c_str ();
68 longopts
[optCount
] = foo
;
70 // where is this correctly defined? opterr=0;
72 while ((lastoption
= getopt_long (argc
, argv
, opts
, longopts
, 0)) != -1)
76 if (lastoption
== '\?')
84 for (int i
= 0; i
< optCount
; ++i
)
86 if (longopts
[i
].val
== lastoption
&& !longopts
[i
].flag
)
87 options
[i
]->Process (optarg
);
97 //FIXME: check for conflicts.
99 OptionSet::Register (Option
* anOption
)
101 Option
**t
= new Option
*[optCount
+ 1];
102 for (int i
= 0; i
< optCount
; ++i
)
104 t
[optCount
++] = anOption
;
This page took 0.046091 seconds and 6 git commands to generate.