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 |
6108
|
37 OCTAVE_API |
1816
|
38 prog_args |
|
39 { |
|
40 public: |
|
41 |
1855
|
42 // These values must match the corresponding defines in getopt.h. |
|
43 enum option_argument |
|
44 { |
|
45 no_arg = 0, |
|
46 required_arg = 1, |
|
47 optional_arg = 2 |
|
48 }; |
|
49 |
1816
|
50 prog_args (int argc, char *const *argv, const char *s_opts, const |
|
51 long_options* l_opts = 0) |
|
52 : xargc (argc), xargv (argv), short_opts (s_opts), long_opts (l_opts) |
|
53 { |
|
54 init (); |
|
55 } |
|
56 |
|
57 ~prog_args (void) { } |
|
58 |
|
59 int getopt (void); |
|
60 |
|
61 const char *optarg (void); |
|
62 |
|
63 int optind (void); |
|
64 |
|
65 private: |
|
66 |
|
67 // Number of args. |
|
68 int xargc; |
|
69 |
|
70 // Program args. |
|
71 char *const *xargv; |
|
72 |
|
73 // Single character options. |
|
74 const char *short_opts; |
|
75 |
|
76 // Long options. |
|
77 const long_options *long_opts; |
|
78 |
|
79 void init (void); |
|
80 |
|
81 prog_args (const prog_args&); |
|
82 |
|
83 prog_args& operator = (const prog_args&); |
|
84 }; |
|
85 |
|
86 #endif |
|
87 |
|
88 /* |
|
89 ;;; Local Variables: *** |
|
90 ;;; mode: C++ *** |
|
91 ;;; End: *** |
|
92 */ |