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
12#include "lldb/Utility/Stream.h"
13
14using namespace lldb;
15using namespace lldb_private;
16
18 uint32_t dump_mask) {
19 if (dump_mask & eDumpOptionType)
20 strm.Printf("(%s)", GetTypeAsCString());
21 if (dump_mask & eDumpOptionValue) {
22 if (dump_mask & eDumpOptionType)
23 strm.PutCString(" = ");
24 if (m_regex.IsValid()) {
25 llvm::StringRef regex_text = m_regex.GetText();
26 strm.Printf("%s", regex_text.str().c_str());
27 }
28 if (dump_mask & eDumpOptionDefaultValue &&
29 m_regex.GetText() != m_default_regex_str &&
30 !m_default_regex_str.empty()) {
31 DefaultValueFormat label(strm);
33 }
34 }
35}
36
40 switch (op) {
47 break;
48
50 Clear();
52 break;
53
57 if (m_regex.IsValid()) {
58 m_value_was_set = true;
60 } else if (llvm::Error err = m_regex.GetError()) {
61 return Status::FromError(std::move(err));
62 } else {
63 return Status::FromErrorString("regex error");
64 }
65 break;
66 }
67 return error;
68}
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:89
An error handling class.
Definition Status.h:118
static Status FromErrorString(const char *str)
Definition Status.h:141
static Status FromError(llvm::Error error)
Avoid using this in new code. Migrate APIs to llvm::Expected instead.
Definition Status.cpp:137
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.