Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:42:50

0001 //===-- OptionValueArray.h --------------------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLDB_INTERPRETER_OPTIONVALUEARRAY_H
0010 #define LLDB_INTERPRETER_OPTIONVALUEARRAY_H
0011 
0012 #include <vector>
0013 
0014 #include "lldb/Interpreter/OptionValue.h"
0015 
0016 namespace lldb_private {
0017 
0018 class OptionValueArray : public Cloneable<OptionValueArray, OptionValue> {
0019 public:
0020   OptionValueArray(uint32_t type_mask = UINT32_MAX, bool raw_value_dump = false)
0021       : m_type_mask(type_mask), m_raw_value_dump(raw_value_dump) {}
0022 
0023   ~OptionValueArray() override = default;
0024 
0025   // Virtual subclass pure virtual overrides
0026 
0027   OptionValue::Type GetType() const override { return eTypeArray; }
0028 
0029   void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
0030                  uint32_t dump_mask) override;
0031 
0032   llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) override;
0033 
0034   Status
0035   SetValueFromString(llvm::StringRef value,
0036                      VarSetOperationType op = eVarSetOperationAssign) override;
0037 
0038   void Clear() override {
0039     m_values.clear();
0040     m_value_was_set = false;
0041   }
0042 
0043   lldb::OptionValueSP
0044   DeepCopy(const lldb::OptionValueSP &new_parent) const override;
0045 
0046   bool IsAggregateValue() const override { return true; }
0047 
0048   lldb::OptionValueSP GetSubValue(const ExecutionContext *exe_ctx,
0049                                   llvm::StringRef name,
0050                                   Status &error) const override;
0051 
0052   // Subclass specific functions
0053 
0054   size_t GetSize() const { return m_values.size(); }
0055 
0056   lldb::OptionValueSP operator[](size_t idx) const {
0057     lldb::OptionValueSP value_sp;
0058     if (idx < m_values.size())
0059       value_sp = m_values[idx];
0060     return value_sp;
0061   }
0062 
0063   lldb::OptionValueSP GetValueAtIndex(size_t idx) const {
0064     lldb::OptionValueSP value_sp;
0065     if (idx < m_values.size())
0066       value_sp = m_values[idx];
0067     return value_sp;
0068   }
0069 
0070   bool AppendValue(const lldb::OptionValueSP &value_sp) {
0071     // Make sure the value_sp object is allowed to contain values of the type
0072     // passed in...
0073     if (value_sp && (m_type_mask & value_sp->GetTypeAsMask())) {
0074       m_values.push_back(value_sp);
0075       return true;
0076     }
0077     return false;
0078   }
0079 
0080   bool InsertValue(size_t idx, const lldb::OptionValueSP &value_sp) {
0081     // Make sure the value_sp object is allowed to contain values of the type
0082     // passed in...
0083     if (value_sp && (m_type_mask & value_sp->GetTypeAsMask())) {
0084       if (idx < m_values.size())
0085         m_values.insert(m_values.begin() + idx, value_sp);
0086       else
0087         m_values.push_back(value_sp);
0088       return true;
0089     }
0090     return false;
0091   }
0092 
0093   bool ReplaceValue(size_t idx, const lldb::OptionValueSP &value_sp) {
0094     // Make sure the value_sp object is allowed to contain values of the type
0095     // passed in...
0096     if (value_sp && (m_type_mask & value_sp->GetTypeAsMask())) {
0097       if (idx < m_values.size()) {
0098         m_values[idx] = value_sp;
0099         return true;
0100       }
0101     }
0102     return false;
0103   }
0104 
0105   bool DeleteValue(size_t idx) {
0106     if (idx < m_values.size()) {
0107       m_values.erase(m_values.begin() + idx);
0108       return true;
0109     }
0110     return false;
0111   }
0112 
0113   size_t GetArgs(Args &args) const;
0114 
0115   Status SetArgs(const Args &args, VarSetOperationType op);
0116 
0117 protected:
0118   typedef std::vector<lldb::OptionValueSP> collection;
0119 
0120   uint32_t m_type_mask;
0121   collection m_values;
0122   bool m_raw_value_dump;
0123 };
0124 
0125 } // namespace lldb_private
0126 
0127 #endif // LLDB_INTERPRETER_OPTIONVALUEARRAY_H