OptionGroupFormat.h revision c340ff885da973bcd6ac6cf5a598a71c31efdc5e
1//===-- OptionGroupFormat.h -------------------------------*- 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#ifndef liblldb_OptionGroupFormat_h_
11#define liblldb_OptionGroupFormat_h_
12
13// C Includes
14// C++ Includes
15// Other libraries and framework includes
16// Project includes
17#include "lldb/Interpreter/Options.h"
18#include "lldb/Interpreter/OptionValueFormat.h"
19#include "lldb/Interpreter/OptionValueSInt64.h"
20#include "lldb/Interpreter/OptionValueUInt64.h"
21
22namespace lldb_private {
23
24//-------------------------------------------------------------------------
25// OptionGroupFormat
26//-------------------------------------------------------------------------
27
28class OptionGroupFormat : public OptionGroup
29{
30public:
31    static const uint32_t OPTION_GROUP_FORMAT   = LLDB_OPT_SET_1;
32    static const uint32_t OPTION_GROUP_GDB_FMT  = LLDB_OPT_SET_2;
33    static const uint32_t OPTION_GROUP_SIZE     = LLDB_OPT_SET_3;
34    static const uint32_t OPTION_GROUP_COUNT    = LLDB_OPT_SET_4;
35
36    OptionGroupFormat (lldb::Format default_format,
37                       uint64_t default_byte_size = UINT64_MAX,  // Pass UINT64_MAX to disable the "--size" option
38                       uint64_t default_count = UINT64_MAX);     // Pass UINT64_MAX to disable the "--count" option
39
40    virtual
41    ~OptionGroupFormat ();
42
43
44    virtual uint32_t
45    GetNumDefinitions ();
46
47    virtual const OptionDefinition*
48    GetDefinitions ();
49
50    virtual Error
51    SetOptionValue (CommandInterpreter &interpreter,
52                    uint32_t option_idx,
53                    const char *option_value);
54
55    virtual void
56    OptionParsingStarting (CommandInterpreter &interpreter);
57
58    lldb::Format
59    GetFormat () const
60    {
61        return m_format.GetCurrentValue();
62    }
63
64    OptionValueFormat &
65    GetFormatValue()
66    {
67        return m_format;
68    }
69
70    const OptionValueFormat &
71    GetFormatValue() const
72    {
73        return m_format;
74    }
75
76    OptionValueUInt64  &
77    GetByteSizeValue()
78    {
79        return m_byte_size;
80    }
81
82    const OptionValueUInt64  &
83    GetByteSizeValue() const
84    {
85        return m_byte_size;
86    }
87
88    OptionValueUInt64  &
89    GetCountValue()
90    {
91        return m_count;
92    }
93
94    const OptionValueUInt64  &
95    GetCountValue() const
96    {
97        return m_count;
98    }
99
100
101    bool
102    AnyOptionWasSet () const
103    {
104        return m_format.OptionWasSet() ||
105               m_byte_size.OptionWasSet() ||
106               m_count.OptionWasSet();
107    }
108
109protected:
110
111    bool
112    ParserGDBFormatLetter (CommandInterpreter &interpreter,
113                           char format_letter,
114                           lldb::Format &format,
115                           uint32_t &byte_size);
116
117    OptionValueFormat m_format;
118    OptionValueUInt64 m_byte_size;
119    OptionValueUInt64 m_count;
120    char m_prev_gdb_format;
121    char m_prev_gdb_size;
122};
123
124} // namespace lldb_private
125
126#endif  // liblldb_OptionGroupFormat_h_
127