1 //====-- UserSettingsController.cpp ------------------------------*- C++-*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "lldb/Core/UserSettingsController.h"
12 #include "lldb/Interpreter/OptionValueProperties.h"
13 #include "lldb/Utility/Status.h"
14 #include "lldb/Utility/Stream.h"
16 #include <memory> // for shared_ptr
18 namespace lldb_private {
19 class CommandInterpreter;
21 namespace lldb_private {
24 namespace lldb_private {
25 class ExecutionContext;
27 namespace lldb_private {
32 using namespace lldb_private;
35 Properties::GetPropertyValue(const ExecutionContext *exe_ctx,
36 llvm::StringRef path, bool will_modify,
37 Status &error) const {
38 OptionValuePropertiesSP properties_sp(GetValueProperties());
40 return properties_sp->GetSubValue(exe_ctx, path, will_modify, error);
41 return lldb::OptionValueSP();
44 Status Properties::SetPropertyValue(const ExecutionContext *exe_ctx,
45 VarSetOperationType op,
47 llvm::StringRef value) {
48 OptionValuePropertiesSP properties_sp(GetValueProperties());
50 return properties_sp->SetSubValue(exe_ctx, op, path, value);
52 error.SetErrorString("no properties");
56 void Properties::DumpAllPropertyValues(const ExecutionContext *exe_ctx,
57 Stream &strm, uint32_t dump_mask) {
58 OptionValuePropertiesSP properties_sp(GetValueProperties());
60 return properties_sp->DumpValue(exe_ctx, strm, dump_mask);
63 void Properties::DumpAllDescriptions(CommandInterpreter &interpreter,
65 strm.PutCString("Top level variables:\n\n");
67 OptionValuePropertiesSP properties_sp(GetValueProperties());
69 return properties_sp->DumpAllDescriptions(interpreter, strm);
72 Status Properties::DumpPropertyValue(const ExecutionContext *exe_ctx,
74 llvm::StringRef property_path,
76 OptionValuePropertiesSP properties_sp(GetValueProperties());
78 return properties_sp->DumpPropertyValue(exe_ctx, strm, property_path,
82 error.SetErrorString("empty property list");
87 Properties::Apropos(llvm::StringRef keyword,
88 std::vector<const Property *> &matching_properties) const {
89 OptionValuePropertiesSP properties_sp(GetValueProperties());
91 properties_sp->Apropos(keyword, matching_properties);
93 return matching_properties.size();
96 lldb::OptionValuePropertiesSP
97 Properties::GetSubProperty(const ExecutionContext *exe_ctx,
98 const ConstString &name) {
99 OptionValuePropertiesSP properties_sp(GetValueProperties());
101 return properties_sp->GetSubProperty(exe_ctx, name);
102 return lldb::OptionValuePropertiesSP();
105 const char *Properties::GetExperimentalSettingsName() { return "experimental"; }
107 bool Properties::IsSettingExperimental(llvm::StringRef setting) {
111 llvm::StringRef experimental = GetExperimentalSettingsName();
112 size_t dot_pos = setting.find_first_of('.');
113 return setting.take_front(dot_pos) == experimental;