1 //===-- OptionValueRegex.h --------------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef liblldb_OptionValueRegex_h_
10 #define liblldb_OptionValueRegex_h_
12 #include "lldb/Interpreter/OptionValue.h"
13 #include "lldb/Utility/RegularExpression.h"
15 namespace lldb_private {
17 class OptionValueRegex : public OptionValue {
19 OptionValueRegex(const char *value = nullptr)
20 : OptionValue(), m_regex(llvm::StringRef::withNullAsEmpty(value)) {}
22 ~OptionValueRegex() override = default;
24 // Virtual subclass pure virtual overrides
26 OptionValue::Type GetType() const override { return eTypeRegex; }
28 void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
29 uint32_t dump_mask) override;
32 SetValueFromString(llvm::StringRef value,
33 VarSetOperationType op = eVarSetOperationAssign) override;
35 SetValueFromString(const char *,
36 VarSetOperationType = eVarSetOperationAssign) = delete;
38 bool Clear() override {
40 m_value_was_set = false;
44 lldb::OptionValueSP DeepCopy() const override;
46 // Subclass specific functions
47 const RegularExpression *GetCurrentValue() const {
48 return (m_regex.IsValid() ? &m_regex : nullptr);
51 void SetCurrentValue(const char *value) {
52 if (value && value[0])
53 m_regex.Compile(llvm::StringRef(value));
58 bool IsValid() const { return m_regex.IsValid(); }
61 RegularExpression m_regex;
64 } // namespace lldb_private
66 #endif // liblldb_OptionValueRegex_h_