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