blob: a42099db3c585e207ca55d2f460500cf011d5b2c [file] [log] [blame]
Greg Clayton57b3c6b2011-04-27 22:04:39 +00001//===-- 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
Johnny Chena0f34692011-05-13 20:21:08 +000010#include "lldb/Interpreter/OptionGroupFormat.h"
Greg Clayton57b3c6b2011-04-27 22:04:39 +000011
12// C Includes
13// C++ Includes
14// Other libraries and framework includes
15// Project includes
16
17using namespace lldb;
18using namespace lldb_private;
19
Greg Clayton56bbdaf2011-04-28 20:55:26 +000020OptionGroupFormat::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)
Greg Clayton57b3c6b2011-04-27 22:04:39 +000028{
29}
30
31OptionGroupFormat::~OptionGroupFormat ()
32{
33}
34
35static OptionDefinition
36g_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};
40const uint32_t k_num_file_options = sizeof(g_option_table)/sizeof(OptionDefinition);
41
42uint32_t
43OptionGroupFormat::GetNumDefinitions ()
44{
45 return k_num_file_options;
46}
47
48const OptionDefinition *
49OptionGroupFormat::GetDefinitions ()
50{
51 return g_option_table;
52}
53
54Error
55OptionGroupFormat::SetOptionValue (CommandInterpreter &interpreter,
Greg Clayton56bbdaf2011-04-28 20:55:26 +000056 uint32_t option_idx,
57 const char *option_arg)
Greg Clayton57b3c6b2011-04-27 22:04:39 +000058{
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
76void
77OptionGroupFormat::OptionParsingStarting (CommandInterpreter &interpreter)
78{
79 m_format.Clear();
80}
81