LLDB mainline
OptionValueArray.h
Go to the documentation of this file.
1//===-- OptionValueArray.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 LLDB_INTERPRETER_OPTIONVALUEARRAY_H
10#define LLDB_INTERPRETER_OPTIONVALUEARRAY_H
11
12#include <vector>
13
15
16namespace lldb_private {
17
18class OptionValueArray : public Cloneable<OptionValueArray, OptionValue> {
19public:
20 OptionValueArray(uint32_t type_mask = UINT32_MAX, bool raw_value_dump = false)
21 : m_type_mask(type_mask), m_raw_value_dump(raw_value_dump) {}
22
23 ~OptionValueArray() override = default;
24
25 // Virtual subclass pure virtual overrides
26
27 OptionValue::Type GetType() const override { return eTypeArray; }
28
29 void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
30 uint32_t dump_mask) override;
31
32 llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) override;
33
34 Status
35 SetValueFromString(llvm::StringRef value,
37
38 void Clear() override {
39 m_values.clear();
40 m_value_was_set = false;
41 }
42
44 DeepCopy(const lldb::OptionValueSP &new_parent) const override;
45
46 bool IsAggregateValue() const override { return true; }
47
49 llvm::StringRef name,
50 Status &error) const override;
51
52 // Subclass specific functions
53
54 size_t GetSize() const { return m_values.size(); }
55
56 lldb::OptionValueSP operator[](size_t idx) const {
57 lldb::OptionValueSP value_sp;
58 if (idx < m_values.size())
59 value_sp = m_values[idx];
60 return value_sp;
61 }
62
64 lldb::OptionValueSP value_sp;
65 if (idx < m_values.size())
66 value_sp = m_values[idx];
67 return value_sp;
68 }
69
70 bool AppendValue(const lldb::OptionValueSP &value_sp) {
71 // Make sure the value_sp object is allowed to contain values of the type
72 // passed in...
73 if (value_sp && (m_type_mask & value_sp->GetTypeAsMask())) {
74 m_values.push_back(value_sp);
75 return true;
76 }
77 return false;
78 }
79
80 bool InsertValue(size_t idx, const lldb::OptionValueSP &value_sp) {
81 // Make sure the value_sp object is allowed to contain values of the type
82 // passed in...
83 if (value_sp && (m_type_mask & value_sp->GetTypeAsMask())) {
84 if (idx < m_values.size())
85 m_values.insert(m_values.begin() + idx, value_sp);
86 else
87 m_values.push_back(value_sp);
88 return true;
89 }
90 return false;
91 }
92
93 bool ReplaceValue(size_t idx, const lldb::OptionValueSP &value_sp) {
94 // Make sure the value_sp object is allowed to contain values of the type
95 // passed in...
96 if (value_sp && (m_type_mask & value_sp->GetTypeAsMask())) {
97 if (idx < m_values.size()) {
98 m_values[idx] = value_sp;
99 return true;
100 }
101 }
102 return false;
103 }
104
105 bool DeleteValue(size_t idx) {
106 if (idx < m_values.size()) {
107 m_values.erase(m_values.begin() + idx);
108 return true;
109 }
110 return false;
111 }
112
113 size_t GetArgs(Args &args) const;
114
115 Status SetArgs(const Args &args, VarSetOperationType op);
116
117protected:
118 typedef std::vector<lldb::OptionValueSP> collection;
119
120 uint32_t m_type_mask;
123};
124
125} // namespace lldb_private
126
127#endif // LLDB_INTERPRETER_OPTIONVALUEARRAY_H
static llvm::raw_ostream & error(Stream &strm)
A command line argument class.
Definition: Args.h:33
A class that implements CRTP-based "virtual constructor" idiom.
Definition: Cloneable.h:40
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
lldb::OptionValueSP operator[](size_t idx) const
bool InsertValue(size_t idx, const lldb::OptionValueSP &value_sp)
bool AppendValue(const lldb::OptionValueSP &value_sp)
Status SetArgs(const Args &args, VarSetOperationType op)
bool ReplaceValue(size_t idx, const lldb::OptionValueSP &value_sp)
bool IsAggregateValue() const override
lldb::OptionValueSP GetValueAtIndex(size_t idx) const
OptionValue::Type GetType() const override
lldb::OptionValueSP GetSubValue(const ExecutionContext *exe_ctx, llvm::StringRef name, Status &error) const override
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override
lldb::OptionValueSP DeepCopy(const lldb::OptionValueSP &new_parent) const override
OptionValueArray(uint32_t type_mask=UINT32_MAX, bool raw_value_dump=false)
Status SetValueFromString(llvm::StringRef value, VarSetOperationType op=eVarSetOperationAssign) override
llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) override
~OptionValueArray() override=default
size_t GetArgs(Args &args) const
std::vector< lldb::OptionValueSP > collection
An error handling class.
Definition: Status.h:44
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
#define UINT32_MAX
Definition: lldb-defines.h:19
A class that represents a running process on the host machine.
VarSetOperationType
Settable state variable types.
std::shared_ptr< lldb_private::OptionValue > OptionValueSP
Definition: lldb-forward.h:382