1 | //===-- Property.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 | |
9 | #ifndef LLDB_INTERPRETER_PROPERTY_H |
10 | #define LLDB_INTERPRETER_PROPERTY_H |
11 | |
12 | #include "lldb/Interpreter/OptionValue.h" |
13 | #include "lldb/Utility/ConstString.h" |
14 | #include "lldb/Utility/Flags.h" |
15 | #include "lldb/lldb-defines.h" |
16 | #include "lldb/lldb-private-types.h" |
17 | |
18 | #include <string> |
19 | |
20 | namespace lldb_private { |
21 | |
22 | // A structure that can be used to create a global table for all properties. |
23 | // Property class instances can be constructed using one of these. |
24 | struct PropertyDefinition { |
25 | const char *name; |
26 | OptionValue::Type type; |
27 | bool global; // false == this setting is a global setting by default |
28 | uintptr_t default_uint_value; |
29 | const char *default_cstr_value; |
30 | OptionEnumValues enum_values; |
31 | const char *description; |
32 | }; |
33 | |
34 | using PropertyDefinitions = llvm::ArrayRef<PropertyDefinition>; |
35 | |
36 | class Property { |
37 | public: |
38 | Property(const PropertyDefinition &definition); |
39 | |
40 | Property(ConstString name, ConstString desc, bool is_global, |
41 | const lldb::OptionValueSP &value_sp); |
42 | |
43 | llvm::StringRef GetName() const { return m_name.GetStringRef(); } |
44 | llvm::StringRef GetDescription() const { |
45 | return m_description.GetStringRef(); |
46 | } |
47 | |
48 | const lldb::OptionValueSP &GetValue() const { return m_value_sp; } |
49 | |
50 | void SetOptionValue(const lldb::OptionValueSP &value_sp) { |
51 | m_value_sp = value_sp; |
52 | } |
53 | |
54 | bool IsValid() const { return (bool)m_value_sp; } |
55 | |
56 | bool IsGlobal() const { return m_is_global; } |
57 | |
58 | void Dump(const ExecutionContext *exe_ctx, Stream &strm, |
59 | uint32_t dump_mask) const; |
60 | |
61 | bool DumpQualifiedName(Stream &strm) const; |
62 | |
63 | void DumpDescription(CommandInterpreter &interpreter, Stream &strm, |
64 | uint32_t output_width, |
65 | bool display_qualified_name) const; |
66 | |
67 | void SetValueChangedCallback(std::function<void()> callback); |
68 | |
69 | protected: |
70 | ConstString m_name; |
71 | ConstString m_description; |
72 | lldb::OptionValueSP m_value_sp; |
73 | bool m_is_global; |
74 | }; |
75 | |
76 | } // namespace lldb_private |
77 | |
78 | #endif // LLDB_INTERPRETER_PROPERTY_H |
79 |