-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOptions.h
106 lines (90 loc) · 4.45 KB
/
Options.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
//
// Copyright 1998-2000 by Craig Stuart Sapp, All Rights Reserved.
// Programmer: Craig Stuart Sapp <craig@ccrma.stanford.edu>
// Creation Date: Sun Apr 5 13:07:18 PDT 1998
// Last Modified: Fri Jan 15 07:24:00 PST 1999
// Last Modified: Sat Mar 27 18:17:59 PST 1999
// Last Modified: Thu Apr 13 14:02:52 PDT 2000 (added 2nd define function)
// Last Modified: Fri May 5 17:57:50 PDT 2000 (added --options suppression)
// Filename: ...sig/maint/code/base/Options/Options.h
// Web Address: http://sig.sapp.org/include/sigBase/Options.h
// Documentation: http://sig.sapp.org/doc/classes/Options
// Syntax: C++
//
// Description: Handles command-line options in a graceful manner.
//
#ifndef _OPTIONS_H_INCLUDED
#define _OPTIONS_H_INCLUDED
#include "Array.h"
class option_list;
class option_register;
class Options {
public:
Options (void);
Options (int argc, char** argv);
~Options ();
int argc (void) const;
char** argv (void) const;
void define (const char* aDefinition);
void define (const char* aDefinition,
const char* description);
char* getArg (int index);
char* getArgument (int index);
int getArgCount (void);
int getArgumentCount (void);
int getBoolean (const char* optionName);
const char* getCommand (void);
const char* getCommandLine (void);
const char* getString (void);
const char* getDefinition (const char* optionName);
double getDouble (const char* optionName);
char getFlag (void);
float getFloat (const char* optionName);
int getInt (const char* optionName);
int getInteger (const char* optionName);
const char* getString (const char* optionName);
char getType (const char* optionName);
int optionsArg (void);
void print (void);
void process (int error_check = 1, int suppress = 0);
void process (int argc, char** argv,
int error_check = 1,
int suppress = 0);
void reset (void);
void verify (int argc, char** argv,
int error_check = 1,
int suppress = 0);
void verify (int error_check = 1,
int suppress = 0);
void setFlag (char aFlag);
void setModified (const char* optionName,
const char* optionValue);
void setOptions (int argc, char** argv);
protected:
int options_error_check; // for verify command
int gargc;
char** gargv;
char* commandString;
char optionFlag;
Array<char*> argument;
Array<option_register*> optionRegister;
Array<option_list*> optionList;
int processedQ;
int sortedQ;
int suppressQ; // prevent the --options option
int optionsArgument; // indicates --options present
int getRegIndex (const char* optionName);
int optionQ (const char* aString, int& argp);
void sortOptionNames (void);
int storeOption (int gargp, int& position,
int& running);
};
#define OPTION_BOOLEAN_TYPE 'b'
#define OPTION_CHAR_TYPE 'c'
#define OPTION_DOUBLE_TYPE 'd'
#define OPTION_FLOAT_TYPE 'f'
#define OPTION_INT_TYPE 'i'
#define OPTION_STRING_TYPE 's'
#define OPTION_UNKNOWN_TYPE 'x'
#endif /* _OPTIONS_H_INCLUDED */
// md5sum: c59d297a8081cb48f61b534484819f48 Options.h [20030102]