LLDB  mainline
OptionValueRegex.cpp
Go to the documentation of this file.
1 //===-- OptionValueRegex.cpp ------------------------------------*- 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 
10 
11 #include "lldb/Utility/Stream.h"
12 
13 using namespace lldb;
14 using namespace lldb_private;
15 
17  uint32_t dump_mask) {
18  if (dump_mask & eDumpOptionType)
19  strm.Printf("(%s)", GetTypeAsCString());
20  if (dump_mask & eDumpOptionValue) {
21  if (dump_mask & eDumpOptionType)
22  strm.PutCString(" = ");
23  if (m_regex.IsValid()) {
24  llvm::StringRef regex_text = m_regex.GetText();
25  strm.Printf("%s", regex_text.str().c_str());
26  }
27  }
28 }
29 
30 Status OptionValueRegex::SetValueFromString(llvm::StringRef value,
32  Status error;
33  switch (op) {
39  error = OptionValue::SetValueFromString(value, op);
40  break;
41 
43  Clear();
44  NotifyValueChanged();
45  break;
46 
49  if (m_regex.Compile(value)) {
50  m_value_was_set = true;
51  NotifyValueChanged();
52  } else {
53  char regex_error[1024];
54  if (m_regex.GetErrorAsCString(regex_error, sizeof(regex_error)))
55  error.SetErrorString(regex_error);
56  else
57  error.SetErrorStringWithFormat("regex error %u",
58  m_regex.GetErrorCode());
59  }
60  break;
61  }
62  return error;
63 }
64 
65 lldb::OptionValueSP OptionValueRegex::DeepCopy() const {
66  return OptionValueSP(new OptionValueRegex(m_regex.GetText().str().c_str()));
67 }
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition: Stream.cpp:61
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
VarSetOperationType
Settable state variable types.
void SetErrorString(llvm::StringRef err_str)
Set the current error string to err_str.
Definition: Status.cpp:241
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:106
Definition: SBAddress.h:15
int SetErrorStringWithFormat(const char *format,...) __attribute__((format(printf
Set the current error string to a formatted error string.
Definition: Status.cpp:255
static bool DumpValue(Stream &s, const SymbolContext *sc, const ExecutionContext *exe_ctx, const FormatEntity::Entry &entry, ValueObject *valobj)
An error handling class.
Definition: Status.h:44