Back to home page

EIC code displayed by LXR

 
 

    


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

0001 //===-- OptionValueRegex.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_OPTIONVALUEREGEX_H
0010 #define LLDB_INTERPRETER_OPTIONVALUEREGEX_H
0011 
0012 #include "lldb/Interpreter/OptionValue.h"
0013 #include "lldb/Utility/RegularExpression.h"
0014 
0015 namespace lldb_private {
0016 
0017 class OptionValueRegex : public Cloneable<OptionValueRegex, OptionValue> {
0018 public:
0019   OptionValueRegex(const char *value = nullptr)
0020       : m_regex(value), m_default_regex_str(value) {}
0021 
0022   ~OptionValueRegex() override = default;
0023 
0024   // Virtual subclass pure virtual overrides
0025 
0026   OptionValue::Type GetType() const override { return eTypeRegex; }
0027 
0028   void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
0029                  uint32_t dump_mask) override;
0030 
0031   llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) override {
0032     return m_regex.GetText();
0033   }
0034 
0035   Status
0036   SetValueFromString(llvm::StringRef value,
0037                      VarSetOperationType op = eVarSetOperationAssign) override;
0038 
0039   void Clear() override {
0040     m_regex = RegularExpression(m_default_regex_str);
0041     m_value_was_set = false;
0042   }
0043 
0044   // Subclass specific functions
0045   const RegularExpression *GetCurrentValue() const {
0046     return (m_regex.IsValid() ? &m_regex : nullptr);
0047   }
0048 
0049   void SetCurrentValue(const char *value) {
0050     if (value && value[0])
0051       m_regex = RegularExpression(llvm::StringRef(value));
0052     else
0053       m_regex = RegularExpression();
0054   }
0055 
0056   bool IsValid() const { return m_regex.IsValid(); }
0057 
0058 protected:
0059   RegularExpression m_regex;
0060   std::string m_default_regex_str;
0061 };
0062 
0063 } // namespace lldb_private
0064 
0065 #endif // LLDB_INTERPRETER_OPTIONVALUEREGEX_H