1 //===-- OptionValueFileSpec.h -----------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef liblldb_OptionValueFileSpec_h_
10 #define liblldb_OptionValueFileSpec_h_
12 #include "lldb/Interpreter/OptionValue.h"
14 #include "lldb/Utility/FileSpec.h"
15 #include "llvm/Support/Chrono.h"
17 namespace lldb_private {
19 class OptionValueFileSpec : public OptionValue {
21 OptionValueFileSpec(bool resolve = true);
23 OptionValueFileSpec(const FileSpec &value, bool resolve = true);
25 OptionValueFileSpec(const FileSpec ¤t_value,
26 const FileSpec &default_value, bool resolve = true);
28 ~OptionValueFileSpec() override {}
30 // Virtual subclass pure virtual overrides
32 OptionValue::Type GetType() const override { return eTypeFileSpec; }
34 void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
35 uint32_t dump_mask) override;
38 SetValueFromString(llvm::StringRef value,
39 VarSetOperationType op = eVarSetOperationAssign) override;
41 SetValueFromString(const char *,
42 VarSetOperationType = eVarSetOperationAssign) = delete;
44 bool Clear() override {
45 m_current_value = m_default_value;
46 m_value_was_set = false;
48 m_data_mod_time = llvm::sys::TimePoint<>();
52 lldb::OptionValueSP DeepCopy() const override;
54 size_t AutoComplete(CommandInterpreter &interpreter,
55 CompletionRequest &request) override;
57 // Subclass specific functions
59 FileSpec &GetCurrentValue() { return m_current_value; }
61 const FileSpec &GetCurrentValue() const { return m_current_value; }
63 const FileSpec &GetDefaultValue() const { return m_default_value; }
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;
72 void SetDefaultValue(const FileSpec &value) { m_default_value = value; }
74 const lldb::DataBufferSP &GetFileContents();
76 void SetCompletionMask(uint32_t mask) { m_completion_mask = mask; }
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;
87 } // namespace lldb_private
89 #endif // liblldb_OptionValueFileSpec_h_