1 //===-- OptionParser.h ------------------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef liblldb_OptionParser_h_
10 #define liblldb_OptionParser_h_
15 #include "llvm/ADT/StringRef.h"
16 #include "llvm/ADT/ArrayRef.h"
20 namespace lldb_private {
22 struct OptionDefinition;
25 // The definition of the option that this refers to.
26 const OptionDefinition *definition;
27 // if not NULL, set *flag to val when option found
29 // if flag not NULL, value to set *flag to; else return value
35 enum OptionArgument { eNoArgument = 0, eRequiredArgument, eOptionalArgument };
37 static void Prepare(std::unique_lock<std::mutex> &lock);
39 static void EnableError(bool error);
41 /// Argv must be an argument vector "as passed to main", i.e. terminated with
43 static int Parse(llvm::MutableArrayRef<char *> argv,
44 llvm::StringRef optstring, const Option *longopts,
47 static char *GetOptionArgument();
48 static int GetOptionIndex();
49 static int GetOptionErrorCause();
50 static std::string GetShortOptionString(struct option *long_options);
54 #endif // liblldb_OptionParser_h_