LLDB mainline
OptionValueRegex.cpp
Go to the documentation of this file.
1//===-- OptionValueRegex.cpp ----------------------------------------------===//
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
13using namespace lldb;
14using 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
33 switch (op) {
40 break;
41
43 Clear();
45 break;
46
50 if (m_regex.IsValid()) {
51 m_value_was_set = true;
53 } else if (llvm::Error err = m_regex.GetError()) {
54 error.SetErrorString(llvm::toString(std::move(err)));
55 } else {
56 error.SetErrorString("regex error");
57 }
58 break;
59 }
60 return error;
61}
static llvm::raw_ostream & error(Stream &strm)
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
Status SetValueFromString(llvm::StringRef value, VarSetOperationType op=eVarSetOperationAssign) override
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override
virtual Status SetValueFromString(llvm::StringRef value, VarSetOperationType op=eVarSetOperationAssign)
virtual const char * GetTypeAsCString() const
Definition: OptionValue.h:87
bool IsValid() const
Test if this object contains a valid regular expression.
llvm::Error GetError() const
Return an error if the regular expression failed to compile.
llvm::StringRef GetText() const
Access the regular expression text.
An error handling class.
Definition: Status.h:44
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:134
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition: Stream.cpp:65
A class that represents a running process on the host machine.
VarSetOperationType
Settable state variable types.
Definition: SBAddress.h:15