1 //===-- source/Host/common/OptionParser.cpp ---------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "lldb/Host/OptionParser.h"
12 #if (!defined( _MSC_VER ) && defined( _WIN32 ))
13 #define _BSD_SOURCE // Required so that getopt.h defines optreset
15 #include "lldb/Host/HostGetOpt.h"
17 using namespace lldb_private;
20 OptionParser::Prepare()
31 OptionParser::EnableError(bool error)
33 opterr = error ? 1 : 0;
37 OptionParser::Parse (int argc,
39 const char *optstring,
40 const Option *longopts,
43 return getopt_long_only(argc, argv, optstring, (const option*)longopts, longindex);
47 OptionParser::GetOptionArgument()
53 OptionParser::GetOptionIndex()
59 OptionParser::GetOptionErrorCause()
65 OptionParser::GetShortOptionString(struct option *long_options)
72 if (long_options[i].name == 0 &&
73 long_options[i].has_arg == 0 &&
74 long_options[i].flag == 0 &&
75 long_options[i].val == 0)
81 if (long_options[i].flag == NULL &&
82 isalpha(long_options[i].val))
84 s.append(1, (char)long_options[i].val);
85 switch (long_options[i].has_arg)
91 case optional_argument:
94 case required_argument: