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 //static void 25 //DumpSettingEntry (CommandInterpreter &interpreter, 26 // Stream &strm, 27 // const uint32_t max_len, 28 // const SettingEntry &entry) 29 //{ 30 // StreamString description; 31 // 32 // if (entry.description) 33 // description.Printf ("%s", entry.description); 34 // 35 // if (entry.default_value && entry.default_value[0]) 36 // description.Printf (" (default: %s)", entry.default_value); 37 // 38 // interpreter.OutputFormattedHelpText (strm, 39 // entry.var_name, 40 // "--", 41 // description.GetData(), 42 // max_len); 43 // 44 // if (entry.enum_values && entry.enum_values[0].string_value) 45 // { 46 // interpreter.OutputFormattedHelpText (strm, 47 // "", 48 // " ", 49 // "Enumeration values:", 50 // max_len); 51 // for (uint32_t enum_idx=0; entry.enum_values[enum_idx].string_value != NULL; ++enum_idx) 52 // { 53 // description.Clear(); 54 // if (entry.enum_values[enum_idx].usage) 55 // description.Printf ("%s = %s", 56 // entry.enum_values[enum_idx].string_value, 57 // entry.enum_values[enum_idx].usage); 58 // else 59 // description.Printf ("%s", entry.enum_values[enum_idx].string_value); 60 // interpreter.OutputFormattedHelpText (strm, 61 // "", 62 // " ", 63 // description.GetData(), 64 // max_len); 65 // } 66 // } 67 //} 68 69 lldb::OptionValueSP 70 Properties::GetPropertyValue (const ExecutionContext *exe_ctx, 71 const char *path, 72 bool will_modify, 73 Error &error) const 74 { 75 OptionValuePropertiesSP properties_sp (GetValueProperties ()); 76 if (properties_sp) 77 return properties_sp->GetSubValue(exe_ctx, path, will_modify, error); 78 return lldb::OptionValueSP(); 79 } 80 81 Error 82 Properties::SetPropertyValue (const ExecutionContext *exe_ctx, 83 VarSetOperationType op, 84 const char *path, 85 const char *value) 86 { 87 OptionValuePropertiesSP properties_sp (GetValueProperties ()); 88 if (properties_sp) 89 return properties_sp->SetSubValue(exe_ctx, op, path, value); 90 Error error; 91 error.SetErrorString ("no properties"); 92 return error; 93 } 94 95 void 96 Properties::DumpAllPropertyValues (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) 97 { 98 OptionValuePropertiesSP properties_sp (GetValueProperties ()); 99 if (properties_sp) 100 return properties_sp->DumpValue (exe_ctx, strm, dump_mask); 101 } 102 103 void 104 Properties::DumpAllDescriptions (CommandInterpreter &interpreter, 105 Stream &strm) const 106 { 107 strm.PutCString("Top level variables:\n\n"); 108 109 OptionValuePropertiesSP properties_sp (GetValueProperties ()); 110 if (properties_sp) 111 return properties_sp->DumpAllDescriptions (interpreter, strm); 112 } 113 114 115 116 Error 117 Properties::DumpPropertyValue (const ExecutionContext *exe_ctx, Stream &strm, const char *property_path, uint32_t dump_mask) 118 { 119 OptionValuePropertiesSP properties_sp (GetValueProperties ()); 120 if (properties_sp) 121 { 122 return properties_sp->DumpPropertyValue (exe_ctx, 123 strm, 124 property_path, 125 dump_mask); 126 } 127 Error error; 128 error.SetErrorString("empty property list"); 129 return error; 130 } 131 132 size_t 133 Properties::Apropos (const char *keyword, std::vector<const Property *> &matching_properties) const 134 { 135 OptionValuePropertiesSP properties_sp (GetValueProperties ()); 136 if (properties_sp) 137 { 138 properties_sp->Apropos (keyword, matching_properties); 139 } 140 return matching_properties.size(); 141 } 142