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 OptionDefinition 32 g_option_table[] = 33 { 34 { LLDB_OPT_SET_1 , false, "outfile", 'o', required_argument, NULL, 0, eArgTypeFilename , "Specify a path for capturing command output."}, 35 { LLDB_OPT_SET_1 , false, "append-outfile" , 'apnd', no_argument, NULL, 0, eArgTypeNone , "Append to the the file specified with '--outfile <path>'."}, 36 }; 37 38 uint32_t 39 OptionGroupOutputFile::GetNumDefinitions () 40 { 41 return llvm::array_lengthof(g_option_table); 42 } 43 44 const OptionDefinition * 45 OptionGroupOutputFile::GetDefinitions () 46 { 47 return g_option_table; 48 } 49 50 Error 51 OptionGroupOutputFile::SetOptionValue (CommandInterpreter &interpreter, 52 uint32_t option_idx, 53 const char *option_arg) 54 { 55 Error error; 56 const int short_option = g_option_table[option_idx].short_option; 57 58 switch (short_option) 59 { 60 case 'o': 61 error = m_file.SetValueFromCString (option_arg); 62 break; 63 64 case 'apnd': 65 m_append.SetCurrentValue(true); 66 break; 67 68 default: 69 error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option); 70 break; 71 } 72 73 return error; 74 } 75 76 void 77 OptionGroupOutputFile::OptionParsingStarting (CommandInterpreter &interpreter) 78 { 79 m_file.Clear(); 80 m_append.Clear(); 81 } 82