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 
17 using namespace lldb;
18 using namespace lldb_private;
19 
20 OptionGroupFormat::OptionGroupFormat(lldb::Format default_format,
21                                      uint32_t default_byte_size,
22                                      bool byte_size_prefix_ok) :
23     m_format (default_format,
24               default_format,
25               default_byte_size,
26               default_byte_size,
27               byte_size_prefix_ok)
28 {
29 }
30 
31 OptionGroupFormat::~OptionGroupFormat ()
32 {
33 }
34 
35 static OptionDefinition
36 g_option_table[] =
37 {
38 { LLDB_OPT_SET_1 , false, "format", 'f', required_argument, NULL, 0, eArgTypeFormat , "Specify a format to be used for display."},
39 };
40 const uint32_t k_num_file_options = sizeof(g_option_table)/sizeof(OptionDefinition);
41 
42 uint32_t
43 OptionGroupFormat::GetNumDefinitions ()
44 {
45     return k_num_file_options;
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