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 
14 #include "lldb/Core/FormatEntity.h"
19 
20 namespace lldb_private {
21 class Properties;
22 
24  : public Cloneable<OptionValueProperties, OptionValue>,
25  public std::enable_shared_from_this<OptionValueProperties> {
26 public:
27  OptionValueProperties() = default;
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  ConstString GetName() const override { return m_name; }
51 
52  virtual Status DumpPropertyValue(const ExecutionContext *exe_ctx,
53  Stream &strm, llvm::StringRef property_path,
54  uint32_t dump_mask);
55 
56  virtual void DumpAllDescriptions(CommandInterpreter &interpreter,
57  Stream &strm) const;
58 
59  void Apropos(llvm::StringRef keyword,
60  std::vector<const Property *> &matching_properties) const;
61 
62  void Initialize(const PropertyDefinitions &setting_definitions);
63 
64  // bool
65  // GetQualifiedName (Stream &strm);
66 
67  // Subclass specific functions
68 
69  virtual size_t GetNumProperties() const;
70 
71  // Get the index of a property given its exact name in this property
72  // collection, "name" can't be a path to a property path that refers to a
73  // property within a property
74  virtual uint32_t GetPropertyIndex(ConstString name) const;
75 
76  // Get a property by exact name exists in this property collection, name can
77  // not be a path to a property path that refers to a property within a
78  // property
79  virtual const Property *GetProperty(const ExecutionContext *exe_ctx,
80  bool will_modify,
81  ConstString name) const;
82 
83  virtual const Property *GetPropertyAtIndex(const ExecutionContext *exe_ctx,
84  bool will_modify,
85  uint32_t idx) const;
86 
87  // Property can be be a property path like
88  // "target.process.extra-startup-command"
89  virtual const Property *GetPropertyAtPath(const ExecutionContext *exe_ctx,
90  bool will_modify,
91  llvm::StringRef property_path) const;
92 
93  virtual lldb::OptionValueSP
94  GetPropertyValueAtIndex(const ExecutionContext *exe_ctx, bool will_modify,
95  uint32_t idx) const;
96 
97  virtual lldb::OptionValueSP GetValueForKey(const ExecutionContext *exe_ctx,
98  ConstString key,
99  bool value_will_be_modified) const;
100 
101  lldb::OptionValueSP GetSubValue(const ExecutionContext *exe_ctx,
102  llvm::StringRef name,
103  bool value_will_be_modified,
104  Status &error) const override;
105 
107  llvm::StringRef path, llvm::StringRef value) override;
108 
111  uint32_t idx) const;
112 
115  uint32_t idx) const;
116 
118  uint32_t idx, lldb::LanguageType lang);
119 
120  bool GetPropertyAtIndexAsArgs(const ExecutionContext *exe_ctx, uint32_t idx,
121  Args &args) const;
122 
123  bool SetPropertyAtIndexFromArgs(const ExecutionContext *exe_ctx, uint32_t idx,
124  const Args &args);
125 
126  bool GetPropertyAtIndexAsBoolean(const ExecutionContext *exe_ctx,
127  uint32_t idx, bool fail_value) const;
128 
129  bool SetPropertyAtIndexAsBoolean(const ExecutionContext *exe_ctx,
130  uint32_t idx, bool new_value);
131 
134  uint32_t idx) const;
135 
136  int64_t GetPropertyAtIndexAsEnumeration(const ExecutionContext *exe_ctx,
137  uint32_t idx,
138  int64_t fail_value) const;
139 
141  uint32_t idx, int64_t new_value);
142 
143  const FormatEntity::Entry *
145  uint32_t idx);
146 
147  const RegularExpression *
149  uint32_t idx) const;
150 
153  uint32_t idx) const;
154 
157  uint32_t idx) const;
158 
159  int64_t GetPropertyAtIndexAsSInt64(const ExecutionContext *exe_ctx,
160  uint32_t idx, int64_t fail_value) const;
161 
162  bool SetPropertyAtIndexAsSInt64(const ExecutionContext *exe_ctx, uint32_t idx,
163  int64_t new_value);
164 
165  uint64_t GetPropertyAtIndexAsUInt64(const ExecutionContext *exe_ctx,
166  uint32_t idx, uint64_t fail_value) const;
167 
168  bool SetPropertyAtIndexAsUInt64(const ExecutionContext *exe_ctx, uint32_t idx,
169  uint64_t new_value);
170 
171  llvm::StringRef GetPropertyAtIndexAsString(const ExecutionContext *exe_ctx,
172  uint32_t idx,
173  llvm::StringRef fail_value) const;
174 
175  bool SetPropertyAtIndexAsString(const ExecutionContext *exe_ctx, uint32_t idx,
176  llvm::StringRef new_value);
177 
180  bool will_modify, uint32_t idx) const;
181 
184  bool will_modify, uint32_t idx) const;
185 
187  uint32_t idx) const;
188 
190  uint32_t idx, const FileSpec &file_spec);
191 
193  const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const;
194 
196  const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const;
197 
198  void AppendProperty(ConstString name, ConstString desc,
199  bool is_global, const lldb::OptionValueSP &value_sp);
200 
201  lldb::OptionValuePropertiesSP GetSubProperty(const ExecutionContext *exe_ctx,
202  ConstString name);
203 
204  void SetValueChangedCallback(uint32_t property_idx,
205  std::function<void()> callback);
206 
207 protected:
209  return ((idx < m_properties.size()) ? &m_properties[idx] : nullptr);
210  }
211 
213  return ((idx < m_properties.size()) ? &m_properties[idx] : nullptr);
214  }
215 
217 
219  std::vector<Property> m_properties;
221 };
222 
223 } // namespace lldb_private
224 
225 #endif // LLDB_INTERPRETER_OPTIONVALUEPROPERTIES_H
lldb_private::OptionValueProperties::Apropos
void Apropos(llvm::StringRef keyword, std::vector< const Property * > &matching_properties) const
Definition: OptionValueProperties.cpp:641
lldb_private::ExecutionContext
Definition: ExecutionContext.h:292
lldb_private::OptionValueProperties::m_properties
std::vector< Property > m_properties
Definition: OptionValueProperties.h:219
lldb_private::RegularExpression
Definition: RegularExpression.h:18
lldb_private::OptionValueProperties::SetPropertyAtIndexAsString
bool SetPropertyAtIndexAsString(const ExecutionContext *exe_ctx, uint32_t idx, llvm::StringRef new_value)
Definition: OptionValueProperties.cpp:460
lldb_private::OptionValueProperties::SetPropertyAtIndexFromArgs
bool SetPropertyAtIndexFromArgs(const ExecutionContext *exe_ctx, uint32_t idx, const Args &args)
Definition: OptionValueProperties.cpp:265
lldb_private::OptionValueProperties::GetPropertyAtIndexAsOptionValueFileSpecList
OptionValueFileSpecList * GetPropertyAtIndexAsOptionValueFileSpecList(const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const
Definition: OptionValueProperties.cpp:204
lldb_private::OptionValueProperties::GetType
Type GetType() const override
Definition: OptionValueProperties.h:33
lldb_private::OptionValueProperties::ProtectedGetPropertyAtIndex
const Property * ProtectedGetPropertyAtIndex(uint32_t idx) const
Definition: OptionValueProperties.h:212
lldb_private::OptionValueProperties::GetPropertyAtIndex
virtual const Property * GetPropertyAtIndex(const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const
Definition: OptionValueProperties.cpp:181
lldb_private::OptionValueProperties::SetPropertyAtIndexAsBoolean
bool SetPropertyAtIndexAsBoolean(const ExecutionContext *exe_ctx, uint32_t idx, bool new_value)
Definition: OptionValueProperties.cpp:301
lldb::LanguageType
LanguageType
Programming language type.
Definition: lldb-enumerations.h:436
lldb_private::OptionValueArch
Definition: OptionValueArch.h:18
lldb_private::Property
Definition: Property.h:35
lldb_private::OptionValueProperties::SetPropertyAtIndexAsLanguage
bool SetPropertyAtIndexAsLanguage(const ExecutionContext *exe_ctx, uint32_t idx, lldb::LanguageType lang)
Definition: OptionValueProperties.cpp:229
lldb_private::Stream
Definition: Stream.h:28
lldb_private::Args
Definition: Args.h:33
lldb_private::OptionValueProperties::~OptionValueProperties
~OptionValueProperties() override=default
lldb_private::OptionValueProperties::GetPropertyAtIndexAsUInt64
uint64_t GetPropertyAtIndexAsUInt64(const ExecutionContext *exe_ctx, uint32_t idx, uint64_t fail_value) const
Definition: OptionValueProperties.cpp:479
UniqueCStringMap.h
lldb_private::OptionValueProperties::SetPropertyAtIndexAsUInt64
bool SetPropertyAtIndexAsUInt64(const ExecutionContext *exe_ctx, uint32_t idx, uint64_t new_value)
Definition: OptionValueProperties.cpp:490
lldb_private::Cloneable
Definition: Cloneable.h:40
lldb_private::OptionValueProperties::DumpValue
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override
Definition: OptionValueProperties.cpp:532
OptionValue.h
lldb_private::OptionValueProperties::GetPropertyAtIndexAsOptionValuePathMappings
OptionValuePathMappings * GetPropertyAtIndexAsOptionValuePathMappings(const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const
Definition: OptionValueProperties.cpp:195
lldb_private::OptionValueFileSpec
Definition: OptionValueFileSpec.h:20
lldb_private::Properties
Definition: UserSettingsController.h:33
lldb_private::OptionValueProperties::AppendProperty
void AppendProperty(ConstString name, ConstString desc, bool is_global, const lldb::OptionValueSP &value_sp)
Definition: OptionValueProperties.cpp:47
lldb_private::OptionValueProperties::GetPropertyAtIndexAsOptionValueLanguage
OptionValueLanguage * GetPropertyAtIndexAsOptionValueLanguage(const ExecutionContext *exe_ctx, uint32_t idx) const
Definition: OptionValueProperties.cpp:221
lldb_private::FileSpec
Definition: FileSpec.h:56
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
lldb_private::VarSetOperationType
VarSetOperationType
Settable state variable types.
Definition: lldb-private-enumerations.h:83
lldb_private::OptionValueLanguage
Definition: OptionValueLanguage.h:18
lldb_private::OptionValueProperties::SetPropertyAtIndexAsSInt64
bool SetPropertyAtIndexAsSInt64(const ExecutionContext *exe_ctx, uint32_t idx, int64_t new_value)
Definition: OptionValueProperties.cpp:437
lldb_private::OptionValueProperties::m_name
ConstString m_name
Definition: OptionValueProperties.h:218
lldb_private::OptionValueProperties::GetSubValue
lldb::OptionValueSP GetSubValue(const ExecutionContext *exe_ctx, llvm::StringRef name, bool value_will_be_modified, Status &error) const override
Definition: OptionValueProperties.cpp:90
lldb_private::OptionValueProperties::GetPropertyAtPath
virtual const Property * GetPropertyAtPath(const ExecutionContext *exe_ctx, bool will_modify, llvm::StringRef property_path) const
Definition: OptionValueProperties.cpp:596
lldb_private::OptionValueProperties::GetPropertyAtIndexAsFormatEntity
const FormatEntity::Entry * GetPropertyAtIndexAsFormatEntity(const ExecutionContext *exe_ctx, uint32_t idx)
Definition: OptionValueProperties.cpp:346
lldb_private::PropertyDefinitions
llvm::ArrayRef< PropertyDefinition > PropertyDefinitions
Definition: Property.h:33
lldb_private::OptionValueProperties::m_name_to_index
NameToIndex m_name_to_index
Definition: OptionValueProperties.h:220
lldb_private::OptionValueProperties
Definition: OptionValueProperties.h:23
lldb_private::OptionValueProperties::GetPropertyAtIndexAsOptionValueUInt64
OptionValueUInt64 * GetPropertyAtIndexAsOptionValueUInt64(const ExecutionContext *exe_ctx, uint32_t idx) const
Definition: OptionValueProperties.cpp:415
Property.h
lldb_private::ConstString
Definition: ConstString.h:40
lldb_private::OptionValueProperties::GetPropertyAtIndexAsOptionValueRegex
const RegularExpression * GetPropertyAtIndexAsOptionValueRegex(const ExecutionContext *exe_ctx, uint32_t idx) const
Definition: OptionValueProperties.cpp:393
lldb_private::CommandInterpreter
Definition: CommandInterpreter.h:214
lldb_private::OptionValueSInt64
Definition: OptionValueSInt64.h:17
lldb_private::OptionValueString
Definition: OptionValueString.h:20
lldb_private::OptionValueProperties::GetName
ConstString GetName() const override
Definition: OptionValueProperties.h:50
lldb_private::UniqueCStringMap< size_t >
lldb_private::OptionValueProperties::DumpPropertyValue
virtual Status DumpPropertyValue(const ExecutionContext *exe_ctx, Stream &strm, llvm::StringRef property_path, uint32_t dump_mask)
Definition: OptionValueProperties.cpp:548
lldb_private::OptionValueProperties::Initialize
void Initialize(const PropertyDefinitions &setting_definitions)
Definition: OptionValueProperties.cpp:29
lldb_private::OptionValueProperties::SetValueFromString
Status SetValueFromString(llvm::StringRef value, VarSetOperationType op=eVarSetOperationAssign) override
Definition: OptionValueProperties.cpp:507
lldb_private::OptionValueProperties::GetPropertyAtIndexAsBoolean
bool GetPropertyAtIndexAsBoolean(const ExecutionContext *exe_ctx, uint32_t idx, bool fail_value) const
Definition: OptionValueProperties.cpp:290
lldb_private::OptionValueProperties::GetPropertyAtIndexAsOptionValueFileSpec
OptionValueFileSpec * GetPropertyAtIndexAsOptionValueFileSpec(const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const
Definition: OptionValueProperties.cpp:358
lldb_private::OptionValueProperties::NameToIndex
UniqueCStringMap< size_t > NameToIndex
Definition: OptionValueProperties.h:216
lldb_private::OptionValueProperties::ProtectedGetPropertyAtIndex
Property * ProtectedGetPropertyAtIndex(uint32_t idx)
Definition: OptionValueProperties.h:208
lldb_private::Status
Definition: Status.h:44
lldb_private::OptionValue::Type
Type
Definition: OptionValue.h:26
uint32_t
lldb_private::OptionValueProperties::GetProperty
virtual const Property * GetProperty(const ExecutionContext *exe_ctx, bool will_modify, ConstString name) const
Definition: OptionValueProperties.cpp:173
lldb_private::OptionValueProperties::GetPropertyAtIndexAsFileSpec
FileSpec GetPropertyAtIndexAsFileSpec(const ExecutionContext *exe_ctx, uint32_t idx) const
Definition: OptionValueProperties.cpp:369
lldb_private::OptionValueProperties::GetSubProperty
lldb::OptionValuePropertiesSP GetSubProperty(const ExecutionContext *exe_ctx, ConstString name)
Definition: OptionValueProperties.cpp:672
lldb_private::OptionValueProperties::OptionValueProperties
OptionValueProperties()=default
lldb_private::FormatEntity::Entry
Definition: FormatEntity.h:40
FormatEntity.h
lldb_private::OptionValueProperties::GetPropertyAtIndexAsOptionValueDictionary
OptionValueDictionary * GetPropertyAtIndexAsOptionValueDictionary(const ExecutionContext *exe_ctx, uint32_t idx) const
Definition: OptionValueProperties.cpp:315
lldb_private::OptionValueProperties::DumpAllDescriptions
virtual void DumpAllDescriptions(CommandInterpreter &interpreter, Stream &strm) const
Definition: OptionValueProperties.cpp:625
lldb_private::OptionValuePathMappings
Definition: OptionValuePathMappings.h:17
lldb_private::OptionValueProperties::CreateLocalCopy
static lldb::OptionValuePropertiesSP CreateLocalCopy(const Properties &global_properties)
Definition: OptionValueProperties.cpp:569
lldb_private::OptionValueFileSpecList
Definition: OptionValueFileSpecList.h:19
lldb_private::OptionValueProperties::GetPropertyAtIndexAsString
llvm::StringRef GetPropertyAtIndexAsString(const ExecutionContext *exe_ctx, uint32_t idx, llvm::StringRef fail_value) const
Definition: OptionValueProperties.cpp:448
lldb_private::OptionValueProperties::GetPropertyAtIndexAsOptionValueSInt64
OptionValueSInt64 * GetPropertyAtIndexAsOptionValueSInt64(const ExecutionContext *exe_ctx, uint32_t idx) const
Definition: OptionValueProperties.cpp:404
lldb_private::OptionValueProperties::GetPropertyAtIndexAsEnumeration
int64_t GetPropertyAtIndexAsEnumeration(const ExecutionContext *exe_ctx, uint32_t idx, int64_t fail_value) const
Definition: OptionValueProperties.cpp:323
lldb_private::OptionValueProperties::GetPropertyAtIndexAsSInt64
int64_t GetPropertyAtIndexAsSInt64(const ExecutionContext *exe_ctx, uint32_t idx, int64_t fail_value) const
Definition: OptionValueProperties.cpp:426
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::OptionValueProperties::GetPropertyValueAtIndex
virtual lldb::OptionValueSP GetPropertyValueAtIndex(const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const
Definition: OptionValueProperties.cpp:186
lldb_private::OptionValueProperties::SetPropertyAtIndexAsEnumeration
bool SetPropertyAtIndexAsEnumeration(const ExecutionContext *exe_ctx, uint32_t idx, int64_t new_value)
Definition: OptionValueProperties.cpp:334
lldb_private::OptionValueUInt64
Definition: OptionValueUInt64.h:17
lldb_private::OptionValueProperties::DeepCopy
lldb::OptionValueSP DeepCopy(const lldb::OptionValueSP &new_parent) const override
Definition: OptionValueProperties.cpp:578
lldb_private::OptionValueProperties::SetValueChangedCallback
void SetValueChangedCallback(uint32_t property_idx, std::function< void()> callback)
Definition: OptionValueProperties.cpp:40
lldb_private::OptionValueDictionary
Definition: OptionValueDictionary.h:19
ConstString.h
lldb_private::OptionValueProperties::GetValueForKey
virtual lldb::OptionValueSP GetValueForKey(const ExecutionContext *exe_ctx, ConstString key, bool value_will_be_modified) const
Definition: OptionValueProperties.cpp:79
lldb_private::OptionValueProperties::GetPropertyAtIndexAsArgs
bool GetPropertyAtIndexAsArgs(const ExecutionContext *exe_ctx, uint32_t idx, Args &args) const
Definition: OptionValueProperties.cpp:240
lldb_private::OptionValue::eTypeProperties
@ eTypeProperties
Definition: OptionValue.h:41
lldb_private::OptionValueProperties::SetPropertyAtIndexAsFileSpec
bool SetPropertyAtIndexAsFileSpec(const ExecutionContext *exe_ctx, uint32_t idx, const FileSpec &file_spec)
Definition: OptionValueProperties.cpp:380
lldb_private::OptionValueProperties::SetSubValue
Status SetSubValue(const ExecutionContext *exe_ctx, VarSetOperationType op, llvm::StringRef path, llvm::StringRef value) override
Definition: OptionValueProperties.cpp:141
lldb_private::OptionValueProperties::GetPropertyAtIndexAsOptionValueString
OptionValueString * GetPropertyAtIndexAsOptionValueString(const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const
Definition: OptionValueProperties.cpp:471
lldb_private::OptionValueProperties::GetPropertyIndex
virtual uint32_t GetPropertyIndex(ConstString name) const
Definition: OptionValueProperties.cpp:168
lldb_private::OptionValueProperties::GetPropertyAtIndexAsOptionValueArch
OptionValueArch * GetPropertyAtIndexAsOptionValueArch(const ExecutionContext *exe_ctx, uint32_t idx) const
Definition: OptionValueProperties.cpp:212
lldb_private::OptionValueProperties::GetNumProperties
virtual size_t GetNumProperties() const
Definition: OptionValueProperties.cpp:25
lldb_private::OptionValueProperties::Clear
void Clear() override
Definition: OptionValueProperties.cpp:501
lldb_private::eVarSetOperationAssign
@ eVarSetOperationAssign
Definition: lldb-private-enumerations.h:90