Greg Clayton | 57b3c6b | 2011-04-27 22:04:39 +0000 | [diff] [blame^] | 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 "OptionGroupFormat.h" |
| 11 | |
| 12 | // C Includes |
| 13 | // C++ Includes |
| 14 | // Other libraries and framework includes |
| 15 | // Project includes |
| 16 | |
| 17 | using namespace lldb; |
| 18 | using namespace lldb_private; |
| 19 | |
| 20 | OptionGroupFormat::OptionGroupFormat(lldb::Format default_format) : |
| 21 | m_format (default_format, default_format) |
| 22 | { |
| 23 | } |
| 24 | |
| 25 | OptionGroupFormat::~OptionGroupFormat () |
| 26 | { |
| 27 | } |
| 28 | |
| 29 | static OptionDefinition |
| 30 | g_option_table[] = |
| 31 | { |
| 32 | { LLDB_OPT_SET_1 , false, "format", 'f', required_argument, NULL, 0, eArgTypeFormat , "Specify a format to be used for display."}, |
| 33 | }; |
| 34 | const uint32_t k_num_file_options = sizeof(g_option_table)/sizeof(OptionDefinition); |
| 35 | |
| 36 | uint32_t |
| 37 | OptionGroupFormat::GetNumDefinitions () |
| 38 | { |
| 39 | return k_num_file_options; |
| 40 | } |
| 41 | |
| 42 | const OptionDefinition * |
| 43 | OptionGroupFormat::GetDefinitions () |
| 44 | { |
| 45 | return g_option_table; |
| 46 | } |
| 47 | |
| 48 | Error |
| 49 | OptionGroupFormat::SetOptionValue (CommandInterpreter &interpreter, |
| 50 | uint32_t option_idx, |
| 51 | const char *option_arg) |
| 52 | { |
| 53 | Error error; |
| 54 | char short_option = (char) g_option_table[option_idx].short_option; |
| 55 | |
| 56 | switch (short_option) |
| 57 | { |
| 58 | case 'f': |
| 59 | error = m_format.SetValueFromCString (option_arg); |
| 60 | break; |
| 61 | |
| 62 | default: |
| 63 | error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option); |
| 64 | break; |
| 65 | } |
| 66 | |
| 67 | return error; |
| 68 | } |
| 69 | |
| 70 | void |
| 71 | OptionGroupFormat::OptionParsingStarting (CommandInterpreter &interpreter) |
| 72 | { |
| 73 | m_format.Clear(); |
| 74 | } |
| 75 | |