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
13#include "lldb/Utility/Status.h"
14#include "lldb/lldb-forward.h"
16
17#include "llvm/ADT/StringRef.h"
18
19#include <optional>
20#include <string>
21#include <vector>
22
23#include <cstddef>
24#include <cstdint>
25
26namespace lldb_private {
29class Property;
30class Stream;
31}
32
33namespace lldb_private {
34
36public:
38
39 Properties(const lldb::OptionValuePropertiesSP &collection_sp);
40
41 virtual ~Properties();
42
46
48 llvm::StringRef property_path,
49 Status &error) const;
50
51 virtual Status SetPropertyValue(const ExecutionContext *exe_ctx,
53 llvm::StringRef property_path,
54 llvm::StringRef value);
55
56 virtual Status DumpPropertyValue(const ExecutionContext *exe_ctx,
57 Stream &strm, llvm::StringRef property_path,
58 uint32_t dump_mask, bool is_json = false);
59
60 virtual void DumpAllPropertyValues(const ExecutionContext *exe_ctx,
61 Stream &strm, uint32_t dump_mask,
62 bool is_json = false);
63
64 virtual void DumpAllDescriptions(CommandInterpreter &interpreter,
65 Stream &strm, bool include_deprecated) const;
66
67 void Apropos(llvm::StringRef keyword,
68 std::vector<const Property *> &matching_properties,
69 std::vector<const Property *> &matching_property_paths) const;
70
71 /// The warning to show when the setting at \a property_path is changed, or
72 /// std::nullopt if that setting isn't deprecated.
73 std::optional<std::string>
74 GetDeprecationWarning(llvm::StringRef property_path) const;
75
76 // We sometimes need to introduce a setting to enable experimental features,
77 // but then we don't want the setting for these to cause errors when the
78 // setting goes away. Add a sub-topic of the settings using this
79 // experimental name, and two things will happen. One is that settings that
80 // don't find the name will not be treated as errors. Also, if you decide to
81 // keep the settings just move them into the containing properties, and we
82 // will auto-forward the experimental settings to the real one.
83 static llvm::StringRef GetExperimentalSettingsName();
84
85 static bool IsSettingExperimental(llvm::StringRef setting);
86
87 template <typename T>
88 T GetPropertyAtIndexAs(uint32_t idx, T default_value,
89 const ExecutionContext *exe_ctx = nullptr) const {
90 return m_collection_sp->GetPropertyAtIndexAs<T>(idx, exe_ctx)
91 .value_or(default_value);
92 }
93
94 template <typename T, typename U = typename std::remove_pointer<T>::type,
95 std::enable_if_t<std::is_pointer_v<T>, bool> = true>
96 const U *
98 const ExecutionContext *exe_ctx = nullptr) const {
99 return m_collection_sp->GetPropertyAtIndexAs<T>(idx, exe_ctx);
100 }
101
102 template <typename T>
103 bool SetPropertyAtIndex(uint32_t idx, T t,
104 const ExecutionContext *exe_ctx = nullptr) const {
105 return m_collection_sp->SetPropertyAtIndex<T>(idx, t, exe_ctx);
106 }
107
108protected:
110};
111
112} // namespace lldb_private
113
114#endif // LLDB_CORE_USERSETTINGSCONTROLLER_H
static llvm::raw_ostream & error(Stream &strm)
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
std::optional< std::string > GetDeprecationWarning(llvm::StringRef property_path) const
The warning to show when the setting at property_path is changed, or std::nullopt if that setting isn...
virtual Status DumpPropertyValue(const ExecutionContext *exe_ctx, Stream &strm, llvm::StringRef property_path, uint32_t dump_mask, bool is_json=false)
virtual void DumpAllPropertyValues(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask, bool is_json=false)
void Apropos(llvm::StringRef keyword, std::vector< const Property * > &matching_properties, std::vector< const Property * > &matching_property_paths) const
const U * GetPropertyAtIndexAs(uint32_t idx, const ExecutionContext *exe_ctx=nullptr) const
lldb::OptionValuePropertiesSP m_collection_sp
virtual Status SetPropertyValue(const ExecutionContext *exe_ctx, VarSetOperationType op, llvm::StringRef property_path, llvm::StringRef value)
virtual lldb::OptionValueSP GetPropertyValue(const ExecutionContext *exe_ctx, llvm::StringRef property_path, Status &error) const
T GetPropertyAtIndexAs(uint32_t idx, T default_value, const ExecutionContext *exe_ctx=nullptr) const
static bool IsSettingExperimental(llvm::StringRef setting)
static llvm::StringRef GetExperimentalSettingsName()
bool SetPropertyAtIndex(uint32_t idx, T t, const ExecutionContext *exe_ctx=nullptr) const
virtual void DumpAllDescriptions(CommandInterpreter &interpreter, Stream &strm, bool include_deprecated) const
lldb::OptionValuePropertiesSP GetValueProperties() const
An error handling class.
Definition Status.h:118
A stream class that can stream formatted output to a file.
Definition Stream.h:28
A class that represents a running process on the host machine.
VarSetOperationType
Settable state variable types.
std::shared_ptr< lldb_private::OptionValueProperties > OptionValuePropertiesSP
std::shared_ptr< lldb_private::OptionValue > OptionValueSP