1 //====-- UserSettingsController.cpp ------------------------------*- C++-*-===//
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
7 //===----------------------------------------------------------------------===//
9 #include "lldb/Core/UserSettingsController.h"
11 #include "lldb/Interpreter/OptionValueProperties.h"
12 #include "lldb/Utility/Status.h"
13 #include "lldb/Utility/Stream.h"
17 namespace lldb_private {
18 class CommandInterpreter;
20 namespace lldb_private {
23 namespace lldb_private {
24 class ExecutionContext;
26 namespace lldb_private {
31 using namespace lldb_private;
34 Properties::GetPropertyValue(const ExecutionContext *exe_ctx,
35 llvm::StringRef path, bool will_modify,
36 Status &error) const {
37 OptionValuePropertiesSP properties_sp(GetValueProperties());
39 return properties_sp->GetSubValue(exe_ctx, path, will_modify, error);
40 return lldb::OptionValueSP();
43 Status Properties::SetPropertyValue(const ExecutionContext *exe_ctx,
44 VarSetOperationType op,
46 llvm::StringRef value) {
47 OptionValuePropertiesSP properties_sp(GetValueProperties());
49 return properties_sp->SetSubValue(exe_ctx, op, path, value);
51 error.SetErrorString("no properties");
55 void Properties::DumpAllPropertyValues(const ExecutionContext *exe_ctx,
56 Stream &strm, uint32_t dump_mask) {
57 OptionValuePropertiesSP properties_sp(GetValueProperties());
59 return properties_sp->DumpValue(exe_ctx, strm, dump_mask);
62 void Properties::DumpAllDescriptions(CommandInterpreter &interpreter,
64 strm.PutCString("Top level variables:\n\n");
66 OptionValuePropertiesSP properties_sp(GetValueProperties());
68 return properties_sp->DumpAllDescriptions(interpreter, strm);
71 Status Properties::DumpPropertyValue(const ExecutionContext *exe_ctx,
73 llvm::StringRef property_path,
75 OptionValuePropertiesSP properties_sp(GetValueProperties());
77 return properties_sp->DumpPropertyValue(exe_ctx, strm, property_path,
81 error.SetErrorString("empty property list");
86 Properties::Apropos(llvm::StringRef keyword,
87 std::vector<const Property *> &matching_properties) const {
88 OptionValuePropertiesSP properties_sp(GetValueProperties());
90 properties_sp->Apropos(keyword, matching_properties);
92 return matching_properties.size();
95 lldb::OptionValuePropertiesSP
96 Properties::GetSubProperty(const ExecutionContext *exe_ctx,
98 OptionValuePropertiesSP properties_sp(GetValueProperties());
100 return properties_sp->GetSubProperty(exe_ctx, name);
101 return lldb::OptionValuePropertiesSP();
104 const char *Properties::GetExperimentalSettingsName() { return "experimental"; }
106 bool Properties::IsSettingExperimental(llvm::StringRef setting) {
110 llvm::StringRef experimental = GetExperimentalSettingsName();
111 size_t dot_pos = setting.find_first_of('.');
112 return setting.take_front(dot_pos) == experimental;