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 
16 namespace lldb_private {
17 
18 class OptionValueArray : public Cloneable<OptionValueArray, 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 = 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  Status
33  SetValueFromString(llvm::StringRef value,
35 
36  void Clear() override {
37  m_values.clear();
38  m_value_was_set = false;
39  }
40 
41  lldb::OptionValueSP
42  DeepCopy(const lldb::OptionValueSP &new_parent) const override;
43 
44  bool IsAggregateValue() const override { return true; }
45 
46  lldb::OptionValueSP GetSubValue(const ExecutionContext *exe_ctx,
47  llvm::StringRef name, bool will_modify,
48  Status &error) const override;
49 
50  // Subclass specific functions
51 
52  size_t GetSize() const { return m_values.size(); }
53 
54  lldb::OptionValueSP operator[](size_t idx) const {
55  lldb::OptionValueSP value_sp;
56  if (idx < m_values.size())
57  value_sp = m_values[idx];
58  return value_sp;
59  }
60 
61  lldb::OptionValueSP GetValueAtIndex(size_t idx) const {
62  lldb::OptionValueSP value_sp;
63  if (idx < m_values.size())
64  value_sp = m_values[idx];
65  return value_sp;
66  }
67 
68  bool AppendValue(const lldb::OptionValueSP &value_sp) {
69  // Make sure the value_sp object is allowed to contain values of the type
70  // passed in...
71  if (value_sp && (m_type_mask & value_sp->GetTypeAsMask())) {
72  m_values.push_back(value_sp);
73  return true;
74  }
75  return false;
76  }
77 
78  bool InsertValue(size_t idx, const lldb::OptionValueSP &value_sp) {
79  // Make sure the value_sp object is allowed to contain values of the type
80  // passed in...
81  if (value_sp && (m_type_mask & value_sp->GetTypeAsMask())) {
82  if (idx < m_values.size())
83  m_values.insert(m_values.begin() + idx, value_sp);
84  else
85  m_values.push_back(value_sp);
86  return true;
87  }
88  return false;
89  }
90 
91  bool ReplaceValue(size_t idx, const lldb::OptionValueSP &value_sp) {
92  // Make sure the value_sp object is allowed to contain values of the type
93  // passed in...
94  if (value_sp && (m_type_mask & value_sp->GetTypeAsMask())) {
95  if (idx < m_values.size()) {
96  m_values[idx] = value_sp;
97  return true;
98  }
99  }
100  return false;
101  }
102 
103  bool DeleteValue(size_t idx) {
104  if (idx < m_values.size()) {
105  m_values.erase(m_values.begin() + idx);
106  return true;
107  }
108  return false;
109  }
110 
111  size_t GetArgs(Args &args) const;
112 
113  Status SetArgs(const Args &args, VarSetOperationType op);
114 
115 protected:
116  typedef std::vector<lldb::OptionValueSP> collection;
117 
121 };
122 
123 } // namespace lldb_private
124 
125 #endif // LLDB_INTERPRETER_OPTIONVALUEARRAY_H
lldb_private::OptionValueArray::ReplaceValue
bool ReplaceValue(size_t idx, const lldb::OptionValueSP &value_sp)
Definition: OptionValueArray.h:91
lldb_private::ExecutionContext
Definition: ExecutionContext.h:292
lldb_private::OptionValueArray::m_values
collection m_values
Definition: OptionValueArray.h:119
lldb_private::OptionValueArray::GetArgs
size_t GetArgs(Args &args) const
Definition: OptionValueArray.cpp:147
lldb_private::OptionValueArray::SetValueFromString
Status SetValueFromString(llvm::StringRef value, VarSetOperationType op=eVarSetOperationAssign) override
Definition: OptionValueArray.cpp:79
lldb_private::OptionValueArray::GetValueAtIndex
lldb::OptionValueSP GetValueAtIndex(size_t idx) const
Definition: OptionValueArray.h:61
lldb_private::OptionValueArray::GetType
OptionValue::Type GetType() const override
Definition: OptionValueArray.h:27
lldb_private::OptionValueArray::Clear
void Clear() override
Definition: OptionValueArray.h:36
lldb_private::Stream
Definition: Stream.h:28
lldb_private::Args
Definition: Args.h:33
lldb_private::Cloneable
Definition: Cloneable.h:40
OptionValue.h
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
lldb_private::VarSetOperationType
VarSetOperationType
Settable state variable types.
Definition: lldb-private-enumerations.h:83
lldb_private::OptionValueArray::GetSize
size_t GetSize() const
Definition: OptionValueArray.h:52
lldb_private::OptionValueArray::OptionValueArray
OptionValueArray(uint32_t type_mask=UINT32_MAX, bool raw_value_dump=false)
Definition: OptionValueArray.h:20
lldb_private::OptionValueArray::m_raw_value_dump
bool m_raw_value_dump
Definition: OptionValueArray.h:120
lldb_private::OptionValueArray::GetSubValue
lldb::OptionValueSP GetSubValue(const ExecutionContext *exe_ctx, llvm::StringRef name, bool will_modify, Status &error) const override
Definition: OptionValueArray.cpp:89
lldb_private::OptionValueArray::DumpValue
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override
Definition: OptionValueArray.cpp:18
lldb_private::OptionValueArray::collection
std::vector< lldb::OptionValueSP > collection
Definition: OptionValueArray.h:116
lldb_private::OptionValueArray::DeleteValue
bool DeleteValue(size_t idx)
Definition: OptionValueArray.h:103
lldb_private::OptionValueArray::DeepCopy
lldb::OptionValueSP DeepCopy(const lldb::OptionValueSP &new_parent) const override
Definition: OptionValueArray.cpp:307
lldb_private::OptionValueArray::operator[]
lldb::OptionValueSP operator[](size_t idx) const
Definition: OptionValueArray.h:54
lldb_private::OptionValue::eTypeArray
@ eTypeArray
Definition: OptionValue.h:30
lldb_private::OptionValueArray::AppendValue
bool AppendValue(const lldb::OptionValueSP &value_sp)
Definition: OptionValueArray.h:68
lldb_private::OptionValueArray::m_type_mask
uint32_t m_type_mask
Definition: OptionValueArray.h:118
lldb_private::Status
Definition: Status.h:44
lldb_private::OptionValue::Type
Type
Definition: OptionValue.h:26
uint32_t
lldb_private::OptionValue::m_value_was_set
bool m_value_was_set
Definition: OptionValue.h:332
UINT32_MAX
#define UINT32_MAX
Definition: lldb-defines.h:31
lldb_private::OptionValueArray::IsAggregateValue
bool IsAggregateValue() const override
Definition: OptionValueArray.h:44
lldb_private::OptionValueArray::~OptionValueArray
~OptionValueArray() override=default
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::OptionValueArray::InsertValue
bool InsertValue(size_t idx, const lldb::OptionValueSP &value_sp)
Definition: OptionValueArray.h:78
lldb_private::OptionValueArray::SetArgs
Status SetArgs(const Args &args, VarSetOperationType op)
Definition: OptionValueArray.cpp:159
lldb_private::eVarSetOperationAssign
@ eVarSetOperationAssign
Definition: lldb-private-enumerations.h:90
lldb_private::OptionValueArray
Definition: OptionValueArray.h:18