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 "lldb/lldb-python.h"
11 
12 #include <string.h>
13 #include <algorithm>
14 
15 #include "lldb/Core/UserSettingsController.h"
16 #include "lldb/Core/Error.h"
17 #include "lldb/Core/RegularExpression.h"
18 #include "lldb/Core/Stream.h"
19 #include "lldb/Core/StreamString.h"
20 #include "lldb/Interpreter/CommandInterpreter.h"
21 #include "lldb/Interpreter/OptionValueProperties.h"
22 #include "lldb/Interpreter/OptionValueString.h"
23 
24 using namespace lldb;
25 using namespace lldb_private;
26 
27 
28 lldb::OptionValueSP
29 Properties::GetPropertyValue (const ExecutionContext *exe_ctx,
30                               const char *path,
31                               bool will_modify,
32                               Error &error) const
33 {
34     OptionValuePropertiesSP properties_sp (GetValueProperties ());
35     if (properties_sp)
36         return properties_sp->GetSubValue(exe_ctx, path, will_modify, error);
37     return lldb::OptionValueSP();
38 }
39 
40 Error
41 Properties::SetPropertyValue (const ExecutionContext *exe_ctx,
42                               VarSetOperationType op,
43                               const char *path,
44                               const char *value)
45 {
46     OptionValuePropertiesSP properties_sp (GetValueProperties ());
47     if (properties_sp)
48         return properties_sp->SetSubValue(exe_ctx, op, path, value);
49     Error error;
50     error.SetErrorString ("no properties");
51     return error;
52 }
53 
54 void
55 Properties::DumpAllPropertyValues (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask)
56 {
57     OptionValuePropertiesSP properties_sp (GetValueProperties ());
58     if (properties_sp)
59         return properties_sp->DumpValue (exe_ctx, strm, dump_mask);
60 }
61 
62 void
63 Properties::DumpAllDescriptions (CommandInterpreter &interpreter,
64                                  Stream &strm) const
65 {
66     strm.PutCString("Top level variables:\n\n");
67 
68     OptionValuePropertiesSP properties_sp (GetValueProperties ());
69     if (properties_sp)
70         return properties_sp->DumpAllDescriptions (interpreter, strm);
71 }
72 
73 
74 
75 Error
76 Properties::DumpPropertyValue (const ExecutionContext *exe_ctx, Stream &strm, const char *property_path, uint32_t dump_mask)
77 {
78     OptionValuePropertiesSP properties_sp (GetValueProperties ());
79     if (properties_sp)
80     {
81         return properties_sp->DumpPropertyValue (exe_ctx,
82                                                  strm,
83                                                  property_path,
84                                                  dump_mask);
85     }
86     Error error;
87     error.SetErrorString("empty property list");
88     return error;
89 }
90 
91 size_t
92 Properties::Apropos (const char *keyword, std::vector<const Property *> &matching_properties) const
93 {
94     OptionValuePropertiesSP properties_sp (GetValueProperties ());
95     if (properties_sp)
96     {
97         properties_sp->Apropos (keyword, matching_properties);
98     }
99     return matching_properties.size();
100 }
101 
102 
103 lldb::OptionValuePropertiesSP
104 Properties::GetSubProperty (const ExecutionContext *exe_ctx,
105                             const ConstString &name)
106 {
107     OptionValuePropertiesSP properties_sp (GetValueProperties ());
108     if (properties_sp)
109         return properties_sp->GetSubProperty (exe_ctx, name);
110     return lldb::OptionValuePropertiesSP();
111 }
112 
113