blob: 7f6ebbf51fd78116b413076c798465c9bfe265d6 [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
Johnny Chen4003f572011-09-10 00:48:33 +000016#include "lldb/Utility/Utils.h"
Greg Clayton57b3c6b2011-04-27 22:04:39 +000017
18using namespace lldb;
19using namespace lldb_private;
20
Greg Clayton56bbdaf2011-04-28 20:55:26 +000021OptionGroupFormat::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)
Greg Clayton57b3c6b2011-04-27 22:04:39 +000029{
30}
31
32OptionGroupFormat::~OptionGroupFormat ()
33{
34}
35
36static OptionDefinition
37g_option_table[] =
38{
Johnny Chen4003f572011-09-10 00:48:33 +000039 { LLDB_OPT_SET_1 , false, "format", 'f', required_argument, NULL, 0, eArgTypeFormat , "Specify a format to be used for display."},
Greg Clayton57b3c6b2011-04-27 22:04:39 +000040};
Greg Clayton57b3c6b2011-04-27 22:04:39 +000041
42uint32_t
43OptionGroupFormat::GetNumDefinitions ()
44{
Johnny Chen4003f572011-09-10 00:48:33 +000045 return arraysize(g_option_table);
Greg Clayton57b3c6b2011-04-27 22:04:39 +000046}
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