LLDB mainline
OptionValueProperties.h
Go to the documentation of this file.
1//===-- OptionValueProperties.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_OPTIONVALUEPROPERTIES_H
10#define LLDB_INTERPRETER_OPTIONVALUEPROPERTIES_H
11
12#include <vector>
13
19
20namespace lldb_private {
21class Properties;
22
24 : public Cloneable<OptionValueProperties, OptionValue>,
25 public std::enable_shared_from_this<OptionValueProperties> {
26public:
28
30
31 ~OptionValueProperties() override = default;
32
33 Type GetType() const override { return eTypeProperties; }
34
35 void Clear() override;
36
37 static lldb::OptionValuePropertiesSP
38 CreateLocalCopy(const Properties &global_properties);
39
40 lldb::OptionValueSP
41 DeepCopy(const lldb::OptionValueSP &new_parent) const override;
42
43 Status
44 SetValueFromString(llvm::StringRef value,
46
47 void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
48 uint32_t dump_mask) override;
49
50 llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) override;
51
52 ConstString GetName() const override { return m_name; }
53
54 virtual Status DumpPropertyValue(const ExecutionContext *exe_ctx,
55 Stream &strm, llvm::StringRef property_path,
56 uint32_t dump_mask, bool is_json = false);
57
58 virtual void DumpAllDescriptions(CommandInterpreter &interpreter,
59 Stream &strm) const;
60
61 void Apropos(llvm::StringRef keyword,
62 std::vector<const Property *> &matching_properties) const;
63
64 void Initialize(const PropertyDefinitions &setting_definitions);
65
66 // bool
67 // GetQualifiedName (Stream &strm);
68
69 // Subclass specific functions
70
71 virtual size_t GetNumProperties() const;
72
73 // Get the index of a property given its exact name in this property
74 // collection, "name" can't be a path to a property path that refers to a
75 // property within a property
76 virtual uint32_t GetPropertyIndex(ConstString name) const;
77
78 // Get a property by exact name exists in this property collection, name can
79 // not be a path to a property path that refers to a property within a
80 // property
81 virtual const Property *GetProperty(const ExecutionContext *exe_ctx,
82 bool will_modify,
83 ConstString name) const;
84
85 virtual const Property *GetPropertyAtIndex(const ExecutionContext *exe_ctx,
86 bool will_modify,
87 uint32_t idx) const;
88
89 // Property can be be a property path like
90 // "target.process.extra-startup-command"
91 virtual const Property *GetPropertyAtPath(const ExecutionContext *exe_ctx,
92 bool will_modify,
93 llvm::StringRef property_path) const;
94
95 virtual lldb::OptionValueSP
96 GetPropertyValueAtIndex(const ExecutionContext *exe_ctx, bool will_modify,
97 uint32_t idx) const;
98
99 virtual lldb::OptionValueSP GetValueForKey(const ExecutionContext *exe_ctx,
100 ConstString key,
101 bool value_will_be_modified) const;
102
103 lldb::OptionValueSP GetSubValue(const ExecutionContext *exe_ctx,
104 llvm::StringRef name,
105 bool value_will_be_modified,
106 Status &error) const override;
107
109 llvm::StringRef path, llvm::StringRef value) override;
110
113 uint32_t idx) const;
114
117 uint32_t idx) const;
118
120 uint32_t idx, lldb::LanguageType lang);
121
122 bool GetPropertyAtIndexAsArgs(const ExecutionContext *exe_ctx, uint32_t idx,
123 Args &args) const;
124
126 const Args &args);
127
129 uint32_t idx, bool fail_value) const;
130
132 uint32_t idx, bool new_value);
133
136 uint32_t idx) const;
137
139 uint32_t idx,
140 int64_t fail_value) const;
141
143 uint32_t idx, int64_t new_value);
144
145 const FormatEntity::Entry *
147 uint32_t idx);
148
149 const RegularExpression *
151 uint32_t idx) const;
152
155 uint32_t idx) const;
156
159 uint32_t idx) const;
160
161 int64_t GetPropertyAtIndexAsSInt64(const ExecutionContext *exe_ctx,
162 uint32_t idx, int64_t fail_value) const;
163
165 int64_t new_value);
166
167 uint64_t GetPropertyAtIndexAsUInt64(const ExecutionContext *exe_ctx,
168 uint32_t idx, uint64_t fail_value) const;
169
171 uint64_t new_value);
172
173 llvm::StringRef GetPropertyAtIndexAsString(const ExecutionContext *exe_ctx,
174 uint32_t idx,
175 llvm::StringRef fail_value) const;
176
178 llvm::StringRef new_value);
179
182 bool will_modify, uint32_t idx) const;
183
186 bool will_modify, uint32_t idx) const;
187
189 uint32_t idx) const;
190
192 uint32_t idx, const FileSpec &file_spec);
193
195 const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const;
196
198 const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const;
199
200 void AppendProperty(ConstString name, ConstString desc,
201 bool is_global, const lldb::OptionValueSP &value_sp);
202
203 lldb::OptionValuePropertiesSP GetSubProperty(const ExecutionContext *exe_ctx,
204 ConstString name);
205
206 void SetValueChangedCallback(uint32_t property_idx,
207 std::function<void()> callback);
208
209protected:
211 return ((idx < m_properties.size()) ? &m_properties[idx] : nullptr);
212 }
213
215 return ((idx < m_properties.size()) ? &m_properties[idx] : nullptr);
216 }
217
219
221 std::vector<Property> m_properties;
223};
224
225} // namespace lldb_private
226
227#endif // LLDB_INTERPRETER_OPTIONVALUEPROPERTIES_H
static llvm::raw_ostream & error(Stream &strm)
A command line argument class.
Definition: Args.h:33
A class that implements CRTP-based "virtual constructor" idiom.
Definition: Cloneable.h:40
A uniqued constant string class.
Definition: ConstString.h:39
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
A file utility class.
Definition: FileSpec.h:56
lldb::OptionValuePropertiesSP GetSubProperty(const ExecutionContext *exe_ctx, ConstString name)
virtual lldb::OptionValueSP GetPropertyValueAtIndex(const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const
Status SetSubValue(const ExecutionContext *exe_ctx, VarSetOperationType op, llvm::StringRef path, llvm::StringRef value) override
bool SetPropertyAtIndexAsString(const ExecutionContext *exe_ctx, uint32_t idx, llvm::StringRef new_value)
bool SetPropertyAtIndexAsEnumeration(const ExecutionContext *exe_ctx, uint32_t idx, int64_t new_value)
void Initialize(const PropertyDefinitions &setting_definitions)
OptionValueFileSpecList * GetPropertyAtIndexAsOptionValueFileSpecList(const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const
uint64_t GetPropertyAtIndexAsUInt64(const ExecutionContext *exe_ctx, uint32_t idx, uint64_t fail_value) const
bool SetPropertyAtIndexAsFileSpec(const ExecutionContext *exe_ctx, uint32_t idx, const FileSpec &file_spec)
OptionValueString * GetPropertyAtIndexAsOptionValueString(const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const
void Apropos(llvm::StringRef keyword, std::vector< const Property * > &matching_properties) const
virtual uint32_t GetPropertyIndex(ConstString name) const
OptionValueDictionary * GetPropertyAtIndexAsOptionValueDictionary(const ExecutionContext *exe_ctx, uint32_t idx) const
FileSpec GetPropertyAtIndexAsFileSpec(const ExecutionContext *exe_ctx, uint32_t idx) const
lldb::OptionValueSP GetSubValue(const ExecutionContext *exe_ctx, llvm::StringRef name, bool value_will_be_modified, Status &error) const override
OptionValueSInt64 * GetPropertyAtIndexAsOptionValueSInt64(const ExecutionContext *exe_ctx, uint32_t idx) const
bool SetPropertyAtIndexAsSInt64(const ExecutionContext *exe_ctx, uint32_t idx, int64_t new_value)
lldb::OptionValueSP DeepCopy(const lldb::OptionValueSP &new_parent) const override
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override
OptionValuePathMappings * GetPropertyAtIndexAsOptionValuePathMappings(const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const
int64_t GetPropertyAtIndexAsSInt64(const ExecutionContext *exe_ctx, uint32_t idx, int64_t fail_value) const
virtual const Property * GetPropertyAtIndex(const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const
virtual void DumpAllDescriptions(CommandInterpreter &interpreter, Stream &strm) const
UniqueCStringMap< size_t > NameToIndex
ConstString GetName() const override
void AppendProperty(ConstString name, ConstString desc, bool is_global, const lldb::OptionValueSP &value_sp)
virtual lldb::OptionValueSP GetValueForKey(const ExecutionContext *exe_ctx, ConstString key, bool value_will_be_modified) const
virtual Status DumpPropertyValue(const ExecutionContext *exe_ctx, Stream &strm, llvm::StringRef property_path, uint32_t dump_mask, bool is_json=false)
llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) override
bool SetPropertyAtIndexAsBoolean(const ExecutionContext *exe_ctx, uint32_t idx, bool new_value)
virtual const Property * GetProperty(const ExecutionContext *exe_ctx, bool will_modify, ConstString name) const
OptionValueLanguage * GetPropertyAtIndexAsOptionValueLanguage(const ExecutionContext *exe_ctx, uint32_t idx) const
static lldb::OptionValuePropertiesSP CreateLocalCopy(const Properties &global_properties)
OptionValueFileSpec * GetPropertyAtIndexAsOptionValueFileSpec(const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const
bool SetPropertyAtIndexAsUInt64(const ExecutionContext *exe_ctx, uint32_t idx, uint64_t new_value)
virtual const Property * GetPropertyAtPath(const ExecutionContext *exe_ctx, bool will_modify, llvm::StringRef property_path) const
void SetValueChangedCallback(uint32_t property_idx, std::function< void()> callback)
bool GetPropertyAtIndexAsArgs(const ExecutionContext *exe_ctx, uint32_t idx, Args &args) const
OptionValueUInt64 * GetPropertyAtIndexAsOptionValueUInt64(const ExecutionContext *exe_ctx, uint32_t idx) const
llvm::StringRef GetPropertyAtIndexAsString(const ExecutionContext *exe_ctx, uint32_t idx, llvm::StringRef fail_value) const
bool SetPropertyAtIndexFromArgs(const ExecutionContext *exe_ctx, uint32_t idx, const Args &args)
const FormatEntity::Entry * GetPropertyAtIndexAsFormatEntity(const ExecutionContext *exe_ctx, uint32_t idx)
const Property * ProtectedGetPropertyAtIndex(uint32_t idx) const
Property * ProtectedGetPropertyAtIndex(uint32_t idx)
bool SetPropertyAtIndexAsLanguage(const ExecutionContext *exe_ctx, uint32_t idx, lldb::LanguageType lang)
OptionValueArch * GetPropertyAtIndexAsOptionValueArch(const ExecutionContext *exe_ctx, uint32_t idx) const
Status SetValueFromString(llvm::StringRef value, VarSetOperationType op=eVarSetOperationAssign) override
const RegularExpression * GetPropertyAtIndexAsOptionValueRegex(const ExecutionContext *exe_ctx, uint32_t idx) const
~OptionValueProperties() override=default
int64_t GetPropertyAtIndexAsEnumeration(const ExecutionContext *exe_ctx, uint32_t idx, int64_t fail_value) const
bool GetPropertyAtIndexAsBoolean(const ExecutionContext *exe_ctx, uint32_t idx, bool fail_value) const
An error handling class.
Definition: Status.h:44
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< PropertyDefinition > PropertyDefinitions
Definition: Property.h:33
VarSetOperationType
Settable state variable types.
LanguageType
Programming language type.