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 <mutex> 14 #include <string> 15 16 struct option; 17 18 namespace lldb_private { 19 20 struct OptionDefinition; 21 22 struct Option 23 { 24 // The definition of the option that this refers to. 25 const OptionDefinition *definition; 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 }; 31 32 class OptionParser 33 { 34 public: 35 enum OptionArgument 36 { 37 eNoArgument = 0, 38 eRequiredArgument, 39 eOptionalArgument 40 }; 41 42 static void 43 Prepare(std::unique_lock<std::mutex> &lock); 44 45 static void EnableError(bool error); 46 47 static int Parse(int argc, char * const argv [], 48 const char *optstring, 49 const Option *longopts, int *longindex); 50 51 static char* GetOptionArgument(); 52 static int GetOptionIndex(); 53 static int GetOptionErrorCause(); 54 static std::string GetShortOptionString(struct option *long_options); 55 }; 56 57 } 58 59 #endif // liblldb_OptionParser_h_ 60