MPQC 2.3.1
GetLongOpt.h
1/* $Id: GetLongOpt.h,v 2.2 2003/02/06 01:02:13 cljanss Exp $ */
2/* S Manoharan. Advanced Computer Research Institute. Lyon. France */
3
4#ifdef __GNUC__
5#pragma interface
6#endif
7
8#ifndef _GetLongOpt_h_
9#define _GetLongOpt_h_
10
11#include <iostream>
12#include <string.h>
13
14namespace sc {
15
16class GetLongOpt {
17public:
18 enum OptType {
19 NoValue, OptionalValue, MandatoryValue
20 };
21private:
22 struct Cell {
23 const char *option; // option name
24 OptType type; // option type
25 const char *description; // a description of option
26 const char *value; // value of option (string)
27 Cell *next; // pointer to the next cell
28
29 Cell() { option = description = value = 0; next = 0; }
30 };
31private:
32 Cell *table; // option table
33 const char *ustring; // usage message
34 char *pname; // program basename
35 char optmarker; // option marker
36
37 int enroll_done; // finished enrolling
38 Cell *last; // last entry in option table
39
40private:
41 char *basename(char * const p) const;
42 int setcell(Cell *c, const char *valtoken, const char *nexttoken, const char *p);
43public:
44 GetLongOpt(const char optmark = '-');
45 ~GetLongOpt();
46
47 int parse(int argc, char * const *argv);
48 int parse(char * const str, char * const p);
49
50 int enroll(const char * const opt, const OptType t,
51 const char * const desc, const char * const val);
52 const char *retrieve(const char * const opt) const;
53
54 void usage(std::ostream &outfile = std::cout) const;
55 void usage(const char *str) { ustring = str; }
56};
57
58}
59
60#endif /* _GetLongOpt_h_ */

Generated at Mon Jan 20 2025 00:00:00 for MPQC 2.3.1 using the documentation package Doxygen 1.13.2.