]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm-project/lldb/include/lldb/Interpreter/OptionValueFileSpec.h
Move all sources from the llvm project into contrib/llvm-project.
[FreeBSD/FreeBSD.git] / contrib / llvm-project / lldb / include / lldb / Interpreter / OptionValueFileSpec.h
1 //===-- OptionValueFileSpec.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_OptionValueFileSpec_h_
10 #define liblldb_OptionValueFileSpec_h_
11
12 #include "lldb/Interpreter/OptionValue.h"
13
14 #include "lldb/Utility/FileSpec.h"
15 #include "llvm/Support/Chrono.h"
16
17 namespace lldb_private {
18
19 class OptionValueFileSpec : public OptionValue {
20 public:
21   OptionValueFileSpec(bool resolve = true);
22
23   OptionValueFileSpec(const FileSpec &value, bool resolve = true);
24
25   OptionValueFileSpec(const FileSpec &current_value,
26                       const FileSpec &default_value, bool resolve = true);
27
28   ~OptionValueFileSpec() override {}
29
30   // Virtual subclass pure virtual overrides
31
32   OptionValue::Type GetType() const override { return eTypeFileSpec; }
33
34   void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
35                  uint32_t dump_mask) override;
36
37   Status
38   SetValueFromString(llvm::StringRef value,
39                      VarSetOperationType op = eVarSetOperationAssign) override;
40   Status
41   SetValueFromString(const char *,
42                      VarSetOperationType = eVarSetOperationAssign) = delete;
43
44   bool Clear() override {
45     m_current_value = m_default_value;
46     m_value_was_set = false;
47     m_data_sp.reset();
48     m_data_mod_time = llvm::sys::TimePoint<>();
49     return true;
50   }
51
52   lldb::OptionValueSP DeepCopy() const override;
53
54   size_t AutoComplete(CommandInterpreter &interpreter,
55                       CompletionRequest &request) override;
56
57   // Subclass specific functions
58
59   FileSpec &GetCurrentValue() { return m_current_value; }
60
61   const FileSpec &GetCurrentValue() const { return m_current_value; }
62
63   const FileSpec &GetDefaultValue() const { return m_default_value; }
64
65   void SetCurrentValue(const FileSpec &value, bool set_value_was_set) {
66     m_current_value = value;
67     if (set_value_was_set)
68       m_value_was_set = true;
69     m_data_sp.reset();
70   }
71
72   void SetDefaultValue(const FileSpec &value) { m_default_value = value; }
73
74   const lldb::DataBufferSP &GetFileContents();
75
76   void SetCompletionMask(uint32_t mask) { m_completion_mask = mask; }
77
78 protected:
79   FileSpec m_current_value;
80   FileSpec m_default_value;
81   lldb::DataBufferSP m_data_sp;
82   llvm::sys::TimePoint<> m_data_mod_time;
83   uint32_t m_completion_mask;
84   bool m_resolve;
85 };
86
87 } // namespace lldb_private
88
89 #endif // liblldb_OptionValueFileSpec_h_