]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Interpreter/OptionValueProperties.h
Merge ^/head r305087 through r305219.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / 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 {
31 public:
32     OptionValueProperties () :
33         OptionValue(),
34         m_name (),
35         m_properties (),
36         m_name_to_index ()
37     {
38     }
39
40     OptionValueProperties (const ConstString &name);
41
42     OptionValueProperties (const OptionValueProperties &global_properties);
43
44     ~OptionValueProperties() override = default;
45
46     Type
47     GetType() const override
48     {
49         return eTypeProperties;
50     }
51     
52     bool
53     Clear() override;
54
55     lldb::OptionValueSP
56     DeepCopy() const override;
57     
58     Error
59     SetValueFromString(llvm::StringRef value,
60                        VarSetOperationType op = eVarSetOperationAssign) override;
61
62     void
63     DumpValue(const ExecutionContext *exe_ctx,
64               Stream &strm,
65               uint32_t dump_mask) override;
66
67     ConstString
68     GetName() const override
69     {
70         return m_name;
71     }
72     
73     virtual Error
74     DumpPropertyValue (const ExecutionContext *exe_ctx,
75                        Stream &strm,
76                        const char *property_path,
77                        uint32_t dump_mask);
78
79     virtual void
80     DumpAllDescriptions (CommandInterpreter &interpreter,
81                          Stream &strm) const;
82
83     void
84     Apropos (const char *keyword,
85              std::vector<const Property *> &matching_properties) const;
86     
87     void
88     Initialize (const PropertyDefinition *setting_definitions);
89
90 //    bool
91 //    GetQualifiedName (Stream &strm);
92
93     //---------------------------------------------------------------------
94     // Subclass specific functions
95     //---------------------------------------------------------------------
96     
97     virtual size_t
98     GetNumProperties() const;
99     
100     virtual ConstString
101     GetPropertyNameAtIndex (uint32_t idx) const;
102
103     virtual const char *
104     GetPropertyDescriptionAtIndex (uint32_t idx) const;
105     
106     //---------------------------------------------------------------------
107     // Get the index of a property given its exact name in this property
108     // collection, "name" can't be a path to a property path that refers
109     // to a property within a property
110     //---------------------------------------------------------------------
111     virtual uint32_t
112     GetPropertyIndex (const ConstString &name) const;
113
114     //---------------------------------------------------------------------
115     // Get a property by exact name exists in this property collection, name
116     // can not be a path to a property path that refers to a property within
117     // a property
118     //---------------------------------------------------------------------
119     virtual const Property *
120     GetProperty (const ExecutionContext *exe_ctx,
121                  bool will_modify,
122                  const ConstString &name) const;
123     
124     virtual const Property *
125     GetPropertyAtIndex (const ExecutionContext *exe_ctx,
126                         bool will_modify,
127                         uint32_t idx) const;
128
129     //---------------------------------------------------------------------
130     // Property can be be a property path like "target.process.extra-startup-command"
131     //---------------------------------------------------------------------
132     virtual const Property *
133     GetPropertyAtPath (const ExecutionContext *exe_ctx,
134                        bool will_modify,
135                        const char *property_path) const;
136
137     virtual lldb::OptionValueSP
138     GetPropertyValueAtIndex (const ExecutionContext *exe_ctx,
139                              bool will_modify,
140                              uint32_t idx) const;
141     
142     virtual lldb::OptionValueSP
143     GetValueForKey  (const ExecutionContext *exe_ctx,
144                      const ConstString &key,
145                      bool value_will_be_modified) const;
146
147     lldb::OptionValueSP
148     GetSubValue(const ExecutionContext *exe_ctx,
149                 const char *name,
150                 bool value_will_be_modified,
151                 Error &error) const override;
152
153     Error
154     SetSubValue(const ExecutionContext *exe_ctx,
155                 VarSetOperationType op,
156                 const char *path,
157                 const char *value) override;
158
159     virtual bool
160     PredicateMatches (const ExecutionContext *exe_ctx,
161                       const char *predicate) const
162     {
163         return false;
164     }
165
166
167     OptionValueArch *
168     GetPropertyAtIndexAsOptionValueArch (const ExecutionContext *exe_ctx, uint32_t idx) const;
169
170     OptionValueLanguage *
171     GetPropertyAtIndexAsOptionValueLanguage (const ExecutionContext *exe_ctx, uint32_t idx) const;
172
173     bool
174     GetPropertyAtIndexAsArgs (const ExecutionContext *exe_ctx, uint32_t idx, Args &args) const;
175
176     bool
177     SetPropertyAtIndexFromArgs (const ExecutionContext *exe_ctx, uint32_t idx, const Args &args);
178     
179     bool
180     GetPropertyAtIndexAsBoolean (const ExecutionContext *exe_ctx, uint32_t idx, bool fail_value) const;
181     
182     bool
183     SetPropertyAtIndexAsBoolean (const ExecutionContext *exe_ctx, uint32_t idx, bool new_value);
184     
185     OptionValueDictionary *
186     GetPropertyAtIndexAsOptionValueDictionary (const ExecutionContext *exe_ctx, uint32_t idx) const;
187
188     int64_t
189     GetPropertyAtIndexAsEnumeration (const ExecutionContext *exe_ctx, uint32_t idx, int64_t fail_value) const;
190     
191     bool
192     SetPropertyAtIndexAsEnumeration (const ExecutionContext *exe_ctx, uint32_t idx, int64_t new_value);
193     
194     const FormatEntity::Entry *
195     GetPropertyAtIndexAsFormatEntity (const ExecutionContext *exe_ctx, uint32_t idx);
196
197     const RegularExpression *
198     GetPropertyAtIndexAsOptionValueRegex (const ExecutionContext *exe_ctx, uint32_t idx) const;
199
200     OptionValueSInt64 *
201     GetPropertyAtIndexAsOptionValueSInt64 (const ExecutionContext *exe_ctx, uint32_t idx) const;
202
203     int64_t
204     GetPropertyAtIndexAsSInt64 (const ExecutionContext *exe_ctx, uint32_t idx, int64_t fail_value) const;
205
206     bool
207     SetPropertyAtIndexAsSInt64 (const ExecutionContext *exe_ctx, uint32_t idx, int64_t new_value);
208
209     uint64_t
210     GetPropertyAtIndexAsUInt64 (const ExecutionContext *exe_ctx, uint32_t idx, uint64_t fail_value) const;
211     
212     bool
213     SetPropertyAtIndexAsUInt64 (const ExecutionContext *exe_ctx, uint32_t idx, uint64_t new_value);
214     
215     const char *
216     GetPropertyAtIndexAsString (const ExecutionContext *exe_ctx, uint32_t idx, const char *fail_value) const;
217
218     bool
219     SetPropertyAtIndexAsString (const ExecutionContext *exe_ctx, uint32_t idx, const char *new_value);
220
221     OptionValueString *
222     GetPropertyAtIndexAsOptionValueString (const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const;
223
224     OptionValueFileSpec *
225     GetPropertyAtIndexAsOptionValueFileSpec (const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const;
226
227     FileSpec
228     GetPropertyAtIndexAsFileSpec (const ExecutionContext *exe_ctx, uint32_t idx) const;
229     
230     bool
231     SetPropertyAtIndexAsFileSpec (const ExecutionContext *exe_ctx, uint32_t idx, const FileSpec &file_spec);
232
233     OptionValuePathMappings *
234     GetPropertyAtIndexAsOptionValuePathMappings (const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const;
235
236     OptionValueFileSpecList *
237     GetPropertyAtIndexAsOptionValueFileSpecList (const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const;
238
239     void
240     AppendProperty(const ConstString &name,
241                    const ConstString &desc,
242                    bool is_global,
243                    const lldb::OptionValueSP &value_sp);
244
245     lldb::OptionValuePropertiesSP
246     GetSubProperty (const ExecutionContext *exe_ctx,
247                     const ConstString &name);
248
249     void
250     SetValueChangedCallback (uint32_t property_idx,
251                              OptionValueChangedCallback callback,
252                              void *baton);
253
254 protected:
255     Property *
256     ProtectedGetPropertyAtIndex(uint32_t idx)
257     {
258         return ((idx < m_properties.size()) ? &m_properties[idx] : nullptr);
259     }
260
261     const Property *
262     ProtectedGetPropertyAtIndex(uint32_t idx) const
263     {
264         return ((idx < m_properties.size()) ? &m_properties[idx] : nullptr);
265     }
266
267     typedef UniqueCStringMap<size_t> NameToIndex;
268
269     ConstString m_name;
270     std::vector<Property> m_properties;
271     NameToIndex m_name_to_index;
272 };
273
274 } // namespace lldb_private
275
276 #endif // liblldb_OptionValueProperties_h_