MPQC 3.0.0-alpha
Loading...
Searching...
No Matches
GetLongOpt.h
1/* $Id$ */
2/* S Manoharan. Advanced Computer Research Institute. Lyon. France */
3
4#ifndef _GetLongOpt_h_
5#define _GetLongOpt_h_
6
7#include <iostream>
8#include <string.h>
9
10namespace sc {
11
14
17public:
20 enum OptType {
21 NoValue, OptionalValue, MandatoryValue
22 };
23private:
24 struct Cell {
25 const char *option; // option name
26 OptType type; // option type
27 const char *description; // a description of option
28 const char *value; // value of option (string)
29 Cell *next; // pointer to the next cell
30
31 Cell() { option = description = value = 0; next = 0; }
32 };
33private:
34 Cell *table; // option table
35 const char *ustring; // usage message
36 char *pname; // program basename
37 char optmarker; // option marker
38
39 int enroll_done; // finished enrolling
40 Cell *last; // last entry in option table
41
42private:
43 char *basename(char * const p) const;
44 int setcell(Cell *c, const char *valtoken, const char *nexttoken, const char *p);
45public:
48 GetLongOpt(const char optmark = '-');
50
56 int parse(int argc, char * const *argv);
62 int parse(char * const str, char * const p);
63
69 int enroll(const char * const opt, const OptType t,
70 const char * const desc, const char * const val);
73 const char *retrieve(const char * const opt) const;
74
77 void usage(std::ostream &outfile = std::cout) const;
80 void usage(const char *str) { ustring = str; }
81};
82
84// end of addtogroup Init
85
86}
87
88#endif /* _GetLongOpt_h_ */
Parse command line options.
Definition GetLongOpt.h:16
const char * retrieve(const char *const opt) const
Retrieve an option.
int parse(char *const str, char *const p)
Parse options in a string.
OptType
Used by the enroll member to specify whether or not a value is expected or optional.
Definition GetLongOpt.h:20
GetLongOpt(const char optmark='-')
Initialize the object.
int enroll(const char *const opt, const OptType t, const char *const desc, const char *const val)
Enroll an option.
void usage(const char *str)
Initialize usage synopsis.
Definition GetLongOpt.h:80
int parse(int argc, char *const *argv)
Parse command line options.
void usage(std::ostream &outfile=std::cout) const
Print usage information.
Contains all MPQC code up to version 3.
Definition mpqcin.h:14

Generated at Wed Sep 25 2024 02:45:31 for MPQC 3.0.0-alpha using the documentation package Doxygen 1.12.0.