aboutsummaryrefslogtreecommitdiff
path: root/include/lldb/Interpreter/OptionValueProperties.h
blob: a67ea5d66e54edd9cee1e7096f44421bebf94fd3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
//===-- OptionValueProperties.h --------------------------------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#ifndef liblldb_OptionValueProperties_h_
#define liblldb_OptionValueProperties_h_

// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/Core/ConstString.h"
#include "lldb/Core/UniqueCStringMap.h"
#include "lldb/Interpreter/OptionValue.h"
#include "lldb/Interpreter/Property.h"

namespace lldb_private {

class OptionValueProperties :
    public OptionValue,
    public std::enable_shared_from_this<OptionValueProperties>
{
public:

    //---------------------------------------------------------------------
    // OptionValueProperties
    //---------------------------------------------------------------------
    OptionValueProperties () :
        OptionValue(),
        m_name (),
        m_properties (),
        m_name_to_index ()
    {
    }

    OptionValueProperties (const ConstString &name);

    OptionValueProperties (const OptionValueProperties &global_properties);
    
    virtual
    ~OptionValueProperties()
    {
    }
    
    virtual Type
    GetType () const
    {
        return eTypeProperties;
    }
    
    virtual bool
    Clear ();

    virtual lldb::OptionValueSP
    DeepCopy () const;
    
    virtual Error
    SetValueFromCString (const char *value, VarSetOperationType op = eVarSetOperationAssign);

    virtual void
    DumpValue (const ExecutionContext *exe_ctx,
               Stream &strm,
               uint32_t dump_mask);

    virtual ConstString
    GetName () const
    {
        return m_name;
    }
    
    virtual Error
    DumpPropertyValue (const ExecutionContext *exe_ctx,
                       Stream &strm,
                       const char *property_path,
                       uint32_t dump_mask);

    virtual void
    DumpAllDescriptions (CommandInterpreter &interpreter,
                         Stream &strm) const;

    void
    Apropos (const char *keyword,
             std::vector<const Property *> &matching_properties) const;
    
    void
    Initialize (const PropertyDefinition *setting_definitions);

//    bool
//    GetQualifiedName (Stream &strm);

    //---------------------------------------------------------------------
    // Subclass specific functions
    //---------------------------------------------------------------------
    
    virtual size_t
    GetNumProperties() const;
    
    virtual ConstString
    GetPropertyNameAtIndex (uint32_t idx) const;

    virtual const char *
    GetPropertyDescriptionAtIndex (uint32_t idx) const;
    
    //---------------------------------------------------------------------
    // Get the index of a property given its exact name in this property
    // collection, "name" can't be a path to a property path that refers
    // to a property within a property
    //---------------------------------------------------------------------
    virtual uint32_t
    GetPropertyIndex (const ConstString &name) const;

    //---------------------------------------------------------------------
    // Get a property by exact name exists in this property collection, name
    // can not be a path to a property path that refers to a property within
    // a property
    //---------------------------------------------------------------------
    virtual const Property *
    GetProperty (const ExecutionContext *exe_ctx,
                 bool will_modify,
                 const ConstString &name) const;
    
    virtual const Property *
    GetPropertyAtIndex (const ExecutionContext *exe_ctx,
                        bool will_modify,
                        uint32_t idx) const;

    //---------------------------------------------------------------------
    // Property can be be a property path like "target.process.extra-startup-command"
    //---------------------------------------------------------------------
    virtual const Property *
    GetPropertyAtPath (const ExecutionContext *exe_ctx,
                       bool will_modify,
                       const char *property_path) const;

    virtual lldb::OptionValueSP
    GetPropertyValueAtIndex (const ExecutionContext *exe_ctx,
                             bool will_modify,
                             uint32_t idx) const;
    
    virtual lldb::OptionValueSP
    GetValueForKey  (const ExecutionContext *exe_ctx,
                     const ConstString &key,
                     bool value_will_be_modified) const;

    lldb::OptionValueSP
    GetSubValue (const ExecutionContext *exe_ctx,
                 const char *name,
                 bool value_will_be_modified,
                 Error &error) const;

    virtual Error
    SetSubValue (const ExecutionContext *exe_ctx,
                 VarSetOperationType op,
                 const char *path,
                 const char *value);

    virtual bool
    PredicateMatches (const ExecutionContext *exe_ctx,
                      const char *predicate) const
    {
        return false;
    }


    OptionValueArch *
    GetPropertyAtIndexAsOptionValueArch (const ExecutionContext *exe_ctx, uint32_t idx) const;

    bool
    GetPropertyAtIndexAsArgs (const ExecutionContext *exe_ctx, uint32_t idx, Args &args) const;

    bool
    SetPropertyAtIndexFromArgs (const ExecutionContext *exe_ctx, uint32_t idx, const Args &args);
    
    bool
    GetPropertyAtIndexAsBoolean (const ExecutionContext *exe_ctx, uint32_t idx, bool fail_value) const;
    
    bool
    SetPropertyAtIndexAsBoolean (const ExecutionContext *exe_ctx, uint32_t idx, bool new_value);
    
    OptionValueDictionary *
    GetPropertyAtIndexAsOptionValueDictionary (const ExecutionContext *exe_ctx, uint32_t idx) const;

    int64_t
    GetPropertyAtIndexAsEnumeration (const ExecutionContext *exe_ctx, uint32_t idx, int64_t fail_value) const;
    
    bool
    SetPropertyAtIndexAsEnumeration (const ExecutionContext *exe_ctx, uint32_t idx, int64_t new_value);
    
    const RegularExpression *
    GetPropertyAtIndexAsOptionValueRegex (const ExecutionContext *exe_ctx, uint32_t idx) const;

    OptionValueSInt64 *
    GetPropertyAtIndexAsOptionValueSInt64 (const ExecutionContext *exe_ctx, uint32_t idx) const;

    int64_t
    GetPropertyAtIndexAsSInt64 (const ExecutionContext *exe_ctx, uint32_t idx, int64_t fail_value) const;

    bool
    SetPropertyAtIndexAsSInt64 (const ExecutionContext *exe_ctx, uint32_t idx, int64_t new_value);

    uint64_t
    GetPropertyAtIndexAsUInt64 (const ExecutionContext *exe_ctx, uint32_t idx, uint64_t fail_value) const;
    
    bool
    SetPropertyAtIndexAsUInt64 (const ExecutionContext *exe_ctx, uint32_t idx, uint64_t new_value);
    
    const char *
    GetPropertyAtIndexAsString (const ExecutionContext *exe_ctx, uint32_t idx, const char *fail_value) const;

    bool
    SetPropertyAtIndexAsString (const ExecutionContext *exe_ctx, uint32_t idx, const char *new_value);

    OptionValueString *
    GetPropertyAtIndexAsOptionValueString (const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const;

    OptionValueFileSpec *
    GetPropertyAtIndexAsOptionValueFileSpec (const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const;

    FileSpec
    GetPropertyAtIndexAsFileSpec (const ExecutionContext *exe_ctx, uint32_t idx) const;
    
    bool
    SetPropertyAtIndexAsFileSpec (const ExecutionContext *exe_ctx, uint32_t idx, const FileSpec &file_spec);

    OptionValuePathMappings *
    GetPropertyAtIndexAsOptionValuePathMappings (const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const;

    OptionValueFileSpecList *
    GetPropertyAtIndexAsOptionValueFileSpecList (const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const;

    void
    AppendProperty(const ConstString &name,
                   const ConstString &desc,
                   bool is_global,
                   const lldb::OptionValueSP &value_sp);

    lldb::OptionValuePropertiesSP
    GetSubProperty (const ExecutionContext *exe_ctx,
                    const ConstString &name);

    void
    SetValueChangedCallback (uint32_t property_idx,
                             OptionValueChangedCallback callback,
                             void *baton);
protected:

    Property *
    ProtectedGetPropertyAtIndex (uint32_t idx)
    {
        if (idx < m_properties.size())
            return &m_properties[idx];
        return NULL;
    }

    const Property *
    ProtectedGetPropertyAtIndex (uint32_t idx) const
    {
        if (idx < m_properties.size())
            return &m_properties[idx];
        return NULL;
    }

    typedef UniqueCStringMap<size_t> NameToIndex;

    ConstString m_name;
    std::vector<Property> m_properties;
    NameToIndex m_name_to_index;
};

} // namespace lldb_private

#endif  // liblldb_OptionValueProperties_h_