1 //===-- OptionGroupFormat.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/OptionGroupFormat.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 OptionGroupFormat::OptionGroupFormat(lldb::Format default_format, 22 uint32_t default_byte_size, 23 bool byte_size_prefix_ok) : 24 m_format (default_format, 25 default_format, 26 default_byte_size, 27 default_byte_size, 28 byte_size_prefix_ok) 29 { 30 } 31 32 OptionGroupFormat::~OptionGroupFormat () 33 { 34 } 35 36 static OptionDefinition 37 g_option_table[] = 38 { 39 { LLDB_OPT_SET_1 , false, "format", 'f', required_argument, NULL, 0, eArgTypeFormat , "Specify a format to be used for display."}, 40 }; 41 42 uint32_t 43 OptionGroupFormat::GetNumDefinitions () 44 { 45 return arraysize(g_option_table); 46 } 47 48 const OptionDefinition * 49 OptionGroupFormat::GetDefinitions () 50 { 51 return g_option_table; 52 } 53 54 Error 55 OptionGroupFormat::SetOptionValue (CommandInterpreter &interpreter, 56 uint32_t option_idx, 57 const char *option_arg) 58 { 59 Error error; 60 char short_option = (char) g_option_table[option_idx].short_option; 61 62 switch (short_option) 63 { 64 case 'f': 65 error = m_format.SetValueFromCString (option_arg); 66 break; 67 68 default: 69 error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option); 70 break; 71 } 72 73 return error; 74 } 75 76 void 77 OptionGroupFormat::OptionParsingStarting (CommandInterpreter &interpreter) 78 { 79 m_format.Clear(); 80 } 81 82