xref: /llvm-project/lldb/source/Core/UserSettingsController.cpp (revision e8cd0c9859bfae9b173e89f566b6f4d6b010b19f)
1 //====-- UserSettingsController.cpp ------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #include <string.h>
11 #include <algorithm>
12 
13 #include "lldb/Core/UserSettingsController.h"
14 #include "lldb/Core/Error.h"
15 #include "lldb/Core/RegularExpression.h"
16 #include "lldb/Core/Stream.h"
17 #include "lldb/Core/StreamString.h"
18 #include "lldb/Interpreter/CommandInterpreter.h"
19 #include "lldb/Interpreter/OptionValueString.h"
20 
21 using namespace lldb;
22 using namespace lldb_private;
23 
24 
25 lldb::OptionValueSP
26 Properties::GetPropertyValue (const ExecutionContext *exe_ctx,
27                               const char *path,
28                               bool will_modify,
29                               Error &error) const
30 {
31     OptionValuePropertiesSP properties_sp (GetValueProperties ());
32     if (properties_sp)
33         return properties_sp->GetSubValue(exe_ctx, path, will_modify, error);
34     return lldb::OptionValueSP();
35 }
36 
37 Error
38 Properties::SetPropertyValue (const ExecutionContext *exe_ctx,
39                               VarSetOperationType op,
40                               const char *path,
41                               const char *value)
42 {
43     OptionValuePropertiesSP properties_sp (GetValueProperties ());
44     if (properties_sp)
45         return properties_sp->SetSubValue(exe_ctx, op, path, value);
46     Error error;
47     error.SetErrorString ("no properties");
48     return error;
49 }
50 
51 void
52 Properties::DumpAllPropertyValues (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask)
53 {
54     OptionValuePropertiesSP properties_sp (GetValueProperties ());
55     if (properties_sp)
56         return properties_sp->DumpValue (exe_ctx, strm, dump_mask);
57 }
58 
59 void
60 Properties::DumpAllDescriptions (CommandInterpreter &interpreter,
61                                  Stream &strm) const
62 {
63     strm.PutCString("Top level variables:\n\n");
64 
65     OptionValuePropertiesSP properties_sp (GetValueProperties ());
66     if (properties_sp)
67         return properties_sp->DumpAllDescriptions (interpreter, strm);
68 }
69 
70 
71 
72 Error
73 Properties::DumpPropertyValue (const ExecutionContext *exe_ctx, Stream &strm, const char *property_path, uint32_t dump_mask)
74 {
75     OptionValuePropertiesSP properties_sp (GetValueProperties ());
76     if (properties_sp)
77     {
78         return properties_sp->DumpPropertyValue (exe_ctx,
79                                                  strm,
80                                                  property_path,
81                                                  dump_mask);
82     }
83     Error error;
84     error.SetErrorString("empty property list");
85     return error;
86 }
87 
88 size_t
89 Properties::Apropos (const char *keyword, std::vector<const Property *> &matching_properties) const
90 {
91     OptionValuePropertiesSP properties_sp (GetValueProperties ());
92     if (properties_sp)
93     {
94         properties_sp->Apropos (keyword, matching_properties);
95     }
96     return matching_properties.size();
97 }
98 
99 
100 lldb::OptionValuePropertiesSP
101 Properties::GetSubProperty (const ExecutionContext *exe_ctx,
102                             const ConstString &name)
103 {
104     OptionValuePropertiesSP properties_sp (GetValueProperties ());
105     if (properties_sp)
106         return properties_sp->GetSubProperty (exe_ctx, name);
107     return lldb::OptionValuePropertiesSP();
108 }
109 
110