LLDB mainline
OptionValueFileSpec.h
Go to the documentation of this file.
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 LLDB_INTERPRETER_OPTIONVALUEFILESPEC_H
10#define LLDB_INTERPRETER_OPTIONVALUEFILESPEC_H
11
14
16#include "llvm/Support/Chrono.h"
17
18namespace lldb_private {
19
20class OptionValueFileSpec : public Cloneable<OptionValueFileSpec, OptionValue> {
21public:
22 OptionValueFileSpec(bool resolve = true);
23
24 OptionValueFileSpec(const FileSpec &value, bool resolve = true);
25
26 OptionValueFileSpec(const FileSpec &current_value,
27 const FileSpec &default_value, bool resolve = true);
28
29 ~OptionValueFileSpec() override = default;
30
31 // Virtual subclass pure virtual overrides
32
33 OptionValue::Type GetType() const override { return eTypeFileSpec; }
34
35 void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
36 uint32_t dump_mask) override;
37
38 llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) const override {
39 return m_current_value.GetPath();
40 }
41
42 Status
43 SetValueFromString(llvm::StringRef value,
45
46 void AutoComplete(CommandInterpreter &interpreter,
47 CompletionRequest &request) override;
48
49 bool IsDefault() const override { return m_current_value == m_default_value; }
50
51 // Subclass specific functions
52
54
55 const FileSpec &GetCurrentValue() const { return m_current_value; }
56
57 const FileSpec &GetDefaultValue() const { return m_default_value; }
58
59 void SetCurrentValue(const FileSpec &value, bool set_value_was_set) {
60 m_current_value = value;
61 if (set_value_was_set)
62 m_value_was_set = true;
63 m_data_sp.reset();
64 }
65
66 void SetDefaultValue(const FileSpec &value) { m_default_value = value; }
67
69
70 void SetCompletionMask(uint32_t mask) { m_completion_mask = mask; }
71
72protected:
73 void ClearImpl() override {
75 m_value_was_set = false;
76 m_data_sp.reset();
77 m_data_mod_time = llvm::sys::TimePoint<>();
78 }
79
83 llvm::sys::TimePoint<> m_data_mod_time;
86};
87
88} // namespace lldb_private
89
90#endif // LLDB_INTERPRETER_OPTIONVALUEFILESPEC_H
A class that implements CRTP-based "virtual constructor" idiom.
Definition Cloneable.h:40
"lldb/Utility/ArgCompletionRequest.h"
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
A file utility class.
Definition FileSpec.h:57
const FileSpec & GetCurrentValue() const
bool IsDefault() const override
Return true if the current value equals the default value.
llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) const override
OptionValue::Type GetType() const override
~OptionValueFileSpec() override=default
void AutoComplete(CommandInterpreter &interpreter, CompletionRequest &request) override
Status SetValueFromString(llvm::StringRef value, VarSetOperationType op=eVarSetOperationAssign) override
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override
const FileSpec & GetDefaultValue() const
void SetDefaultValue(const FileSpec &value)
const lldb::DataBufferSP & GetFileContents()
void SetCurrentValue(const FileSpec &value, bool set_value_was_set)
An error handling class.
Definition Status.h:118
A stream class that can stream formatted output to a file.
Definition Stream.h:28
A class that represents a running process on the host machine.
VarSetOperationType
Settable state variable types.
std::shared_ptr< lldb_private::DataBuffer > DataBufferSP