]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Interpreter/OptionGroupFormat.h
MFV r329760: 7638 Refactor spa_load_impl into several functions
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / include / lldb / Interpreter / OptionGroupFormat.h
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/OptionValueFormat.h"
18 #include "lldb/Interpreter/OptionValueSInt64.h"
19 #include "lldb/Interpreter/OptionValueUInt64.h"
20 #include "lldb/Interpreter/Options.h"
21
22 namespace lldb_private {
23
24 //-------------------------------------------------------------------------
25 // OptionGroupFormat
26 //-------------------------------------------------------------------------
27
28 class OptionGroupFormat : public OptionGroup {
29 public:
30   static const uint32_t OPTION_GROUP_FORMAT = LLDB_OPT_SET_1;
31   static const uint32_t OPTION_GROUP_GDB_FMT = LLDB_OPT_SET_2;
32   static const uint32_t OPTION_GROUP_SIZE = LLDB_OPT_SET_3;
33   static const uint32_t OPTION_GROUP_COUNT = LLDB_OPT_SET_4;
34
35   OptionGroupFormat(
36       lldb::Format default_format,
37       uint64_t default_byte_size =
38           UINT64_MAX, // Pass UINT64_MAX to disable the "--size" option
39       uint64_t default_count =
40           UINT64_MAX); // Pass UINT64_MAX to disable the "--count" option
41
42   ~OptionGroupFormat() override;
43
44   llvm::ArrayRef<OptionDefinition> GetDefinitions() override;
45
46   Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value,
47                         ExecutionContext *execution_context) override;
48   Status SetOptionValue(uint32_t, const char *, ExecutionContext *) = delete;
49
50   void OptionParsingStarting(ExecutionContext *execution_context) override;
51
52   lldb::Format GetFormat() const { return m_format.GetCurrentValue(); }
53
54   OptionValueFormat &GetFormatValue() { return m_format; }
55
56   const OptionValueFormat &GetFormatValue() const { return m_format; }
57
58   OptionValueUInt64 &GetByteSizeValue() { return m_byte_size; }
59
60   const OptionValueUInt64 &GetByteSizeValue() const { return m_byte_size; }
61
62   OptionValueUInt64 &GetCountValue() { return m_count; }
63
64   const OptionValueUInt64 &GetCountValue() const { return m_count; }
65
66   bool HasGDBFormat() const { return m_has_gdb_format; }
67
68   bool AnyOptionWasSet() const {
69     return m_format.OptionWasSet() || m_byte_size.OptionWasSet() ||
70            m_count.OptionWasSet();
71   }
72
73 protected:
74   bool ParserGDBFormatLetter(ExecutionContext *execution_context,
75                              char format_letter, lldb::Format &format,
76                              uint32_t &byte_size);
77
78   OptionValueFormat m_format;
79   OptionValueUInt64 m_byte_size;
80   OptionValueUInt64 m_count;
81   char m_prev_gdb_format;
82   char m_prev_gdb_size;
83   bool m_has_gdb_format;
84 };
85
86 } // namespace lldb_private
87
88 #endif // liblldb_OptionGroupFormat_h_