LLDB  mainline
OptionValueChar.cpp
Go to the documentation of this file.
1 //===-- OptionValueChar.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 
12 #include "lldb/Utility/Stream.h"
14 #include "llvm/ADT/STLExtras.h"
15 
16 using namespace lldb;
17 using namespace lldb_private;
18 
20  uint32_t dump_mask) {
21  if (dump_mask & eDumpOptionType)
22  strm.Printf("(%s)", GetTypeAsCString());
23 
24  if (dump_mask & eDumpOptionValue) {
25  if (dump_mask & eDumpOptionType)
26  strm.PutCString(" = ");
27  if (m_current_value != '\0')
28  strm.PutChar(m_current_value);
29  else
30  strm.PutCString("(null)");
31  }
32 }
33 
34 Status OptionValueChar::SetValueFromString(llvm::StringRef value,
36  Status error;
37  switch (op) {
39  Clear();
40  break;
41 
44  bool success = false;
45  char char_value = OptionArgParser::ToChar(value, '\0', &success);
46  if (success) {
47  m_current_value = char_value;
48  m_value_was_set = true;
49  } else
50  error.SetErrorStringWithFormat("'%s' cannot be longer than 1 character",
51  value.str().c_str());
52  } break;
53 
54  default:
55  error = OptionValue::SetValueFromString(value, op);
56  break;
57  }
58  return error;
59 }
60 
61 lldb::OptionValueSP OptionValueChar::DeepCopy() const {
62  return OptionValueSP(new OptionValueChar(*this));
63 }
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.
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:106
size_t PutChar(char ch)
Definition: Stream.cpp:103
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