LLDB mainline
OptionValueRegex.h
Go to the documentation of this file.
1//===-- OptionValueRegex.h --------------------------------------*- C++ -*-===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLDB_INTERPRETER_OPTIONVALUEREGEX_H
10#define LLDB_INTERPRETER_OPTIONVALUEREGEX_H
11
14
15namespace lldb_private {
16
17class OptionValueRegex : public Cloneable<OptionValueRegex, OptionValue> {
18public:
19 OptionValueRegex(const char *value = nullptr)
20 : m_regex(value), m_default_regex_str(value) {}
21
22 ~OptionValueRegex() override = default;
23
24 // Virtual subclass pure virtual overrides
25
26 OptionValue::Type GetType() const override { return eTypeRegex; }
27
28 void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
29 uint32_t dump_mask) override;
30
31 llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) const override {
32 return m_regex.GetText();
33 }
34
35 Status
36 SetValueFromString(llvm::StringRef value,
38
39 bool IsDefault() const override {
40 return m_regex.GetText() == m_default_regex_str;
41 }
42
43 // Subclass specific functions
45 return (m_regex.IsValid() ? &m_regex : nullptr);
46 }
47
48 void SetCurrentValue(const char *value) {
49 if (value && value[0])
50 m_regex = RegularExpression(llvm::StringRef(value));
51 else
53 }
54
55 bool IsValid() const { return m_regex.IsValid(); }
56
57protected:
58 void ClearImpl() override {
60 m_value_was_set = false;
61 }
62
65};
66
67} // namespace lldb_private
68
69#endif // LLDB_INTERPRETER_OPTIONVALUEREGEX_H
A class that implements CRTP-based "virtual constructor" idiom.
Definition Cloneable.h:40
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
const RegularExpression * GetCurrentValue() const
llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) const override
OptionValue::Type GetType() const override
Status SetValueFromString(llvm::StringRef value, VarSetOperationType op=eVarSetOperationAssign) override
OptionValueRegex(const char *value=nullptr)
void SetCurrentValue(const char *value)
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override
bool IsDefault() const override
Return true if the current value equals the default value.
~OptionValueRegex() override=default
An error handling class.
Definition Status.h:118
A stream class that can stream formatted output to a file.
Definition Stream.h:28
A class that represents a running process on the host machine.
VarSetOperationType
Settable state variable types.