1 //===-- OptionGroupOutputFile.cpp -------------------------------*- 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 #include "lldb/Interpreter/OptionGroupOutputFile.h" 11 12 // C Includes 13 // C++ Includes 14 // Other libraries and framework includes 15 // Project includes 16 #include "lldb/Utility/Utils.h" 17 18 using namespace lldb; 19 using namespace lldb_private; 20 21 OptionGroupOutputFile::OptionGroupOutputFile() : 22 m_file (), 23 m_append (false, false) 24 { 25 } 26 27 OptionGroupOutputFile::~OptionGroupOutputFile () 28 { 29 } 30 31 static const uint32_t SHORT_OPTION_APND = 0x61706e64; // 'apnd' 32 33 static OptionDefinition 34 g_option_table[] = 35 { 36 { LLDB_OPT_SET_1 , false, "outfile", 'o', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeFilename , "Specify a path for capturing command output."}, 37 { LLDB_OPT_SET_1 , false, "append-outfile" , SHORT_OPTION_APND, 38 OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone , 39 "Append to the file specified with '--outfile <path>'."}, 40 }; 41 42 uint32_t 43 OptionGroupOutputFile::GetNumDefinitions () 44 { 45 return llvm::array_lengthof(g_option_table); 46 } 47 48 const OptionDefinition * 49 OptionGroupOutputFile::GetDefinitions () 50 { 51 return g_option_table; 52 } 53 54 Error 55 OptionGroupOutputFile::SetOptionValue(uint32_t option_idx, 56 const char *option_arg, 57 ExecutionContext *execution_context) 58 { 59 Error error; 60 const int short_option = g_option_table[option_idx].short_option; 61 62 switch (short_option) 63 { 64 case 'o': 65 error = m_file.SetValueFromString (option_arg); 66 break; 67 68 case SHORT_OPTION_APND: 69 m_append.SetCurrentValue(true); 70 break; 71 72 default: 73 error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option); 74 break; 75 } 76 77 return error; 78 } 79 80 void 81 OptionGroupOutputFile::OptionParsingStarting( 82 ExecutionContext *execution_context) 83 { 84 m_file.Clear(); 85 m_append.Clear(); 86 } 87