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 
117  bool GetPropertyAtIndexAsArgs(const ExecutionContext *exe_ctx, uint32_t idx,
118  Args &args) const;
119 
120  bool SetPropertyAtIndexFromArgs(const ExecutionContext *exe_ctx, uint32_t idx,
121  const Args &args);
122 
123  bool GetPropertyAtIndexAsBoolean(const ExecutionContext *exe_ctx,
124  uint32_t idx, bool fail_value) const;
125 
126  bool SetPropertyAtIndexAsBoolean(const ExecutionContext *exe_ctx,
127  uint32_t idx, bool new_value);
128 
131  uint32_t idx) const;
132 
133  int64_t GetPropertyAtIndexAsEnumeration(const ExecutionContext *exe_ctx,
134  uint32_t idx,
135  int64_t fail_value) const;
136 
138  uint32_t idx, int64_t new_value);
139 
140  const FormatEntity::Entry *
142  uint32_t idx);
143 
144  const RegularExpression *
146  uint32_t idx) const;
147 
150  uint32_t idx) const;
151 
152  int64_t GetPropertyAtIndexAsSInt64(const ExecutionContext *exe_ctx,
153  uint32_t idx, int64_t fail_value) const;
154 
155  bool SetPropertyAtIndexAsSInt64(const ExecutionContext *exe_ctx, uint32_t idx,
156  int64_t new_value);
157 
158  uint64_t GetPropertyAtIndexAsUInt64(const ExecutionContext *exe_ctx,
159  uint32_t idx, uint64_t fail_value) const;
160 
161  bool SetPropertyAtIndexAsUInt64(const ExecutionContext *exe_ctx, uint32_t idx,
162  uint64_t new_value);
163 
164  llvm::StringRef GetPropertyAtIndexAsString(const ExecutionContext *exe_ctx,
165  uint32_t idx,
166  llvm::StringRef fail_value) const;
167 
168  bool SetPropertyAtIndexAsString(const ExecutionContext *exe_ctx, uint32_t idx,
169  llvm::StringRef new_value);
170 
173  bool will_modify, uint32_t idx) const;
174 
177  bool will_modify, uint32_t idx) const;
178 
180  uint32_t idx) const;
181 
183  uint32_t idx, const FileSpec &file_spec);
184 
186  const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const;
187 
189  const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const;
190 
191  void AppendProperty(ConstString name, ConstString desc,
192  bool is_global, const lldb::OptionValueSP &value_sp);
193 
194  lldb::OptionValuePropertiesSP GetSubProperty(const ExecutionContext *exe_ctx,
195  ConstString name);
196 
197  void SetValueChangedCallback(uint32_t property_idx,
198  std::function<void()> callback);
199 
200 protected:
202  return ((idx < m_properties.size()) ? &m_properties[idx] : nullptr);
203  }
204 
206  return ((idx < m_properties.size()) ? &m_properties[idx] : nullptr);
207  }
208 
210 
212  std::vector<Property> m_properties;
214 };
215 
216 } // namespace lldb_private
217 
218 #endif // LLDB_INTERPRETER_OPTIONVALUEPROPERTIES_H
lldb_private::OptionValueProperties::Apropos
void Apropos(llvm::StringRef keyword, std::vector< const Property * > &matching_properties) const
Definition: OptionValueProperties.cpp:618
lldb_private::ExecutionContext
Definition: ExecutionContext.h:292
lldb_private::OptionValueProperties::m_properties
std::vector< Property > m_properties
Definition: OptionValueProperties.h:212
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:437
lldb_private::OptionValueProperties::SetPropertyAtIndexFromArgs
bool SetPropertyAtIndexFromArgs(const ExecutionContext *exe_ctx, uint32_t idx, const Args &args)
Definition: OptionValueProperties.cpp:253
lldb_private::OptionValueProperties::GetPropertyAtIndexAsOptionValueFileSpecList
OptionValueFileSpecList * GetPropertyAtIndexAsOptionValueFileSpecList(const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const
Definition: OptionValueProperties.cpp:203
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:205
lldb_private::OptionValueProperties::GetPropertyAtIndex
virtual const Property * GetPropertyAtIndex(const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const
Definition: OptionValueProperties.cpp:180
lldb_private::OptionValueProperties::SetPropertyAtIndexAsBoolean
bool SetPropertyAtIndexAsBoolean(const ExecutionContext *exe_ctx, uint32_t idx, bool new_value)
Definition: OptionValueProperties.cpp:289
lldb_private::OptionValueArch
Definition: OptionValueArch.h:18
lldb_private::Property
Definition: Property.h:36
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:456
UniqueCStringMap.h
lldb_private::OptionValueProperties::SetPropertyAtIndexAsUInt64
bool SetPropertyAtIndexAsUInt64(const ExecutionContext *exe_ctx, uint32_t idx, uint64_t new_value)
Definition: OptionValueProperties.cpp:467
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:509
OptionValue.h
lldb_private::OptionValueProperties::GetPropertyAtIndexAsOptionValuePathMappings
OptionValuePathMappings * GetPropertyAtIndexAsOptionValuePathMappings(const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const
Definition: OptionValueProperties.cpp:194
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:220
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:414
lldb_private::OptionValueProperties::m_name
ConstString m_name
Definition: OptionValueProperties.h:211
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:89
lldb_private::OptionValueProperties::GetPropertyAtPath
virtual const Property * GetPropertyAtPath(const ExecutionContext *exe_ctx, bool will_modify, llvm::StringRef property_path) const
Definition: OptionValueProperties.cpp:573
lldb_private::OptionValueProperties::GetPropertyAtIndexAsFormatEntity
const FormatEntity::Entry * GetPropertyAtIndexAsFormatEntity(const ExecutionContext *exe_ctx, uint32_t idx)
Definition: OptionValueProperties.cpp:334
lldb_private::PropertyDefinitions
llvm::ArrayRef< PropertyDefinition > PropertyDefinitions
Definition: Property.h:34
lldb_private::OptionValueProperties::m_name_to_index
NameToIndex m_name_to_index
Definition: OptionValueProperties.h:213
lldb_private::OptionValueProperties
Definition: OptionValueProperties.h:23
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:381
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:525
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:484
lldb_private::OptionValueProperties::GetPropertyAtIndexAsBoolean
bool GetPropertyAtIndexAsBoolean(const ExecutionContext *exe_ctx, uint32_t idx, bool fail_value) const
Definition: OptionValueProperties.cpp:278
lldb_private::OptionValueProperties::GetPropertyAtIndexAsOptionValueFileSpec
OptionValueFileSpec * GetPropertyAtIndexAsOptionValueFileSpec(const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const
Definition: OptionValueProperties.cpp:346
lldb_private::OptionValueProperties::NameToIndex
UniqueCStringMap< size_t > NameToIndex
Definition: OptionValueProperties.h:209
lldb_private::OptionValueProperties::ProtectedGetPropertyAtIndex
Property * ProtectedGetPropertyAtIndex(uint32_t idx)
Definition: OptionValueProperties.h:201
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:172
lldb_private::OptionValueProperties::GetPropertyAtIndexAsFileSpec
FileSpec GetPropertyAtIndexAsFileSpec(const ExecutionContext *exe_ctx, uint32_t idx) const
Definition: OptionValueProperties.cpp:357
lldb_private::OptionValueProperties::GetSubProperty
lldb::OptionValuePropertiesSP GetSubProperty(const ExecutionContext *exe_ctx, ConstString name)
Definition: OptionValueProperties.cpp:649
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:303
lldb_private::OptionValueProperties::DumpAllDescriptions
virtual void DumpAllDescriptions(CommandInterpreter &interpreter, Stream &strm) const
Definition: OptionValueProperties.cpp:602
lldb_private::OptionValuePathMappings
Definition: OptionValuePathMappings.h:17
lldb_private::OptionValueProperties::CreateLocalCopy
static lldb::OptionValuePropertiesSP CreateLocalCopy(const Properties &global_properties)
Definition: OptionValueProperties.cpp:546
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:425
lldb_private::OptionValueProperties::GetPropertyAtIndexAsOptionValueSInt64
OptionValueSInt64 * GetPropertyAtIndexAsOptionValueSInt64(const ExecutionContext *exe_ctx, uint32_t idx) const
Definition: OptionValueProperties.cpp:392
lldb_private::OptionValueProperties::GetPropertyAtIndexAsEnumeration
int64_t GetPropertyAtIndexAsEnumeration(const ExecutionContext *exe_ctx, uint32_t idx, int64_t fail_value) const
Definition: OptionValueProperties.cpp:311
lldb_private::OptionValueProperties::GetPropertyAtIndexAsSInt64
int64_t GetPropertyAtIndexAsSInt64(const ExecutionContext *exe_ctx, uint32_t idx, int64_t fail_value) const
Definition: OptionValueProperties.cpp:403
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:185
lldb_private::OptionValueProperties::SetPropertyAtIndexAsEnumeration
bool SetPropertyAtIndexAsEnumeration(const ExecutionContext *exe_ctx, uint32_t idx, int64_t new_value)
Definition: OptionValueProperties.cpp:322
lldb_private::OptionValueProperties::DeepCopy
lldb::OptionValueSP DeepCopy(const lldb::OptionValueSP &new_parent) const override
Definition: OptionValueProperties.cpp:555
lldb_private::OptionValueProperties::SetValueChangedCallback
void SetValueChangedCallback(uint32_t property_idx, std::function< void()> callback)
Definition: OptionValueProperties.cpp:40
lldb_private::OptionValueDictionary
Definition: OptionValueDictionary.h:18
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:78
lldb_private::OptionValueProperties::GetPropertyAtIndexAsArgs
bool GetPropertyAtIndexAsArgs(const ExecutionContext *exe_ctx, uint32_t idx, Args &args) const
Definition: OptionValueProperties.cpp:228
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:368
lldb_private::OptionValueProperties::SetSubValue
Status SetSubValue(const ExecutionContext *exe_ctx, VarSetOperationType op, llvm::StringRef path, llvm::StringRef value) override
Definition: OptionValueProperties.cpp:140
lldb_private::OptionValueProperties::GetPropertyAtIndexAsOptionValueString
OptionValueString * GetPropertyAtIndexAsOptionValueString(const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const
Definition: OptionValueProperties.cpp:448
lldb_private::OptionValueProperties::GetPropertyIndex
virtual uint32_t GetPropertyIndex(ConstString name) const
Definition: OptionValueProperties.cpp:167
lldb_private::OptionValueProperties::GetPropertyAtIndexAsOptionValueArch
OptionValueArch * GetPropertyAtIndexAsOptionValueArch(const ExecutionContext *exe_ctx, uint32_t idx) const
Definition: OptionValueProperties.cpp:211
lldb_private::OptionValueProperties::GetNumProperties
virtual size_t GetNumProperties() const
Definition: OptionValueProperties.cpp:25
lldb_private::OptionValueProperties::Clear
void Clear() override
Definition: OptionValueProperties.cpp:478
lldb_private::eVarSetOperationAssign
@ eVarSetOperationAssign
Definition: lldb-private-enumerations.h:90