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 
15 namespace lldb_private {
16 
17 class OptionValueRegex : public OptionValue {
18 public:
19  OptionValueRegex(const char *value = nullptr)
20  : OptionValue(), m_regex(llvm::StringRef::withNullAsEmpty(value)),
21  m_default_regex_str(llvm::StringRef::withNullAsEmpty(value).str()) {}
22 
23  ~OptionValueRegex() override = default;
24 
25  // Virtual subclass pure virtual overrides
26 
27  OptionValue::Type GetType() const override { return eTypeRegex; }
28 
29  void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
30  uint32_t dump_mask) override;
31 
32  Status
33  SetValueFromString(llvm::StringRef value,
35  Status
36  SetValueFromString(const char *,
38 
39  bool Clear() override {
41  m_value_was_set = false;
42  return true;
43  }
44 
45  lldb::OptionValueSP DeepCopy() const override;
46 
47  // Subclass specific functions
49  return (m_regex.IsValid() ? &m_regex : nullptr);
50  }
51 
52  void SetCurrentValue(const char *value) {
53  if (value && value[0])
54  m_regex = RegularExpression(llvm::StringRef(value));
55  else
57  }
58 
59  bool IsValid() const { return m_regex.IsValid(); }
60 
61 protected:
63  std::string m_default_regex_str;
64 };
65 
66 } // namespace lldb_private
67 
68 #endif // LLDB_INTERPRETER_OPTIONVALUEREGEX_H
A class that represents a running process on the host machine.
Definition: Debugger.h:49
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
const RegularExpression * GetCurrentValue() const
lldb::OptionValueSP DeepCopy() const override
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
~OptionValueRegex() override=default
bool IsValid() const
Test if this object contains a valid regular expression.
VarSetOperationType
Settable state variable types.
void SetCurrentValue(const char *value)
OptionValue::Type GetType() const override
Status SetValueFromString(llvm::StringRef value, VarSetOperationType op=eVarSetOperationAssign) override
OptionValueRegex(const char *value=nullptr)
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override
An error handling class.
Definition: Status.h:44