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) const override;
33
34 Status
35 SetValueFromString(llvm::StringRef value,
37
39 DeepCopy(const lldb::OptionValueSP &new_parent) const override;
40
41 bool IsAggregateValue() const override { return true; }
42
44 llvm::StringRef name,
45 Status &error) const override;
46
47 // Subclass specific functions
48
49 size_t GetSize() const { return m_values.size(); }
50
51 lldb::OptionValueSP operator[](size_t idx) const {
52 lldb::OptionValueSP value_sp;
53 if (idx < m_values.size())
54 value_sp = m_values[idx];
55 return value_sp;
56 }
57
59 lldb::OptionValueSP value_sp;
60 if (idx < m_values.size())
61 value_sp = m_values[idx];
62 return value_sp;
63 }
64
65 bool AppendValue(const lldb::OptionValueSP &value_sp) {
66 // Make sure the value_sp object is allowed to contain values of the type
67 // passed in...
68 if (value_sp && (m_type_mask & value_sp->GetTypeAsMask())) {
69 m_values.push_back(value_sp);
70 return true;
71 }
72 return false;
73 }
74
75 bool InsertValue(size_t idx, const lldb::OptionValueSP &value_sp) {
76 // Make sure the value_sp object is allowed to contain values of the type
77 // passed in...
78 if (value_sp && (m_type_mask & value_sp->GetTypeAsMask())) {
79 if (idx < m_values.size())
80 m_values.insert(m_values.begin() + idx, value_sp);
81 else
82 m_values.push_back(value_sp);
83 return true;
84 }
85 return false;
86 }
87
88 bool ReplaceValue(size_t idx, const lldb::OptionValueSP &value_sp) {
89 // Make sure the value_sp object is allowed to contain values of the type
90 // passed in...
91 if (value_sp && (m_type_mask & value_sp->GetTypeAsMask())) {
92 if (idx < m_values.size()) {
93 m_values[idx] = value_sp;
94 return true;
95 }
96 }
97 return false;
98 }
99
100 bool DeleteValue(size_t idx) {
101 if (idx < m_values.size()) {
102 m_values.erase(m_values.begin() + idx);
103 return true;
104 }
105 return false;
106 }
107
108 size_t GetArgs(Args &args) const;
109
110 Status SetArgs(const Args &args, VarSetOperationType op);
111
112protected:
113 void ClearImpl() override {
114 m_values.clear();
115 m_value_was_set = false;
116 }
117
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) const override
~OptionValueArray() override=default
size_t GetArgs(Args &args) const
std::vector< lldb::OptionValueSP > collection
An error handling class.
Definition Status.h:118
A stream class that can stream formatted output to a file.
Definition Stream.h:28
#define UINT32_MAX
A class that represents a running process on the host machine.
VarSetOperationType
Settable state variable types.
std::shared_ptr< lldb_private::OptionValue > OptionValueSP