libplatform/prog/option.h Source File
option.h
1#ifndef MP4V2_PLATFORM_PROG_OPTION_H
2#define MP4V2_PLATFORM_PROG_OPTION_H
3
22namespace mp4v2 { namespace platform { namespace prog {
23
26MP4V2_EXPORT extern const char* optarg;
27
33MP4V2_EXPORT extern int optind;
34
39MP4V2_EXPORT extern int optopt;
40
42MP4V2_EXPORT extern int opterr;
43
46MP4V2_EXPORT extern int optreset;
47
51struct MP4V2_EXPORT Option
52{
63
65 const char* name;
66
69
73 int* flag;
74
79 int val;
80};
81
133MP4V2_EXPORT
134int getOption( int argc, char* const* argv, const char* optstr, const Option* longopts, int* idx );
135
167MP4V2_EXPORT
168int getOptionSingle( int argc, char* const* argv, const char* optstr, const Option* longopts, int* idx );
169
171
172}}} // namespace mp4v2::platform::prog
173
174#endif // MP4V2_PLATFORM_PROG_OPTION_H
int optreset
Must be set to 1 before evaluating the 2nd or each additional set of arguments.
int getOptionSingle(int argc, char *const *argv, const char *optstr, const Option *longopts, int *idx)
Get option character from command line argument list and allow long-options with single-hyphens.
int optopt
On return from getOption() or getOptionSingle(), saves the last known option character returned by ge...
const char * optarg
On return from getOption() or getOptionSingle(), points to an option argument, if it is anticipated.
int opterr
Initialized to 1 and may be set to 0 to disable error messages.
int optind
On return from getOption() or getOptionSingle(), contains the index to the next argv argument for a s...
int getOption(int argc, char *const *argv, const char *optstr, const Option *longopts, int *idx)
Get option character from command line argument list.
Structure describing a single option.
Definition option.h:52
Type type
option expectation-type
Definition option.h:68
Type
expectation-type indicating number of arguments expected on the command-line following the option-arg...
Definition option.h:55
@ NO_ARG
indicates exactly 0 arguments follow option
Definition option.h:57
@ REQUIRED_ARG
indicates exactly 1 argument follow option
Definition option.h:59
@ OPTIONAL_ARG
indicates 0 or 1 arguments follow option
Definition option.h:61
const char * name
contains the option name without leading double-dash
Definition option.h:65
int val
Constant value representing option.
Definition option.h:79
int * flag
If not NULL, then the integer pointed to by it will be set to the value in the val field.
Definition option.h:73