Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:42:50

0001 //===-- OptionValueFileSpec.h -----------------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLDB_INTERPRETER_OPTIONVALUEFILESPEC_H
0010 #define LLDB_INTERPRETER_OPTIONVALUEFILESPEC_H
0011 
0012 #include "lldb/Interpreter/CommandCompletions.h"
0013 #include "lldb/Interpreter/OptionValue.h"
0014 
0015 #include "lldb/Utility/FileSpec.h"
0016 #include "llvm/Support/Chrono.h"
0017 
0018 namespace lldb_private {
0019 
0020 class OptionValueFileSpec : public Cloneable<OptionValueFileSpec, OptionValue> {
0021 public:
0022   OptionValueFileSpec(bool resolve = true);
0023 
0024   OptionValueFileSpec(const FileSpec &value, bool resolve = true);
0025 
0026   OptionValueFileSpec(const FileSpec &current_value,
0027                       const FileSpec &default_value, bool resolve = true);
0028 
0029   ~OptionValueFileSpec() override = default;
0030 
0031   // Virtual subclass pure virtual overrides
0032 
0033   OptionValue::Type GetType() const override { return eTypeFileSpec; }
0034 
0035   void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
0036                  uint32_t dump_mask) override;
0037 
0038   llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) override {
0039     return m_current_value.GetPath();
0040   }
0041 
0042   Status
0043   SetValueFromString(llvm::StringRef value,
0044                      VarSetOperationType op = eVarSetOperationAssign) override;
0045 
0046   void Clear() override {
0047     m_current_value = m_default_value;
0048     m_value_was_set = false;
0049     m_data_sp.reset();
0050     m_data_mod_time = llvm::sys::TimePoint<>();
0051   }
0052 
0053   void AutoComplete(CommandInterpreter &interpreter,
0054                     CompletionRequest &request) override;
0055 
0056   // Subclass specific functions
0057 
0058   FileSpec &GetCurrentValue() { return m_current_value; }
0059 
0060   const FileSpec &GetCurrentValue() const { return m_current_value; }
0061 
0062   const FileSpec &GetDefaultValue() const { return m_default_value; }
0063 
0064   void SetCurrentValue(const FileSpec &value, bool set_value_was_set) {
0065     m_current_value = value;
0066     if (set_value_was_set)
0067       m_value_was_set = true;
0068     m_data_sp.reset();
0069   }
0070 
0071   void SetDefaultValue(const FileSpec &value) { m_default_value = value; }
0072 
0073   const lldb::DataBufferSP &GetFileContents();
0074 
0075   void SetCompletionMask(uint32_t mask) { m_completion_mask = mask; }
0076 
0077 protected:
0078   FileSpec m_current_value;
0079   FileSpec m_default_value;
0080   lldb::DataBufferSP m_data_sp;
0081   llvm::sys::TimePoint<> m_data_mod_time;
0082   uint32_t m_completion_mask = lldb::eDiskFileCompletion;
0083   bool m_resolve;
0084 };
0085 
0086 } // namespace lldb_private
0087 
0088 #endif // LLDB_INTERPRETER_OPTIONVALUEFILESPEC_H