LLDB  mainline
UserSettingsController.h
Go to the documentation of this file.
1 //====-- UserSettingsController.h --------------------------------*- C++-*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLDB_CORE_USERSETTINGSCONTROLLER_H
10 #define LLDB_CORE_USERSETTINGSCONTROLLER_H
11 
12 #include "lldb/Utility/Status.h"
13 #include "lldb/lldb-forward.h"
15 
16 #include "llvm/ADT/StringRef.h"
17 
18 #include <vector>
19 
20 #include <cstddef>
21 #include <cstdint>
22 
23 namespace lldb_private {
24 class CommandInterpreter;
25 class ConstString;
26 class ExecutionContext;
27 class Property;
28 class Stream;
29 }
30 
31 namespace lldb_private {
32 
33 class Properties {
34 public:
35  Properties() = default;
36 
37  Properties(const lldb::OptionValuePropertiesSP &collection_sp)
38  : m_collection_sp(collection_sp) {}
39 
40  virtual ~Properties() = default;
41 
42  virtual lldb::OptionValuePropertiesSP GetValueProperties() const {
43  // This function is virtual in case subclasses want to lazily implement
44  // creating the properties.
45  return m_collection_sp;
46  }
47 
48  virtual lldb::OptionValueSP GetPropertyValue(const ExecutionContext *exe_ctx,
49  llvm::StringRef property_path,
50  bool will_modify,
51  Status &error) const;
52 
53  virtual Status SetPropertyValue(const ExecutionContext *exe_ctx,
55  llvm::StringRef property_path,
56  llvm::StringRef value);
57 
58  virtual Status DumpPropertyValue(const ExecutionContext *exe_ctx,
59  Stream &strm, llvm::StringRef property_path,
60  uint32_t dump_mask);
61 
62  virtual void DumpAllPropertyValues(const ExecutionContext *exe_ctx,
63  Stream &strm, uint32_t dump_mask);
64 
65  virtual void DumpAllDescriptions(CommandInterpreter &interpreter,
66  Stream &strm) const;
67 
68  size_t Apropos(llvm::StringRef keyword,
69  std::vector<const Property *> &matching_properties) const;
70 
71  lldb::OptionValuePropertiesSP GetSubProperty(const ExecutionContext *exe_ctx,
72  ConstString name);
73 
74  // We sometimes need to introduce a setting to enable experimental features,
75  // but then we don't want the setting for these to cause errors when the
76  // setting goes away. Add a sub-topic of the settings using this
77  // experimental name, and two things will happen. One is that settings that
78  // don't find the name will not be treated as errors. Also, if you decide to
79  // keep the settings just move them into the containing properties, and we
80  // will auto-forward the experimental settings to the real one.
81  static const char *GetExperimentalSettingsName();
82 
83  static bool IsSettingExperimental(llvm::StringRef setting);
84 
85 protected:
86  lldb::OptionValuePropertiesSP m_collection_sp;
87 };
88 
89 } // namespace lldb_private
90 
91 #endif // LLDB_CORE_USERSETTINGSCONTROLLER_H
lldb_private::Properties::IsSettingExperimental
static bool IsSettingExperimental(llvm::StringRef setting)
Definition: UserSettingsController.cpp:106
lldb_private::Properties::Properties
Properties(const lldb::OptionValuePropertiesSP &collection_sp)
Definition: UserSettingsController.h:37
lldb_private::ExecutionContext
Definition: ExecutionContext.h:292
lldb_private::Properties::GetSubProperty
lldb::OptionValuePropertiesSP GetSubProperty(const ExecutionContext *exe_ctx, ConstString name)
Definition: UserSettingsController.cpp:96
lldb_private::Properties::GetValueProperties
virtual lldb::OptionValuePropertiesSP GetValueProperties() const
Definition: UserSettingsController.h:42
lldb_private::Stream
Definition: Stream.h:28
lldb-private-enumerations.h
lldb_private::Properties::~Properties
virtual ~Properties()=default
lldb_private::Properties
Definition: UserSettingsController.h:33
lldb_private::Properties::GetPropertyValue
virtual lldb::OptionValueSP GetPropertyValue(const ExecutionContext *exe_ctx, llvm::StringRef property_path, bool will_modify, Status &error) const
Definition: UserSettingsController.cpp:34
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
lldb_private::VarSetOperationType
VarSetOperationType
Settable state variable types.
Definition: lldb-private-enumerations.h:83
lldb_private::ConstString
Definition: ConstString.h:40
lldb_private::Properties::DumpAllPropertyValues
virtual void DumpAllPropertyValues(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask)
Definition: UserSettingsController.cpp:55
lldb_private::Properties::Apropos
size_t Apropos(llvm::StringRef keyword, std::vector< const Property * > &matching_properties) const
Definition: UserSettingsController.cpp:86
lldb_private::CommandInterpreter
Definition: CommandInterpreter.h:214
lldb_private::Properties::DumpPropertyValue
virtual Status DumpPropertyValue(const ExecutionContext *exe_ctx, Stream &strm, llvm::StringRef property_path, uint32_t dump_mask)
Definition: UserSettingsController.cpp:71
lldb_private::Properties::DumpAllDescriptions
virtual void DumpAllDescriptions(CommandInterpreter &interpreter, Stream &strm) const
Definition: UserSettingsController.cpp:62
lldb_private::Properties::GetExperimentalSettingsName
static const char * GetExperimentalSettingsName()
Definition: UserSettingsController.cpp:104
lldb_private::Status
Definition: Status.h:44
uint32_t
lldb_private::Properties::Properties
Properties()=default
lldb-forward.h
Status.h
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::Properties::m_collection_sp
lldb::OptionValuePropertiesSP m_collection_sp
Definition: UserSettingsController.h:86
lldb_private::Properties::SetPropertyValue
virtual Status SetPropertyValue(const ExecutionContext *exe_ctx, VarSetOperationType op, llvm::StringRef property_path, llvm::StringRef value)
Definition: UserSettingsController.cpp:43