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