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 liblldb_OptionValueRegex_h_
10 #define liblldb_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 
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  Status
32  SetValueFromString(llvm::StringRef value,
34  Status
35  SetValueFromString(const char *,
37 
38  bool Clear() override {
39  m_regex.Clear();
40  m_value_was_set = false;
41  return true;
42  }
43 
44  lldb::OptionValueSP DeepCopy() const override;
45 
46  // Subclass specific functions
48  return (m_regex.IsValid() ? &m_regex : nullptr);
49  }
50 
51  void SetCurrentValue(const char *value) {
52  if (value && value[0])
53  m_regex.Compile(llvm::StringRef(value));
54  else
55  m_regex.Clear();
56  }
57 
58  bool IsValid() const { return m_regex.IsValid(); }
59 
60 protected:
62 };
63 
64 } // namespace lldb_private
65 
66 #endif // liblldb_OptionValueRegex_h_
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
Definition: Debugger.h:71
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
const RegularExpression * GetCurrentValue() const
"lldb/Utility/RegularExpression.h" A C++ wrapper class for regex.
lldb::OptionValueSP DeepCopy() const override
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
~OptionValueRegex() override=default
bool IsValid() const
Test if valid.
VarSetOperationType
Settable state variable types.
bool Compile(llvm::StringRef string)
Compile a regular expression.
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