OptionParser.h revision 263367
1//===-- OptionParser.h ------------------------------------------*- C++ -*-===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef liblldb_OptionParser_h_
11#define liblldb_OptionParser_h_
12
13#include <string>
14
15struct option;
16
17namespace lldb_private {
18
19typedef struct Option
20{
21    // name of long option
22    const char *name;
23    // one of no_argument, required_argument, and optional_argument:
24    // whether option takes an argument
25    int has_arg;
26    // if not NULL, set *flag to val when option found
27    int *flag;
28    // if flag not NULL, value to set *flag to; else return value
29    int val;
30} Option;
31
32class OptionParser
33{
34public:
35    enum OptionArgument
36    {
37        eNoArgument = 0,
38        eRequiredArgument,
39        eOptionalArgument
40    };
41
42    static void Prepare();
43
44    static void EnableError(bool error);
45
46    static int Parse(int argc, char * const argv [],
47        const char *optstring,
48        const Option *longopts, int *longindex);
49
50    static char* GetOptionArgument();
51    static int GetOptionIndex();
52    static int GetOptionErrorCause();
53    static std::string GetShortOptionString(struct option *long_options);
54};
55
56}
57
58#endif  // liblldb_OptionParser_h_
59