1 //===-- OptionValueFileSpecList.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_OPTIONVALUEFILESPECLIST_H 10 #define LLDB_INTERPRETER_OPTIONVALUEFILESPECLIST_H 11 12 #include <mutex> 13 14 #include "lldb/Interpreter/OptionValue.h" 15 #include "lldb/Utility/FileSpecList.h" 16 17 namespace lldb_private { 18 19 class OptionValueFileSpecList 20 : public Cloneable<OptionValueFileSpecList, OptionValue> { 21 public: 22 OptionValueFileSpecList() = default; 23 OptionValueFileSpecList(const OptionValueFileSpecList & other)24 OptionValueFileSpecList(const OptionValueFileSpecList &other) 25 : Cloneable(other), m_current_value(other.GetCurrentValue()) {} 26 27 ~OptionValueFileSpecList() override = default; 28 29 // Virtual subclass pure virtual overrides 30 GetType()31 OptionValue::Type GetType() const override { return eTypeFileSpecList; } 32 33 void DumpValue(const ExecutionContext *exe_ctx, Stream &strm, 34 uint32_t dump_mask) override; 35 36 llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) const override; 37 38 Status 39 SetValueFromString(llvm::StringRef value, 40 VarSetOperationType op = eVarSetOperationAssign) override; 41 Clear()42 void Clear() override { 43 std::lock_guard<std::recursive_mutex> lock(m_mutex); 44 m_current_value.Clear(); 45 m_value_was_set = false; 46 } 47 IsAggregateValue()48 bool IsAggregateValue() const override { return true; } 49 50 // Subclass specific functions 51 GetCurrentValue()52 FileSpecList GetCurrentValue() const { 53 std::lock_guard<std::recursive_mutex> lock(m_mutex); 54 return m_current_value; 55 } 56 SetCurrentValue(const FileSpecList & value)57 void SetCurrentValue(const FileSpecList &value) { 58 std::lock_guard<std::recursive_mutex> lock(m_mutex); 59 m_current_value = value; 60 } 61 AppendCurrentValue(const FileSpec & value)62 void AppendCurrentValue(const FileSpec &value) { 63 std::lock_guard<std::recursive_mutex> lock(m_mutex); 64 m_current_value.Append(value); 65 } 66 67 protected: 68 lldb::OptionValueSP Clone() const override; 69 70 mutable std::recursive_mutex m_mutex; 71 FileSpecList m_current_value; 72 }; 73 74 } // namespace lldb_private 75 76 #endif // LLDB_INTERPRETER_OPTIONVALUEFILESPECLIST_H 77