Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:42:49

0001 //===-- OptionParser.h ------------------------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLDB_HOST_OPTIONPARSER_H
0010 #define LLDB_HOST_OPTIONPARSER_H
0011 
0012 #include <mutex>
0013 #include <string>
0014 
0015 #include "llvm/ADT/StringRef.h"
0016 #include "llvm/ADT/ArrayRef.h"
0017 
0018 struct option;
0019 
0020 namespace lldb_private {
0021 
0022 struct OptionDefinition;
0023 
0024 struct Option {
0025   // The definition of the option that this refers to.
0026   const OptionDefinition *definition;
0027   // if not NULL, set *flag to val when option found
0028   int *flag;
0029   // if flag not NULL, value to set *flag to; else return value
0030   int val;
0031 };
0032 
0033 class OptionParser {
0034 public:
0035   enum OptionArgument { eNoArgument = 0, eRequiredArgument, eOptionalArgument };
0036 
0037   static void Prepare(std::unique_lock<std::mutex> &lock);
0038 
0039   static void EnableError(bool error);
0040 
0041   /// Argv must be an argument vector "as passed to main", i.e. terminated with
0042   /// a nullptr.
0043   static int Parse(llvm::MutableArrayRef<char *> argv,
0044                    llvm::StringRef optstring, const Option *longopts,
0045                    int *longindex);
0046 
0047   static char *GetOptionArgument();
0048   static int GetOptionIndex();
0049   static int GetOptionErrorCause();
0050   static std::string GetShortOptionString(struct option *long_options);
0051 };
0052 }
0053 
0054 #endif // LLDB_HOST_OPTIONPARSER_H