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