24 : m_name(name.str()) {}
27 for (
const auto &definition : defs) {
31 property.GetValue()->SetParent(shared_from_this());
37 size_t property_idx, std::function<
void()> callback) {
40 property->SetValueChangedCallback(std::move(callback));
44 llvm::StringRef desc,
bool is_global,
46 Property property(name, desc, is_global, value_sp);
49 value_sp->SetParent(shared_from_this());
54 llvm::StringRef key)
const {
58 const size_t idx = iter->second;
71 llvm::StringRef sub_name;
73 size_t key_len = name.find_first_of(
".[{");
74 if (key_len != llvm::StringRef::npos) {
75 key = name.take_front(key_len);
76 sub_name = name.drop_front(key_len);
81 if (sub_name.empty() || !value_sp)
84 switch (sub_name[0]) {
88 value_sp->GetSubValue(exe_ctx, sub_name.drop_front(),
error);
91 const size_t experimental_len =
93 if (sub_name[experimental_len + 1] ==
'.')
94 return_val_sp = value_sp->GetSubValue(
95 exe_ctx, sub_name.drop_front(experimental_len + 2),
error);
101 return return_val_sp;
106 return value_sp->GetSubValue(exe_ctx, sub_name,
error);
117 llvm::StringRef name,
118 llvm::StringRef value) {
120 llvm::SmallVector<llvm::StringRef, 8> components;
121 name.split(components,
'.');
122 bool name_contains_experimental =
false;
123 for (
const auto &part : components)
125 name_contains_experimental =
true;
129 error = value_sp->SetValueFromString(value, op);
133 if (!name_contains_experimental &&
error.AsCString() ==
nullptr) {
134 error.SetErrorStringWithFormat(
"invalid value path '%s'",
170 return value_sp->GetAsPathMappings();
179 return value_sp->GetAsFileSpecList();
244 return property->GetValue()->GetAsDictionary();
286 return value_sp->GetAsString();
292 for (
size_t i = 0; i < num_properties; ++i)
322 Stream &strm, uint32_t dump_mask) {
324 for (
size_t i = 0; i < num_properties; ++i) {
327 OptionValue *option_value =
property->GetValue().get();
328 assert(option_value);
330 property->Dump(exe_ctx, strm, dump_mask);
331 if (!transparent_value)
339 llvm::json::Object json_properties;
341 for (
size_t i = 0; i < num_properties; ++i) {
344 OptionValue *option_value =
property->GetValue().get();
345 assert(option_value);
346 json_properties.try_emplace(property->GetName(),
347 option_value->
ToJSON(exe_ctx));
350 return json_properties;
355 llvm::StringRef property_path,
361 if (!value_sp->ValueIsTransparent()) {
370 llvm::formatv(
"{0:2}", value_sp->ToJSON(exe_ctx)).str().c_str());
372 value_sp->DumpValue(exe_ctx, strm, dump_mask);
382 auto copy_sp = global_props_sp->DeepCopy(global_props_sp->GetParent());
383 return std::static_pointer_cast<OptionValueProperties>(copy_sp);
394 for (
auto &property : props_value_ptr->m_properties) {
397 if (!property.IsGlobal()) {
398 auto value_sp =
property.GetValue()->DeepCopy(copy_sp);
399 property.SetOptionValue(value_sp);
407 llvm::StringRef name)
const {
412 llvm::StringRef sub_name;
414 size_t key_len = name.find_first_of(
".[{");
416 if (key_len != llvm::StringRef::npos) {
417 key = name.take_front(key_len);
418 sub_name = name.drop_front(key_len);
423 if (sub_name.empty() || !property)
426 if (sub_name[0] ==
'.') {
437 size_t max_name_len = 0;
439 for (
size_t i = 0; i < num_properties; ++i) {
442 max_name_len = std::max<size_t>(property->GetName().size(), max_name_len);
444 for (
size_t i = 0; i < num_properties; ++i) {
447 property->DumpDescription(interpreter, strm, max_name_len,
false);
452 llvm::StringRef keyword,
453 std::vector<const Property *> &matching_properties)
const {
456 for (
size_t i = 0; i < num_properties; ++i) {
462 properties->
Apropos(keyword, matching_properties);
465 llvm::StringRef name =
property->GetName();
466 if (name.contains_insensitive(keyword))
469 llvm::StringRef desc =
property->GetDescription();
470 if (desc.contains_insensitive(keyword))
474 matching_properties.push_back(property);
483 llvm::StringRef name) {
485 if (option_value_sp) {
488 return ov_properties->shared_from_this();
static llvm::raw_ostream & error(Stream &strm)
A command line argument class.
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
size_t GetArgs(Args &args) const
Status SetArgs(const Args &args, VarSetOperationType op)
size_t GetArgs(Args &args) const
size_t GetArgs(Args &args) const
Status SetArgs(const Args &args, VarSetOperationType op)
void AppendProperty(llvm::StringRef name, llvm::StringRef desc, bool is_global, const lldb::OptionValueSP &value_sp)
llvm::StringMap< size_t > m_name_to_index
Status SetSubValue(const ExecutionContext *exe_ctx, VarSetOperationType op, llvm::StringRef path, llvm::StringRef value) override
void Initialize(const PropertyDefinitions &setting_definitions)
OptionValueFileSpec * GetPropertyAtIndexAsOptionValueFileSpec(size_t idx, const ExecutionContext *exe_ctx=nullptr) const
void Apropos(llvm::StringRef keyword, std::vector< const Property * > &matching_properties) const
lldb::OptionValueSP DeepCopy(const lldb::OptionValueSP &new_parent) const override
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override
virtual void DumpAllDescriptions(CommandInterpreter &interpreter, Stream &strm) const
OptionValueFileSpecList * GetPropertyAtIndexAsOptionValueFileSpecList(size_t idx, const ExecutionContext *exe_ctx=nullptr) const
Property * ProtectedGetPropertyAtIndex(size_t idx)
OptionValueString * GetPropertyAtIndexAsOptionValueString(size_t idx, const ExecutionContext *exe_ctx=nullptr) 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
OptionValueDictionary * GetPropertyAtIndexAsOptionValueDictionary(size_t idx, const ExecutionContext *exe_ctx=nullptr) const
static lldb::OptionValuePropertiesSP CreateLocalCopy(const Properties &global_properties)
lldb::OptionValueSP GetSubValue(const ExecutionContext *exe_ctx, llvm::StringRef name, Status &error) const override
std::vector< Property > m_properties
void SetValueChangedCallback(size_t property_idx, std::function< void()> callback)
bool SetPropertyAtIndexFromArgs(size_t idx, const Args &args, const ExecutionContext *exe_ctx=nullptr)
Status SetValueFromString(llvm::StringRef value, VarSetOperationType op=eVarSetOperationAssign) override
virtual const Property * GetPropertyAtPath(const ExecutionContext *exe_ctx, llvm::StringRef property_path) const
virtual const Property * GetPropertyAtIndex(size_t idx, const ExecutionContext *exe_ctx=nullptr) const
virtual lldb::OptionValueSP GetValueForKey(const ExecutionContext *exe_ctx, llvm::StringRef key) const
lldb::OptionValuePropertiesSP GetSubProperty(const ExecutionContext *exe_ctx, llvm::StringRef name)
virtual lldb::OptionValueSP GetPropertyValueAtIndex(size_t idx, const ExecutionContext *exe_ctx) const
OptionValueUInt64 * GetPropertyAtIndexAsOptionValueUInt64(size_t idx, const ExecutionContext *exe_ctx=nullptr) const
OptionValuePathMappings * GetPropertyAtIndexAsOptionValuePathMappings(size_t idx, const ExecutionContext *exe_ctx=nullptr) const
OptionValueSInt64 * GetPropertyAtIndexAsOptionValueSInt64(size_t idx, const ExecutionContext *exe_ctx=nullptr) const
virtual const Property * GetProperty(llvm::StringRef name, const ExecutionContext *exe_ctx=nullptr) const
bool GetPropertyAtIndexAsArgs(size_t idx, Args &args, const ExecutionContext *exe_ctx=nullptr) const
virtual size_t GetPropertyIndex(llvm::StringRef name) const
OptionValueProperties()=default
OptionValueDictionary * GetAsDictionary()
virtual Status SetValueFromString(llvm::StringRef value, VarSetOperationType op=eVarSetOperationAssign)
OptionValueSInt64 * GetAsSInt64()
virtual llvm::json::Value ToJSON(const ExecutionContext *exe_ctx)
virtual bool ValueIsTransparent() const
OptionValueUInt64 * GetAsUInt64()
OptionValueProperties * GetAsProperties()
virtual lldb::OptionValueSP DeepCopy(const lldb::OptionValueSP &new_parent) const
OptionValueArgs * GetAsArgs()
OptionValueArray * GetAsArray()
OptionValueFileSpec * GetAsFileSpec()
static bool IsSettingExperimental(llvm::StringRef setting)
static llvm::StringRef GetExperimentalSettingsName()
virtual lldb::OptionValuePropertiesSP GetValueProperties() const
const lldb::OptionValueSP & GetValue() const
bool Success() const
Test for success condition.
A stream class that can stream formatted output to a file.
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
size_t EOL()
Output and End of Line character to the stream.
A class that represents a running process on the host machine.
llvm::ArrayRef< PropertyDefinition > PropertyDefinitions
VarSetOperationType
Settable state variable types.
@ eVarSetOperationReplace
@ eVarSetOperationInvalid
@ eVarSetOperationInsertBefore
@ eVarSetOperationInsertAfter
std::shared_ptr< lldb_private::OptionValueProperties > OptionValuePropertiesSP
std::shared_ptr< lldb_private::OptionValue > OptionValueSP