1 //===-- OptionValueRegex.h --------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_OptionValueRegex_h_
11 #define liblldb_OptionValueRegex_h_
13 #include "lldb/Interpreter/OptionValue.h"
14 #include "lldb/Utility/RegularExpression.h"
16 namespace lldb_private {
18 class OptionValueRegex : public OptionValue {
20 OptionValueRegex(const char *value = nullptr)
21 : OptionValue(), m_regex(llvm::StringRef::withNullAsEmpty(value)) {}
23 ~OptionValueRegex() override = default;
25 //---------------------------------------------------------------------
26 // Virtual subclass pure virtual overrides
27 //---------------------------------------------------------------------
29 OptionValue::Type GetType() const override { return eTypeRegex; }
31 void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
32 uint32_t dump_mask) override;
35 SetValueFromString(llvm::StringRef value,
36 VarSetOperationType op = eVarSetOperationAssign) override;
38 SetValueFromString(const char *,
39 VarSetOperationType = eVarSetOperationAssign) = delete;
41 bool Clear() override {
43 m_value_was_set = false;
47 lldb::OptionValueSP DeepCopy() const override;
49 //---------------------------------------------------------------------
50 // Subclass specific functions
51 //---------------------------------------------------------------------
52 const RegularExpression *GetCurrentValue() const {
53 return (m_regex.IsValid() ? &m_regex : nullptr);
56 void SetCurrentValue(const char *value) {
57 if (value && value[0])
58 m_regex.Compile(llvm::StringRef(value));
63 bool IsValid() const { return m_regex.IsValid(); }
66 RegularExpression m_regex;
69 } // namespace lldb_private
71 #endif // liblldb_OptionValueRegex_h_