aboutsummaryrefslogtreecommitdiff
path: root/include/lldb/Host/OptionParser.h
blob: 1b0dc4ae19e00f94359abc122daf173502d7e55a (plain) (blame)
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
//===-- OptionParser.h ------------------------------------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#ifndef liblldb_OptionParser_h_
#define liblldb_OptionParser_h_

#include <mutex>
#include <string>

#include "llvm/ADT/StringRef.h"

struct option;

namespace lldb_private {

struct OptionDefinition;

struct Option {
  // The definition of the option that this refers to.
  const OptionDefinition *definition;
  // if not NULL, set *flag to val when option found
  int *flag;
  // if flag not NULL, value to set *flag to; else return value
  int val;
};

class OptionParser {
public:
  enum OptionArgument { eNoArgument = 0, eRequiredArgument, eOptionalArgument };

  static void Prepare(std::unique_lock<std::mutex> &lock);

  static void EnableError(bool error);

  static int Parse(int argc, char *const argv[], llvm::StringRef optstring,
                   const Option *longopts, int *longindex);

  static char *GetOptionArgument();
  static int GetOptionIndex();
  static int GetOptionErrorCause();
  static std::string GetShortOptionString(struct option *long_options);
};
}

#endif // liblldb_OptionParser_h_