blob: 4fde3f6e3c8a28132283f123a77e00a973d631c0 [file] [log] [blame]
Andrew Walbran3d2c1972020-04-07 12:24:26 +01001//===-- 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
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02009#ifndef LLDB_INTERPRETER_OPTIONVALUEFILESPEC_H
10#define LLDB_INTERPRETER_OPTIONVALUEFILESPEC_H
Andrew Walbran3d2c1972020-04-07 12:24:26 +010011
12#include "lldb/Interpreter/OptionValue.h"
13
14#include "lldb/Utility/FileSpec.h"
15#include "llvm/Support/Chrono.h"
16
17namespace lldb_private {
18
19class OptionValueFileSpec : public OptionValue {
20public:
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
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020044 void Clear() override {
Andrew Walbran3d2c1972020-04-07 12:24:26 +010045 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<>();
Andrew Walbran3d2c1972020-04-07 12:24:26 +010049 }
50
51 lldb::OptionValueSP DeepCopy() const override;
52
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020053 void AutoComplete(CommandInterpreter &interpreter,
54 CompletionRequest &request) override;
Andrew Walbran3d2c1972020-04-07 12:24:26 +010055
56 // Subclass specific functions
57
58 FileSpec &GetCurrentValue() { return m_current_value; }
59
60 const FileSpec &GetCurrentValue() const { return m_current_value; }
61
62 const FileSpec &GetDefaultValue() const { return m_default_value; }
63
64 void SetCurrentValue(const FileSpec &value, bool set_value_was_set) {
65 m_current_value = value;
66 if (set_value_was_set)
67 m_value_was_set = true;
68 m_data_sp.reset();
69 }
70
71 void SetDefaultValue(const FileSpec &value) { m_default_value = value; }
72
73 const lldb::DataBufferSP &GetFileContents();
74
75 void SetCompletionMask(uint32_t mask) { m_completion_mask = mask; }
76
77protected:
78 FileSpec m_current_value;
79 FileSpec m_default_value;
80 lldb::DataBufferSP m_data_sp;
81 llvm::sys::TimePoint<> m_data_mod_time;
82 uint32_t m_completion_mask;
83 bool m_resolve;
84};
85
86} // namespace lldb_private
87
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020088#endif // LLDB_INTERPRETER_OPTIONVALUEFILESPEC_H