]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - include/lldb/Interpreter/OptionValueProperties.h
Vendor import of lldb trunk r290819:
[FreeBSD/FreeBSD.git] / include / lldb / Interpreter / OptionValueProperties.h
1 //===-- OptionValueProperties.h ---------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef liblldb_OptionValueProperties_h_
11 #define liblldb_OptionValueProperties_h_
12
13 // C Includes
14 // C++ Includes
15 #include <vector>
16
17 // Other libraries and framework includes
18 // Project includes
19 #include "lldb/Core/ConstString.h"
20 #include "lldb/Core/FormatEntity.h"
21 #include "lldb/Core/UniqueCStringMap.h"
22 #include "lldb/Interpreter/OptionValue.h"
23 #include "lldb/Interpreter/Property.h"
24
25 namespace lldb_private {
26
27 class OptionValueProperties
28     : public OptionValue,
29       public std::enable_shared_from_this<OptionValueProperties> {
30 public:
31   OptionValueProperties()
32       : OptionValue(), m_name(), m_properties(), m_name_to_index() {}
33
34   OptionValueProperties(const ConstString &name);
35
36   OptionValueProperties(const OptionValueProperties &global_properties);
37
38   ~OptionValueProperties() override = default;
39
40   Type GetType() const override { return eTypeProperties; }
41
42   bool Clear() override;
43
44   lldb::OptionValueSP DeepCopy() const override;
45
46   Error
47   SetValueFromString(llvm::StringRef value,
48                      VarSetOperationType op = eVarSetOperationAssign) override;
49
50   void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
51                  uint32_t dump_mask) override;
52
53   ConstString GetName() const override { return m_name; }
54
55   virtual Error DumpPropertyValue(const ExecutionContext *exe_ctx, Stream &strm,
56     llvm::StringRef property_path,
57                                   uint32_t dump_mask);
58
59   virtual void DumpAllDescriptions(CommandInterpreter &interpreter,
60                                    Stream &strm) const;
61
62   void Apropos(llvm::StringRef keyword,
63                std::vector<const Property *> &matching_properties) const;
64
65   void Initialize(const PropertyDefinition *setting_definitions);
66
67   //    bool
68   //    GetQualifiedName (Stream &strm);
69
70   //---------------------------------------------------------------------
71   // Subclass specific functions
72   //---------------------------------------------------------------------
73
74   virtual size_t GetNumProperties() const;
75
76   //---------------------------------------------------------------------
77   // Get the index of a property given its exact name in this property
78   // collection, "name" can't be a path to a property path that refers
79   // to a property within a property
80   //---------------------------------------------------------------------
81   virtual uint32_t GetPropertyIndex(const ConstString &name) const;
82
83   //---------------------------------------------------------------------
84   // Get a property by exact name exists in this property collection, name
85   // can not be a path to a property path that refers to a property within
86   // a property
87   //---------------------------------------------------------------------
88   virtual const Property *GetProperty(const ExecutionContext *exe_ctx,
89                                       bool will_modify,
90                                       const ConstString &name) const;
91
92   virtual const Property *GetPropertyAtIndex(const ExecutionContext *exe_ctx,
93                                              bool will_modify,
94                                              uint32_t idx) const;
95
96   //---------------------------------------------------------------------
97   // Property can be be a property path like
98   // "target.process.extra-startup-command"
99   //---------------------------------------------------------------------
100   virtual const Property *GetPropertyAtPath(const ExecutionContext *exe_ctx,
101                                             bool will_modify,
102     llvm::StringRef property_path) const;
103
104   virtual lldb::OptionValueSP
105   GetPropertyValueAtIndex(const ExecutionContext *exe_ctx, bool will_modify,
106                           uint32_t idx) const;
107
108   virtual lldb::OptionValueSP GetValueForKey(const ExecutionContext *exe_ctx,
109                                              const ConstString &key,
110                                              bool value_will_be_modified) const;
111
112   lldb::OptionValueSP GetSubValue(const ExecutionContext *exe_ctx,
113     llvm::StringRef name, bool value_will_be_modified,
114                                   Error &error) const override;
115
116   Error SetSubValue(const ExecutionContext *exe_ctx, VarSetOperationType op,
117     llvm::StringRef path, llvm::StringRef value) override;
118
119   virtual bool PredicateMatches(const ExecutionContext *exe_ctx,
120     llvm::StringRef predicate) const {
121     return false;
122   }
123
124   OptionValueArch *
125   GetPropertyAtIndexAsOptionValueArch(const ExecutionContext *exe_ctx,
126                                       uint32_t idx) const;
127
128   OptionValueLanguage *
129   GetPropertyAtIndexAsOptionValueLanguage(const ExecutionContext *exe_ctx,
130                                           uint32_t idx) const;
131
132   bool GetPropertyAtIndexAsArgs(const ExecutionContext *exe_ctx, uint32_t idx,
133                                 Args &args) const;
134
135   bool SetPropertyAtIndexFromArgs(const ExecutionContext *exe_ctx, uint32_t idx,
136                                   const Args &args);
137
138   bool GetPropertyAtIndexAsBoolean(const ExecutionContext *exe_ctx,
139                                    uint32_t idx, bool fail_value) const;
140
141   bool SetPropertyAtIndexAsBoolean(const ExecutionContext *exe_ctx,
142                                    uint32_t idx, bool new_value);
143
144   OptionValueDictionary *
145   GetPropertyAtIndexAsOptionValueDictionary(const ExecutionContext *exe_ctx,
146                                             uint32_t idx) const;
147
148   int64_t GetPropertyAtIndexAsEnumeration(const ExecutionContext *exe_ctx,
149                                           uint32_t idx,
150                                           int64_t fail_value) const;
151
152   bool SetPropertyAtIndexAsEnumeration(const ExecutionContext *exe_ctx,
153                                        uint32_t idx, int64_t new_value);
154
155   const FormatEntity::Entry *
156   GetPropertyAtIndexAsFormatEntity(const ExecutionContext *exe_ctx,
157                                    uint32_t idx);
158
159   const RegularExpression *
160   GetPropertyAtIndexAsOptionValueRegex(const ExecutionContext *exe_ctx,
161                                        uint32_t idx) const;
162
163   OptionValueSInt64 *
164   GetPropertyAtIndexAsOptionValueSInt64(const ExecutionContext *exe_ctx,
165                                         uint32_t idx) const;
166
167   int64_t GetPropertyAtIndexAsSInt64(const ExecutionContext *exe_ctx,
168                                      uint32_t idx, int64_t fail_value) const;
169
170   bool SetPropertyAtIndexAsSInt64(const ExecutionContext *exe_ctx, uint32_t idx,
171                                   int64_t new_value);
172
173   uint64_t GetPropertyAtIndexAsUInt64(const ExecutionContext *exe_ctx,
174                                       uint32_t idx, uint64_t fail_value) const;
175
176   bool SetPropertyAtIndexAsUInt64(const ExecutionContext *exe_ctx, uint32_t idx,
177                                   uint64_t new_value);
178
179   llvm::StringRef GetPropertyAtIndexAsString(const ExecutionContext *exe_ctx,
180                                          uint32_t idx,
181                                          llvm::StringRef fail_value) const;
182
183   bool SetPropertyAtIndexAsString(const ExecutionContext *exe_ctx, uint32_t idx,
184                                   llvm::StringRef new_value);
185
186   OptionValueString *
187   GetPropertyAtIndexAsOptionValueString(const ExecutionContext *exe_ctx,
188                                         bool will_modify, uint32_t idx) const;
189
190   OptionValueFileSpec *
191   GetPropertyAtIndexAsOptionValueFileSpec(const ExecutionContext *exe_ctx,
192                                           bool will_modify, uint32_t idx) const;
193
194   FileSpec GetPropertyAtIndexAsFileSpec(const ExecutionContext *exe_ctx,
195                                         uint32_t idx) const;
196
197   bool SetPropertyAtIndexAsFileSpec(const ExecutionContext *exe_ctx,
198                                     uint32_t idx, const FileSpec &file_spec);
199
200   OptionValuePathMappings *GetPropertyAtIndexAsOptionValuePathMappings(
201       const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const;
202
203   OptionValueFileSpecList *GetPropertyAtIndexAsOptionValueFileSpecList(
204       const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const;
205
206   void AppendProperty(const ConstString &name, const ConstString &desc,
207                       bool is_global, const lldb::OptionValueSP &value_sp);
208
209   lldb::OptionValuePropertiesSP GetSubProperty(const ExecutionContext *exe_ctx,
210                                                const ConstString &name);
211
212   void SetValueChangedCallback(uint32_t property_idx,
213                                OptionValueChangedCallback callback,
214                                void *baton);
215
216 protected:
217   Property *ProtectedGetPropertyAtIndex(uint32_t idx) {
218     return ((idx < m_properties.size()) ? &m_properties[idx] : nullptr);
219   }
220
221   const Property *ProtectedGetPropertyAtIndex(uint32_t idx) const {
222     return ((idx < m_properties.size()) ? &m_properties[idx] : nullptr);
223   }
224
225   typedef UniqueCStringMap<size_t> NameToIndex;
226
227   ConstString m_name;
228   std::vector<Property> m_properties;
229   NameToIndex m_name_to_index;
230 };
231
232 } // namespace lldb_private
233
234 #endif // liblldb_OptionValueProperties_h_