LLDB  mainline
Property.h
Go to the documentation of this file.
1 //===-- Property.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_INTERPRETER_PROPERTY_H
10 #define LLDB_INTERPRETER_PROPERTY_H
11 
14 #include "lldb/Utility/Flags.h"
15 #include "lldb/lldb-defines.h"
17 
18 #include <string>
19 
20 namespace lldb_private {
21 
22 // A structure that can be used to create a global table for all properties.
23 // Property class instances can be constructed using one of these.
25  const char *name;
27  bool global; // false == this setting is a global setting by default
28  uintptr_t default_uint_value;
29  const char *default_cstr_value;
30  OptionEnumValues enum_values;
31  const char *description;
32 };
33 
34 using PropertyDefinitions = llvm::ArrayRef<PropertyDefinition>;
35 
36 class Property {
37 public:
38  Property(const PropertyDefinition &definition);
39 
40  Property(ConstString name, ConstString desc, bool is_global,
41  const lldb::OptionValueSP &value_sp);
42 
43  llvm::StringRef GetName() const { return m_name.GetStringRef(); }
44  llvm::StringRef GetDescription() const {
45  return m_description.GetStringRef();
46  }
47 
48  const lldb::OptionValueSP &GetValue() const { return m_value_sp; }
49 
50  void SetOptionValue(const lldb::OptionValueSP &value_sp) {
51  m_value_sp = value_sp;
52  }
53 
54  bool IsValid() const { return (bool)m_value_sp; }
55 
56  bool IsGlobal() const { return m_is_global; }
57 
58  void Dump(const ExecutionContext *exe_ctx, Stream &strm,
59  uint32_t dump_mask) const;
60 
61  bool DumpQualifiedName(Stream &strm) const;
62 
63  void DumpDescription(CommandInterpreter &interpreter, Stream &strm,
64  uint32_t output_width,
65  bool display_qualified_name) const;
66 
67  void SetValueChangedCallback(std::function<void()> callback);
68 
69 protected:
72  lldb::OptionValueSP m_value_sp;
74 };
75 
76 } // namespace lldb_private
77 
78 #endif // LLDB_INTERPRETER_PROPERTY_H
lldb_private::ExecutionContext
Definition: ExecutionContext.h:292
lldb-private-types.h
lldb_private::Property::Property
Property(const PropertyDefinition &definition)
Definition: Property.cpp:23
lldb-defines.h
lldb_private::Property::m_value_sp
lldb::OptionValueSP m_value_sp
Definition: Property.h:72
lldb_private::Property
Definition: Property.h:36
lldb_private::Property::IsGlobal
bool IsGlobal() const
Definition: Property.h:56
lldb_private::PropertyDefinition::default_uint_value
uintptr_t default_uint_value
Definition: Property.h:28
lldb_private::PropertyDefinition::name
const char * name
Definition: Property.h:25
lldb_private::Stream
Definition: Stream.h:28
lldb_private::PropertyDefinition::type
OptionValue::Type type
Definition: Property.h:26
OptionValue.h
lldb_private::ConstString::GetStringRef
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
Definition: ConstString.h:202
lldb_private::PropertyDefinition::global
bool global
Definition: Property.h:27
lldb_private::Property::DumpQualifiedName
bool DumpQualifiedName(Stream &strm) const
Definition: Property.cpp:232
lldb_private::PropertyDefinitions
llvm::ArrayRef< PropertyDefinition > PropertyDefinitions
Definition: Property.h:34
lldb_private::Property::Dump
void Dump(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) const
Definition: Property.cpp:242
lldb_private::PropertyDefinition::default_cstr_value
const char * default_cstr_value
Definition: Property.h:29
lldb_private::ConstString
Definition: ConstString.h:40
lldb_private::Property::m_name
ConstString m_name
Definition: Property.h:70
lldb_private::PropertyDefinition::description
const char * description
Definition: Property.h:31
lldb_private::Property::DumpDescription
void DumpDescription(CommandInterpreter &interpreter, Stream &strm, uint32_t output_width, bool display_qualified_name) const
Definition: Property.cpp:270
lldb_private::CommandInterpreter
Definition: CommandInterpreter.h:214
lldb_private::Property::m_is_global
bool m_is_global
Definition: Property.h:73
lldb_private::Property::IsValid
bool IsValid() const
Definition: Property.h:54
lldb_private::OptionValue::Type
Type
Definition: OptionValue.h:26
uint32_t
lldb_private::Property::GetDescription
llvm::StringRef GetDescription() const
Definition: Property.h:44
lldb_private::PropertyDefinition::enum_values
OptionEnumValues enum_values
Definition: Property.h:30
lldb_private::Property::GetValue
const lldb::OptionValueSP & GetValue() const
Definition: Property.h:48
lldb_private::Property::SetValueChangedCallback
void SetValueChangedCallback(std::function< void()> callback)
Definition: Property.cpp:301
lldb_private::Property::GetName
llvm::StringRef GetName() const
Definition: Property.h:43
lldb_private::Property::SetOptionValue
void SetOptionValue(const lldb::OptionValueSP &value_sp)
Definition: Property.h:50
lldb_private::PropertyDefinition
Definition: Property.h:24
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::Property::m_description
ConstString m_description
Definition: Property.h:71
ConstString.h
Flags.h