LLDB  mainline
OptionParser.h
Go to the documentation of this file.
1 //===-- OptionParser.h ------------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLDB_HOST_OPTIONPARSER_H
10 #define LLDB_HOST_OPTIONPARSER_H
11 
12 #include <mutex>
13 #include <string>
14 
15 #include "llvm/ADT/StringRef.h"
16 #include "llvm/ADT/ArrayRef.h"
17 
18 struct option;
19 
20 namespace lldb_private {
21 
22 struct OptionDefinition;
23 
24 struct Option {
25  // The definition of the option that this refers to.
27  // if not NULL, set *flag to val when option found
28  int *flag;
29  // if flag not NULL, value to set *flag to; else return value
30  int val;
31 };
32 
33 class OptionParser {
34 public:
36 
37  static void Prepare(std::unique_lock<std::mutex> &lock);
38 
39  static void EnableError(bool error);
40 
41  /// Argv must be an argument vector "as passed to main", i.e. terminated with
42  /// a nullptr.
43  static int Parse(llvm::MutableArrayRef<char *> argv,
44  llvm::StringRef optstring, const Option *longopts,
45  int *longindex);
46 
47  static char *GetOptionArgument();
48  static int GetOptionIndex();
49  static int GetOptionErrorCause();
50  static std::string GetShortOptionString(struct option *long_options);
51 };
52 }
53 
54 #endif // LLDB_HOST_OPTIONPARSER_H
lldb_private::OptionParser::Parse
static int Parse(llvm::MutableArrayRef< char * > argv, llvm::StringRef optstring, const Option *longopts, int *longindex)
Argv must be an argument vector "as passed to main", i.e.
Definition: OptionParser.cpp:31
lldb_private::OptionParser::eNoArgument
@ eNoArgument
Definition: OptionParser.h:35
lldb_private::OptionParser::EnableError
static void EnableError(bool error)
Definition: OptionParser.cpp:29
lldb_private::Option
Definition: OptionParser.h:24
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
lldb_private::OptionParser::GetOptionIndex
static int GetOptionIndex()
Definition: OptionParser.cpp:52
lldb_private::OptionParser::eOptionalArgument
@ eOptionalArgument
Definition: OptionParser.h:35
lldb_private::OptionParser::GetOptionArgument
static char * GetOptionArgument()
Definition: OptionParser.cpp:50
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
lldb_private::Option::val
int val
Definition: OptionParser.h:30
lldb_private::OptionParser
Definition: OptionParser.h:33
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::OptionDefinition
Definition: OptionDefinition.h:20
lldb_private::OptionParser::OptionArgument
OptionArgument
Definition: OptionParser.h:35
lldb_private::Option::definition
const OptionDefinition * definition
Definition: OptionParser.h:26
lldb_private::OptionParser::GetShortOptionString
static std::string GetShortOptionString(struct option *long_options)
Definition: OptionParser.cpp:56
lldb_private::Option::flag
int * flag
Definition: OptionParser.h:28
lldb_private::OptionParser::GetOptionErrorCause
static int GetOptionErrorCause()
Definition: OptionParser.cpp:54
lldb_private::OptionParser::eRequiredArgument
@ eRequiredArgument
Definition: OptionParser.h:35
lldb_private::OptionParser::Prepare
static void Prepare(std::unique_lock< std::mutex > &lock)
Definition: OptionParser.cpp:18