blob: 797aee4be81595ec4ea6fc4801f1d0ed05ebe381 [file] [log] [blame]
Andrew Walbran3d2c1972020-04-07 12:24:26 +01001//===-- 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 liblldb_Property_h_
10#define liblldb_Property_h_
11
12#include "lldb/Interpreter/OptionValue.h"
13#include "lldb/Utility/ConstString.h"
14#include "lldb/Utility/Flags.h"
15#include "lldb/lldb-defines.h"
16#include "lldb/lldb-private-types.h"
17
18#include <string>
19
20namespace 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.
24struct PropertyDefinition {
25 const char *name;
26 OptionValue::Type type;
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
34using PropertyDefinitions = llvm::ArrayRef<PropertyDefinition>;
35
36class Property {
37public:
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(OptionValueChangedCallback callback,
68 void *baton);
69
70protected:
71 ConstString m_name;
72 ConstString m_description;
73 lldb::OptionValueSP m_value_sp;
74 bool m_is_global;
75};
76
77} // namespace lldb_private
78
79#endif // liblldb_Property_h_