blob: 62c6f97c621444e05e00cb905b433b4b7d06ae3f [file] [log] [blame]
Andrew Walbran3d2c1972020-04-07 12:24:26 +01001//===-- OptionGroupFormat.h -------------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02009#ifndef LLDB_INTERPRETER_OPTIONGROUPFORMAT_H
10#define LLDB_INTERPRETER_OPTIONGROUPFORMAT_H
Andrew Walbran3d2c1972020-04-07 12:24:26 +010011
12#include "lldb/Interpreter/OptionValueFormat.h"
13#include "lldb/Interpreter/OptionValueSInt64.h"
14#include "lldb/Interpreter/OptionValueUInt64.h"
15#include "lldb/Interpreter/Options.h"
16
17namespace lldb_private {
18
19// OptionGroupFormat
20
21class OptionGroupFormat : public OptionGroup {
22public:
23 static const uint32_t OPTION_GROUP_FORMAT = LLDB_OPT_SET_1;
24 static const uint32_t OPTION_GROUP_GDB_FMT = LLDB_OPT_SET_2;
25 static const uint32_t OPTION_GROUP_SIZE = LLDB_OPT_SET_3;
26 static const uint32_t OPTION_GROUP_COUNT = LLDB_OPT_SET_4;
27
28 OptionGroupFormat(
29 lldb::Format default_format,
30 uint64_t default_byte_size =
31 UINT64_MAX, // Pass UINT64_MAX to disable the "--size" option
32 uint64_t default_count =
33 UINT64_MAX); // Pass UINT64_MAX to disable the "--count" option
34
35 ~OptionGroupFormat() override;
36
37 llvm::ArrayRef<OptionDefinition> GetDefinitions() override;
38
39 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value,
40 ExecutionContext *execution_context) override;
41 Status SetOptionValue(uint32_t, const char *, ExecutionContext *) = delete;
42
43 void OptionParsingStarting(ExecutionContext *execution_context) override;
44
45 lldb::Format GetFormat() const { return m_format.GetCurrentValue(); }
46
47 OptionValueFormat &GetFormatValue() { return m_format; }
48
49 const OptionValueFormat &GetFormatValue() const { return m_format; }
50
51 OptionValueUInt64 &GetByteSizeValue() { return m_byte_size; }
52
53 const OptionValueUInt64 &GetByteSizeValue() const { return m_byte_size; }
54
55 OptionValueUInt64 &GetCountValue() { return m_count; }
56
57 const OptionValueUInt64 &GetCountValue() const { return m_count; }
58
59 bool HasGDBFormat() const { return m_has_gdb_format; }
60
61 bool AnyOptionWasSet() const {
62 return m_format.OptionWasSet() || m_byte_size.OptionWasSet() ||
63 m_count.OptionWasSet();
64 }
65
66protected:
67 bool ParserGDBFormatLetter(ExecutionContext *execution_context,
68 char format_letter, lldb::Format &format,
69 uint32_t &byte_size);
70
71 OptionValueFormat m_format;
72 OptionValueUInt64 m_byte_size;
73 OptionValueUInt64 m_count;
74 char m_prev_gdb_format;
75 char m_prev_gdb_size;
76 bool m_has_gdb_format;
77};
78
79} // namespace lldb_private
80
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020081#endif // LLDB_INTERPRETER_OPTIONGROUPFORMAT_H