LLDB mainline
OptionValueChar.cpp
Go to the documentation of this file.
1//===-- OptionValueChar.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
13#include "lldb/Utility/Stream.h"
15#include "llvm/ADT/STLExtras.h"
16
17using namespace lldb;
18using namespace lldb_private;
19
20static void DumpChar(Stream &strm, char value) {
21 if (value != '\0')
22 strm.PutChar(value);
23 else
24 strm.PutCString("(null)");
25}
26
28 uint32_t dump_mask) {
29 if (dump_mask & eDumpOptionType)
30 strm.Printf("(%s)", GetTypeAsCString());
31
32 if (dump_mask & eDumpOptionValue) {
33 if (dump_mask & eDumpOptionType)
34 strm.PutCString(" = ");
36 if (dump_mask & eDumpOptionDefaultValue &&
38 DefaultValueFormat label(strm);
40 }
41 }
42}
43
47 switch (op) {
49 Clear();
50 break;
51
54 bool success = false;
55 char char_value = OptionArgParser::ToChar(value, '\0', &success);
56 if (success) {
57 m_current_value = char_value;
58 m_value_was_set = true;
59 } else
61 "'{0}' cannot be longer than 1 character", value);
62 } break;
63
64 default:
66 break;
67 }
68 return error;
69}
static llvm::raw_ostream & error(Stream &strm)
static void DumpChar(Stream &strm, char value)
"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 static Status FromErrorStringWithFormatv(const char *format, Args &&...args)
Definition Status.h:151
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
size_t PutChar(char ch)
Definition Stream.cpp:131
A class that represents a running process on the host machine.
VarSetOperationType
Settable state variable types.
static char ToChar(llvm::StringRef s, char fail_value, bool *success_ptr)