1 //===-- OptionValueProperties.h --------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_OptionValueProperties_h_
11 #define liblldb_OptionValueProperties_h_
15 // Other libraries and framework includes
17 #include "lldb/Core/ConstString.h"
18 #include "lldb/Core/UniqueCStringMap.h"
19 #include "lldb/Interpreter/OptionValue.h"
20 #include "lldb/Interpreter/Property.h"
22 namespace lldb_private {
24 class OptionValueProperties :
26 public std::enable_shared_from_this<OptionValueProperties>
30 //---------------------------------------------------------------------
31 // OptionValueProperties
32 //---------------------------------------------------------------------
33 OptionValueProperties () :
41 OptionValueProperties (const ConstString &name);
43 OptionValueProperties (const OptionValueProperties &global_properties);
46 ~OptionValueProperties()
53 return eTypeProperties;
59 virtual lldb::OptionValueSP
63 SetValueFromCString (const char *value, VarSetOperationType op = eVarSetOperationAssign);
66 DumpValue (const ExecutionContext *exe_ctx,
77 DumpPropertyValue (const ExecutionContext *exe_ctx,
79 const char *property_path,
83 DumpAllDescriptions (CommandInterpreter &interpreter,
87 Apropos (const char *keyword,
88 std::vector<const Property *> &matching_properties) const;
91 Initialize (const PropertyDefinition *setting_definitions);
94 // GetQualifiedName (Stream &strm);
96 //---------------------------------------------------------------------
97 // Subclass specific functions
98 //---------------------------------------------------------------------
101 GetNumProperties() const;
104 GetPropertyNameAtIndex (uint32_t idx) const;
107 GetPropertyDescriptionAtIndex (uint32_t idx) const;
109 //---------------------------------------------------------------------
110 // Get the index of a property given its exact name in this property
111 // collection, "name" can't be a path to a property path that refers
112 // to a property within a property
113 //---------------------------------------------------------------------
115 GetPropertyIndex (const ConstString &name) const;
117 //---------------------------------------------------------------------
118 // Get a property by exact name exists in this property collection, name
119 // can not be a path to a property path that refers to a property within
121 //---------------------------------------------------------------------
122 virtual const Property *
123 GetProperty (const ExecutionContext *exe_ctx,
125 const ConstString &name) const;
127 virtual const Property *
128 GetPropertyAtIndex (const ExecutionContext *exe_ctx,
132 //---------------------------------------------------------------------
133 // Property can be be a property path like "target.process.extra-startup-command"
134 //---------------------------------------------------------------------
135 virtual const Property *
136 GetPropertyAtPath (const ExecutionContext *exe_ctx,
138 const char *property_path) const;
140 virtual lldb::OptionValueSP
141 GetPropertyValueAtIndex (const ExecutionContext *exe_ctx,
145 virtual lldb::OptionValueSP
146 GetValueForKey (const ExecutionContext *exe_ctx,
147 const ConstString &key,
148 bool value_will_be_modified) const;
151 GetSubValue (const ExecutionContext *exe_ctx,
153 bool value_will_be_modified,
157 SetSubValue (const ExecutionContext *exe_ctx,
158 VarSetOperationType op,
163 PredicateMatches (const ExecutionContext *exe_ctx,
164 const char *predicate) const
171 GetPropertyAtIndexAsOptionValueArch (const ExecutionContext *exe_ctx, uint32_t idx) const;
174 GetPropertyAtIndexAsArgs (const ExecutionContext *exe_ctx, uint32_t idx, Args &args) const;
177 SetPropertyAtIndexFromArgs (const ExecutionContext *exe_ctx, uint32_t idx, const Args &args);
180 GetPropertyAtIndexAsBoolean (const ExecutionContext *exe_ctx, uint32_t idx, bool fail_value) const;
183 SetPropertyAtIndexAsBoolean (const ExecutionContext *exe_ctx, uint32_t idx, bool new_value);
185 OptionValueDictionary *
186 GetPropertyAtIndexAsOptionValueDictionary (const ExecutionContext *exe_ctx, uint32_t idx) const;
189 GetPropertyAtIndexAsEnumeration (const ExecutionContext *exe_ctx, uint32_t idx, int64_t fail_value) const;
192 SetPropertyAtIndexAsEnumeration (const ExecutionContext *exe_ctx, uint32_t idx, int64_t new_value);
194 const RegularExpression *
195 GetPropertyAtIndexAsOptionValueRegex (const ExecutionContext *exe_ctx, uint32_t idx) const;
198 GetPropertyAtIndexAsOptionValueSInt64 (const ExecutionContext *exe_ctx, uint32_t idx) const;
201 GetPropertyAtIndexAsSInt64 (const ExecutionContext *exe_ctx, uint32_t idx, int64_t fail_value) const;
204 SetPropertyAtIndexAsSInt64 (const ExecutionContext *exe_ctx, uint32_t idx, int64_t new_value);
207 GetPropertyAtIndexAsUInt64 (const ExecutionContext *exe_ctx, uint32_t idx, uint64_t fail_value) const;
210 SetPropertyAtIndexAsUInt64 (const ExecutionContext *exe_ctx, uint32_t idx, uint64_t new_value);
213 GetPropertyAtIndexAsString (const ExecutionContext *exe_ctx, uint32_t idx, const char *fail_value) const;
216 SetPropertyAtIndexAsString (const ExecutionContext *exe_ctx, uint32_t idx, const char *new_value);
219 GetPropertyAtIndexAsOptionValueString (const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const;
221 OptionValueFileSpec *
222 GetPropertyAtIndexAsOptionValueFileSpec (const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const;
225 GetPropertyAtIndexAsFileSpec (const ExecutionContext *exe_ctx, uint32_t idx) const;
228 SetPropertyAtIndexAsFileSpec (const ExecutionContext *exe_ctx, uint32_t idx, const FileSpec &file_spec);
230 OptionValuePathMappings *
231 GetPropertyAtIndexAsOptionValuePathMappings (const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const;
233 OptionValueFileSpecList *
234 GetPropertyAtIndexAsOptionValueFileSpecList (const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const;
237 AppendProperty(const ConstString &name,
238 const ConstString &desc,
240 const lldb::OptionValueSP &value_sp);
242 lldb::OptionValuePropertiesSP
243 GetSubProperty (const ExecutionContext *exe_ctx,
244 const ConstString &name);
247 SetValueChangedCallback (uint32_t property_idx,
248 OptionValueChangedCallback callback,
253 ProtectedGetPropertyAtIndex (uint32_t idx)
255 if (idx < m_properties.size())
256 return &m_properties[idx];
261 ProtectedGetPropertyAtIndex (uint32_t idx) const
263 if (idx < m_properties.size())
264 return &m_properties[idx];
268 typedef UniqueCStringMap<size_t> NameToIndex;
271 std::vector<Property> m_properties;
272 NameToIndex m_name_to_index;
275 } // namespace lldb_private
277 #endif // liblldb_OptionValueProperties_h_