LLDB mainline
Property.h
Go to the documentation of this file.
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
13#include "lldb/Utility/Flags.h"
14#include "lldb/Utility/Stream.h"
15#include "lldb/lldb-defines.h"
17
18#include <optional>
19#include <string>
20
21namespace lldb_private {
22
23// A structure that can be used to create a global table for all properties.
24// Property class instances can be constructed using one of these.
26 const char *name;
28 bool global; // false == this setting is a global setting by default
30 const char *default_cstr_value;
32 const char *description;
33 // Deprecated settings can still be set and shown by name, but are mostly
34 // hidden otherwise. See the Deprecated class in PropertiesBase.td.
36 // What users of a deprecated setting should do instead, or nullptr.
38};
39
41 llvm::ArrayRef<PropertyDefinition> definitions;
42 llvm::StringRef expected_path;
43};
44
45class Property {
46public:
47 Property(const PropertyDefinition &definition);
48
49 Property(llvm::StringRef name, llvm::StringRef desc, bool is_global,
50 const lldb::OptionValueSP &value_sp);
51
52 llvm::StringRef GetName() const { return m_name; }
53 llvm::StringRef GetDescription() const { return m_description; }
54
55 const lldb::OptionValueSP &GetValue() const { return m_value_sp; }
56
57 void SetOptionValue(const lldb::OptionValueSP &value_sp) {
58 m_value_sp = value_sp;
59 }
60
61 bool IsValid() const { return (bool)m_value_sp; }
62
63 bool IsGlobal() const { return m_is_global; }
64
65 bool IsDeprecated() const { return m_is_deprecated; }
66
67 /// What users of this deprecated property should do instead.
68 llvm::StringRef GetDeprecationMessage() const {
70 }
71
72 /// Whether listings should leave this property out. Deprecated properties
73 /// are only listed when \a include_deprecated is set.
74 bool IsHidden(bool include_deprecated) const {
75 return m_is_deprecated && !include_deprecated;
76 }
77
78 /// If this property is deprecated, and output produced with \a dump_mask can
79 /// be tagged, write the deprecation tag that follows the property's name.
80 void DumpDeprecatedTag(Stream &strm, uint32_t dump_mask) const;
81
82 /// The description, starting with a deprecation tag if this property is
83 /// deprecated.
84 std::string GetTaggedDescription() const;
85
86 void Dump(const ExecutionContext *exe_ctx, Stream &strm,
87 uint32_t dump_mask) const;
88
90 Stream &strm,
91 std::optional<Stream::HighlightSettings> highlight = std::nullopt) const;
92
93 void DumpDescription(
94 CommandInterpreter &interpreter, Stream &strm, uint32_t output_width,
95 bool display_qualified_name, bool include_deprecated,
96 std::optional<Stream::HighlightSettings> highlight = std::nullopt) const;
97
98 void SetValueChangedCallback(std::function<void()> callback);
99
100protected:
101 std::string m_name;
102 std::string m_description;
105 bool m_is_deprecated = false;
106 /// Points into the static PropertyDefinition table, or is nullptr.
107 const char *m_deprecation_message = nullptr;
108};
109
110} // namespace lldb_private
111
112#endif // LLDB_INTERPRETER_PROPERTY_H
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
llvm::StringRef GetName() const
Definition Property.h:52
const char * m_deprecation_message
Points into the static PropertyDefinition table, or is nullptr.
Definition Property.h:107
bool IsGlobal() const
Definition Property.h:63
void DumpDeprecatedTag(Stream &strm, uint32_t dump_mask) const
If this property is deprecated, and output produced with dump_mask can be tagged, write the deprecati...
Definition Property.cpp:255
bool IsDeprecated() const
Definition Property.h:65
const lldb::OptionValueSP & GetValue() const
Definition Property.h:55
void SetOptionValue(const lldb::OptionValueSP &value_sp)
Definition Property.h:57
bool IsHidden(bool include_deprecated) const
Whether listings should leave this property out.
Definition Property.h:74
llvm::StringRef GetDescription() const
Definition Property.h:53
lldb::OptionValueSP m_value_sp
Definition Property.h:103
bool DumpQualifiedName(Stream &strm, std::optional< Stream::HighlightSettings > highlight=std::nullopt) const
Definition Property.cpp:238
void SetValueChangedCallback(std::function< void()> callback)
Definition Property.cpp:342
llvm::StringRef GetDeprecationMessage() const
What users of this deprecated property should do instead.
Definition Property.h:68
std::string GetTaggedDescription() const
The description, starting with a deprecation tag if this property is deprecated.
Definition Property.cpp:265
void Dump(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) const
Definition Property.cpp:271
Property(const PropertyDefinition &definition)
Definition Property.cpp:22
std::string m_description
Definition Property.h:102
bool IsValid() const
Definition Property.h:61
void DumpDescription(CommandInterpreter &interpreter, Stream &strm, uint32_t output_width, bool display_qualified_name, bool include_deprecated, std::optional< Stream::HighlightSettings > highlight=std::nullopt) const
Definition Property.cpp:302
A stream class that can stream formatted output to a file.
Definition Stream.h:28
A class that represents a running process on the host machine.
llvm::ArrayRef< OptionEnumValueElement > OptionEnumValues
std::shared_ptr< lldb_private::OptionValue > OptionValueSP
llvm::ArrayRef< PropertyDefinition > definitions
Definition Property.h:41
OptionEnumValues enum_values
Definition Property.h:31