1 //===-- OptionGroupFormat.h -------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_OptionGroupFormat_h_
11 #define liblldb_OptionGroupFormat_h_
15 // Other libraries and framework 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"
22 namespace lldb_private {
24 //-------------------------------------------------------------------------
26 //-------------------------------------------------------------------------
28 class OptionGroupFormat : public OptionGroup {
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;
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
42 ~OptionGroupFormat() override;
44 llvm::ArrayRef<OptionDefinition> GetDefinitions() override;
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;
50 void OptionParsingStarting(ExecutionContext *execution_context) override;
52 lldb::Format GetFormat() const { return m_format.GetCurrentValue(); }
54 OptionValueFormat &GetFormatValue() { return m_format; }
56 const OptionValueFormat &GetFormatValue() const { return m_format; }
58 OptionValueUInt64 &GetByteSizeValue() { return m_byte_size; }
60 const OptionValueUInt64 &GetByteSizeValue() const { return m_byte_size; }
62 OptionValueUInt64 &GetCountValue() { return m_count; }
64 const OptionValueUInt64 &GetCountValue() const { return m_count; }
66 bool HasGDBFormat() const { return m_has_gdb_format; }
68 bool AnyOptionWasSet() const {
69 return m_format.OptionWasSet() || m_byte_size.OptionWasSet() ||
70 m_count.OptionWasSet();
74 bool ParserGDBFormatLetter(ExecutionContext *execution_context,
75 char format_letter, lldb::Format &format,
78 OptionValueFormat m_format;
79 OptionValueUInt64 m_byte_size;
80 OptionValueUInt64 m_count;
81 char m_prev_gdb_format;
83 bool m_has_gdb_format;
86 } // namespace lldb_private
88 #endif // liblldb_OptionGroupFormat_h_