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_
15 // Other libraries and framework includes
17 #include "lldb/Interpreter/OptionValue.h"
18 #include "lldb/Utility/RegularExpression.h"
20 namespace lldb_private {
22 class OptionValueRegex : public OptionValue {
24 OptionValueRegex(const char *value = nullptr)
25 : OptionValue(), m_regex(llvm::StringRef::withNullAsEmpty(value)) {}
27 ~OptionValueRegex() override = default;
29 //---------------------------------------------------------------------
30 // Virtual subclass pure virtual overrides
31 //---------------------------------------------------------------------
33 OptionValue::Type GetType() const override { return eTypeRegex; }
35 void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
36 uint32_t dump_mask) override;
39 SetValueFromString(llvm::StringRef value,
40 VarSetOperationType op = eVarSetOperationAssign) override;
42 SetValueFromString(const char *,
43 VarSetOperationType = eVarSetOperationAssign) = delete;
45 bool Clear() override {
47 m_value_was_set = false;
51 lldb::OptionValueSP DeepCopy() const override;
53 //---------------------------------------------------------------------
54 // Subclass specific functions
55 //---------------------------------------------------------------------
56 const RegularExpression *GetCurrentValue() const {
57 return (m_regex.IsValid() ? &m_regex : nullptr);
60 void SetCurrentValue(const char *value) {
61 if (value && value[0])
62 m_regex.Compile(llvm::StringRef(value));
67 bool IsValid() const { return m_regex.IsValid(); }
70 RegularExpression m_regex;
73 } // namespace lldb_private
75 #endif // liblldb_OptionValueRegex_h_