]>
cygwin.com Git - cygwin-apps/setup.git/blob - libgetopt++/src/GetOption.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 "GetOption.h"
25 GetOption
& GetOption::GetInstance ()
27 if (Instance
.inited
!= 42)
34 bool GetOption::Process (int argc
, char **argv
)
38 // log (LOG_TIMESTAMP, "No command line options pass\n");
43 // log (LOG_TIMESTAMP,
44 // "%d Command line options passed, and no options registered\n",
48 // log (LOG_TIMESTAMP, "Process command line options\n");
50 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;
73 while ((lastoption
= getopt_long (argc
, argv
, opts
, longopts
, 0)) != -1)
77 if (lastoption
== '\?')
85 for (int i
= 0; i
< optCount
; ++i
)
87 if (longopts
[i
].val
== lastoption
&& !longopts
[i
].flag
)
88 options
[i
]->Process (optarg
);
106 //FIXME: check for conflicts.
108 GetOption::Register (Option
* anOption
)
110 Option
**t
= new Option
*[optCount
+ 1];
111 for (int i
= 0; i
< optCount
; ++i
)
113 t
[optCount
++] = anOption
;
This page took 0.041484 seconds and 5 git commands to generate.