Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:42:46

0001 //====-- UserSettingsController.h --------------------------------*- C++-*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLDB_CORE_USERSETTINGSCONTROLLER_H
0010 #define LLDB_CORE_USERSETTINGSCONTROLLER_H
0011 
0012 #include "lldb/Interpreter/OptionValueProperties.h"
0013 #include "lldb/Utility/Status.h"
0014 #include "lldb/lldb-forward.h"
0015 #include "lldb/lldb-private-enumerations.h"
0016 
0017 #include "llvm/ADT/StringRef.h"
0018 
0019 #include <vector>
0020 
0021 #include <cstddef>
0022 #include <cstdint>
0023 
0024 namespace lldb_private {
0025 class CommandInterpreter;
0026 class ExecutionContext;
0027 class Property;
0028 class Stream;
0029 }
0030 
0031 namespace lldb_private {
0032 
0033 class Properties {
0034 public:
0035   Properties();
0036 
0037   Properties(const lldb::OptionValuePropertiesSP &collection_sp);
0038 
0039   virtual ~Properties();
0040 
0041   virtual lldb::OptionValuePropertiesSP GetValueProperties() const {
0042     // This function is virtual in case subclasses want to lazily implement
0043     // creating the properties.
0044     return m_collection_sp;
0045   }
0046 
0047   virtual lldb::OptionValueSP GetPropertyValue(const ExecutionContext *exe_ctx,
0048                                                llvm::StringRef property_path,
0049                                                Status &error) const;
0050 
0051   virtual Status SetPropertyValue(const ExecutionContext *exe_ctx,
0052                                   VarSetOperationType op,
0053                                   llvm::StringRef property_path,
0054                                   llvm::StringRef value);
0055 
0056   virtual Status DumpPropertyValue(const ExecutionContext *exe_ctx,
0057                                    Stream &strm, llvm::StringRef property_path,
0058                                    uint32_t dump_mask, bool is_json = false);
0059 
0060   virtual void DumpAllPropertyValues(const ExecutionContext *exe_ctx,
0061                                      Stream &strm, uint32_t dump_mask,
0062                                      bool is_json = false);
0063 
0064   virtual void DumpAllDescriptions(CommandInterpreter &interpreter,
0065                                    Stream &strm) const;
0066 
0067   size_t Apropos(llvm::StringRef keyword,
0068                  std::vector<const Property *> &matching_properties) const;
0069 
0070   // We sometimes need to introduce a setting to enable experimental features,
0071   // but then we don't want the setting for these to cause errors when the
0072   // setting goes away.  Add a sub-topic of the settings using this
0073   // experimental name, and two things will happen.  One is that settings that
0074   // don't find the name will not be treated as errors.  Also, if you decide to
0075   // keep the settings just move them into the containing properties, and we
0076   // will auto-forward the experimental settings to the real one.
0077   static llvm::StringRef GetExperimentalSettingsName();
0078 
0079   static bool IsSettingExperimental(llvm::StringRef setting);
0080 
0081   template <typename T>
0082   T GetPropertyAtIndexAs(uint32_t idx, T default_value,
0083                          const ExecutionContext *exe_ctx = nullptr) const {
0084     return m_collection_sp->GetPropertyAtIndexAs<T>(idx, exe_ctx)
0085         .value_or(default_value);
0086   }
0087 
0088   template <typename T, typename U = typename std::remove_pointer<T>::type,
0089             std::enable_if_t<std::is_pointer_v<T>, bool> = true>
0090   const U *
0091   GetPropertyAtIndexAs(uint32_t idx,
0092                        const ExecutionContext *exe_ctx = nullptr) const {
0093     return m_collection_sp->GetPropertyAtIndexAs<T>(idx, exe_ctx);
0094   }
0095 
0096   template <typename T>
0097   bool SetPropertyAtIndex(uint32_t idx, T t,
0098                           const ExecutionContext *exe_ctx = nullptr) const {
0099     return m_collection_sp->SetPropertyAtIndex<T>(idx, t, exe_ctx);
0100   }
0101 
0102 protected:
0103   lldb::OptionValuePropertiesSP m_collection_sp;
0104 };
0105 
0106 } // namespace lldb_private
0107 
0108 #endif // LLDB_CORE_USERSETTINGSCONTROLLER_H