1816
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
1816
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
5307
|
19 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
20 02110-1301, USA. |
1816
|
21 |
|
22 */ |
|
23 |
|
24 #if !defined (octave_prog_args_h) |
|
25 #define octave_prog_args_h 1 |
|
26 |
|
27 struct |
|
28 long_options |
|
29 { |
|
30 const char *name; |
|
31 int has_arg; |
|
32 int *flag; |
|
33 int val; |
|
34 }; |
|
35 |
|
36 class |
|
37 prog_args |
|
38 { |
|
39 public: |
|
40 |
1855
|
41 // These values must match the corresponding defines in getopt.h. |
|
42 enum option_argument |
|
43 { |
|
44 no_arg = 0, |
|
45 required_arg = 1, |
|
46 optional_arg = 2 |
|
47 }; |
|
48 |
1816
|
49 prog_args (int argc, char *const *argv, const char *s_opts, const |
|
50 long_options* l_opts = 0) |
|
51 : xargc (argc), xargv (argv), short_opts (s_opts), long_opts (l_opts) |
|
52 { |
|
53 init (); |
|
54 } |
|
55 |
|
56 ~prog_args (void) { } |
|
57 |
|
58 int getopt (void); |
|
59 |
|
60 const char *optarg (void); |
|
61 |
|
62 int optind (void); |
|
63 |
|
64 private: |
|
65 |
|
66 // Number of args. |
|
67 int xargc; |
|
68 |
|
69 // Program args. |
|
70 char *const *xargv; |
|
71 |
|
72 // Single character options. |
|
73 const char *short_opts; |
|
74 |
|
75 // Long options. |
|
76 const long_options *long_opts; |
|
77 |
|
78 void init (void); |
|
79 |
|
80 prog_args (const prog_args&); |
|
81 |
|
82 prog_args& operator = (const prog_args&); |
|
83 }; |
|
84 |
|
85 #endif |
|
86 |
|
87 /* |
|
88 ;;; Local Variables: *** |
|
89 ;;; mode: C++ *** |
|
90 ;;; End: *** |
|
91 */ |