source: ThirdParty/mpqc_open/src/lib/util/options/GetLongOpt.3

Candidate_v1.6.1
Last change on this file was 860145, checked in by Frederik Heber <heber@…>, 8 years ago

Merge commit '0b990dfaa8c6007a996d030163a25f7f5fc8a7e7' as 'ThirdParty/mpqc_open'

  • Property mode set to 100644
File size: 4.1 KB
Line 
1.\" @(#)GetLongOpt.3 2.0 12/01/1993
2.TH GETLONGOPT 3 "12 January 1993" "" "C++ LIBRARY CLASSES"
3.UC 4
4.SH NAME
5GetLongOpt - C++ class for parsing command line and strings for options
6.SH SYNOPSIS
7.nf
8.ft B
9.ss 18
10#include <GetLongOpt.h>
11
12GetLongOpt::GetLongOpt(const char optmark = '-');
13int GetLongOpt::parse(int argc, char * const *argv);
14int GetLongOpt::parse(char * const str, char * const p);
15int GetLongOpt::enroll(const char * const opt, const OptType t,
16 const char * const desc, const char * const val);
17const char * GetLongOpt::retrieve(const char * const opt) const;
18void GetLongOpt::usage(ostream &outfile = cout) const;
19void GetLongOpt::usage(const char *str);
20.ft
21.fi
22.ss
23
24.SH DESCRIPTION
25GetLongOpt is a C++ class for getting options from the command line
26and from strings. GetLongOpt supports long options. These options
27may be flags or require optional or mandatory values.
28If an option requires a value, then the value should be separated
29from the option either by whitespace or by a "=". Long options
30can be abbreviated. GetLongOpt can also be used to parse options given
31through environments.
32
33The constructor for GetLongOpt takes an optional argument: the option
34marker. If unspecified, this defaults to '-', the standard (?)
35Unix option marker. For example, a DOS addict may want to
36specify '/' for the option marker!
37
38.I GetLongOpt::enroll
39adds option specifications to its internal
40database. The first argument is the option sting. The second
41is an enum saying if the option is a flag (GetLongOpt::NoValue),
42if it requires a mandatory value (GetLongOpt::MandatoryValue) or
43if it takes an optional value (GetLongOpt::OptionalValue).
44The third argument is a string giving a brief description of
45the option. This description will be used by
46.I GetLongOpt::usage.
47GetLongOpt, for usage-printing, uses $val to represent values
48needed by the options. <$val> is a mandatory value and [$val]
49is an optional value. The final argument to
50.I GetLongOpt::enroll
51is the default string to be returned if the option is not
52specified. For flags (options with NoValue), use "" (empty
53string, or in fact any arbitrary string) for specifying TRUE
54and 0 (null pointer) to specify FALSE.
55
56.I GetLongOpt::usage
57is overloaded. If passed a string
58.I s,
59it sets the
60internal usage string to
61.I s.
62Otherwise it simply prints the
63command usage. The options and their
64descriptions (as specified during enroll) are printed in the
65order they are enrolled.
66
67.I GetLongOpt::parse
68is also overloaded. It can either parse a string of
69options (typically given from the environment), or it can parse
70the command line args (argc, argv). In either case a return
71value < 1 represents a parse error. Appropriate error messages
72are printed when errors are seen. GetLongOpt::parse, in its first
73form, takes two strings: the first one is the string to be
74parsed and the second one is a string to be prefixed to the
75parse errors. In its second form,
76.I GetLongOpt::parse
77takes in argc and argv and returns the
78the optind (see getopt(3)) if parsing is successful.
79Successful parsing, in either form of
80.I GetLongOpt::parse,
81updates the values of the options within the internal database.
82
83The values of the options that are enrolled in the database
84can be retrieved using
85.I GetLongOpt::retrieve.
86This returns a string
87and this string should be converted to whatever type you want.
88See atoi(3), atof(3), atol(3) etc. I suppose you would do a
89.I GetLongOpt::parse
90before
91retrieving. Otherwise all you would get are the default values
92you gave while enrolling!
93Ambiguities while retrieving (may happen when options are
94abbreviated) are resolved by taking the matching option that
95was enrolled last.
96
97If you try to retrieve something you did not enroll, you will
98get a warning message. This means that you probably had made
99a typo somewhere while enrolling or retrieving.
100
101.SH BUGS
102They should be there well-hidden. If you spot one report it.
103
104.SH "SEE ALSO"
105getopt(3),
106getopts(1),
107atoi(3), atof(3), atol(3).
108
109.SH AUTHOR
110.nf
111S Manoharan
112Advanced Computer Research Institute
1131 Boulevard Marius Vivier-Merle
11469443 Lyon Cedex 03 France
115
116mano@acri.fr
117.fi
118
119.\" end of man page
Note: See TracBrowser for help on using the repository browser.