• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/Core/FileSpecList.h"
15 #include "lldb/Interpreter/OptionValue.h"
16 
17 namespace lldb_private {
18 
19 class OptionValueFileSpecList : public OptionValue {
20 public:
OptionValueFileSpecList()21   OptionValueFileSpecList() : OptionValue(), m_current_value() {}
22 
OptionValueFileSpecList(const FileSpecList & current_value)23   OptionValueFileSpecList(const FileSpecList &current_value)
24       : OptionValue(), m_current_value(current_value) {}
25 
~OptionValueFileSpecList()26   ~OptionValueFileSpecList() override {}
27 
28   // Virtual subclass pure virtual overrides
29 
GetType()30   OptionValue::Type GetType() const override { return eTypeFileSpecList; }
31 
32   void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
33                  uint32_t dump_mask) override;
34 
35   Status
36   SetValueFromString(llvm::StringRef value,
37                      VarSetOperationType op = eVarSetOperationAssign) override;
38   Status
39   SetValueFromString(const char *,
40                      VarSetOperationType = eVarSetOperationAssign) = delete;
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 
48   lldb::OptionValueSP DeepCopy() const override;
49 
IsAggregateValue()50   bool IsAggregateValue() const override { return true; }
51 
52   // Subclass specific functions
53 
GetCurrentValue()54   FileSpecList GetCurrentValue() const {
55     std::lock_guard<std::recursive_mutex> lock(m_mutex);
56     return m_current_value;
57   }
58 
SetCurrentValue(const FileSpecList & value)59   void SetCurrentValue(const FileSpecList &value) {
60     std::lock_guard<std::recursive_mutex> lock(m_mutex);
61     m_current_value = value;
62   }
63 
AppendCurrentValue(const FileSpec & value)64   void AppendCurrentValue(const FileSpec &value) {
65     std::lock_guard<std::recursive_mutex> lock(m_mutex);
66     m_current_value.Append(value);
67   }
68 
69 protected:
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