• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
22 namespace lldb_private {
23 
24 //-------------------------------------------------------------------------
25 // OptionGroupFormat
26 //-------------------------------------------------------------------------
27 
28 class OptionGroupFormat : public OptionGroup
29 {
30 public:
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
GetFormat()59     GetFormat () const
60     {
61         return m_format.GetCurrentValue();
62     }
63 
64     OptionValueFormat &
GetFormatValue()65     GetFormatValue()
66     {
67         return m_format;
68     }
69 
70     const OptionValueFormat &
GetFormatValue()71     GetFormatValue() const
72     {
73         return m_format;
74     }
75 
76     OptionValueUInt64  &
GetByteSizeValue()77     GetByteSizeValue()
78     {
79         return m_byte_size;
80     }
81 
82     const OptionValueUInt64  &
GetByteSizeValue()83     GetByteSizeValue() const
84     {
85         return m_byte_size;
86     }
87 
88     OptionValueUInt64  &
GetCountValue()89     GetCountValue()
90     {
91         return m_count;
92     }
93 
94     const OptionValueUInt64  &
GetCountValue()95     GetCountValue() const
96     {
97         return m_count;
98     }
99 
100     bool
HasGDBFormat()101     HasGDBFormat () const
102     {
103         return m_has_gdb_format;
104     }
105 
106     bool
AnyOptionWasSet()107     AnyOptionWasSet () const
108     {
109         return m_format.OptionWasSet() ||
110                m_byte_size.OptionWasSet() ||
111                m_count.OptionWasSet();
112     }
113 
114 protected:
115 
116     bool
117     ParserGDBFormatLetter (CommandInterpreter &interpreter,
118                            char format_letter,
119                            lldb::Format &format,
120                            uint32_t &byte_size);
121 
122     OptionValueFormat m_format;
123     OptionValueUInt64 m_byte_size;
124     OptionValueUInt64 m_count;
125     char m_prev_gdb_format;
126     char m_prev_gdb_size;
127 
128     bool m_has_gdb_format;
129 };
130 
131 } // namespace lldb_private
132 
133 #endif  // liblldb_OptionGroupFormat_h_
134