LLDB
mainline
llvm-project
lldb
source
Interpreter
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
9
#include "
lldb/Interpreter/OptionValueChar.h
"
10
11
#include "
lldb/Interpreter/OptionArgParser.h
"
12
#include "
lldb/Utility/Stream.h
"
13
#include "
lldb/Utility/StringList.h
"
14
#include "llvm/ADT/STLExtras.h"
15
16
using namespace
lldb
;
17
using namespace
lldb_private
;
18
19
void
OptionValueChar::DumpValue
(
const
ExecutionContext
*exe_ctx,
Stream
&strm,
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,
35
VarSetOperationType
op) {
36
Status
error
;
37
switch
(op) {
38
case
eVarSetOperationClear
:
39
Clear
();
40
break
;
41
42
case
eVarSetOperationReplace
:
43
case
eVarSetOperationAssign
: {
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
}
error
static llvm::raw_ostream & error(Stream &strm)
Definition:
CommandReturnObject.cpp:17
OptionArgParser.h
OptionValueChar.h
Stream.h
StringList.h
lldb_private::ExecutionContext
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
Definition:
ExecutionContext.h:292
lldb_private::OptionValueChar::m_current_value
char m_current_value
Definition:
OptionValueChar.h:62
lldb_private::OptionValueChar::SetValueFromString
Status SetValueFromString(llvm::StringRef value, VarSetOperationType op=eVarSetOperationAssign) override
Definition:
OptionValueChar.cpp:34
lldb_private::OptionValueChar::DumpValue
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override
Definition:
OptionValueChar.cpp:19
lldb_private::OptionValueChar::Clear
void Clear() override
Definition:
OptionValueChar.h:41
lldb_private::OptionValue::SetValueFromString
virtual Status SetValueFromString(llvm::StringRef value, VarSetOperationType op=eVarSetOperationAssign)
Definition:
OptionValue.cpp:602
lldb_private::OptionValue::eDumpOptionType
@ eDumpOptionType
Definition:
OptionValue.h:59
lldb_private::OptionValue::eDumpOptionValue
@ eDumpOptionValue
Definition:
OptionValue.h:60
lldb_private::OptionValue::m_value_was_set
bool m_value_was_set
Definition:
OptionValue.h:346
lldb_private::OptionValue::GetTypeAsCString
virtual const char * GetTypeAsCString() const
Definition:
OptionValue.h:87
lldb_private::Status
An error handling class.
Definition:
Status.h:44
lldb_private::Stream
A stream class that can stream formatted output to a file.
Definition:
Stream.h:28
lldb_private::Stream::Printf
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition:
Stream.cpp:134
lldb_private::Stream::PutCString
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition:
Stream.cpp:65
lldb_private::Stream::PutChar
size_t PutChar(char ch)
Definition:
Stream.cpp:131
lldb_private
A class that represents a running process on the host machine.
Definition:
SBAddressRange.h:14
lldb_private::VarSetOperationType
VarSetOperationType
Settable state variable types.
Definition:
lldb-private-enumerations.h:85
lldb_private::eVarSetOperationAssign
@ eVarSetOperationAssign
Definition:
lldb-private-enumerations.h:92
lldb_private::eVarSetOperationReplace
@ eVarSetOperationReplace
Definition:
lldb-private-enumerations.h:86
lldb_private::eVarSetOperationClear
@ eVarSetOperationClear
Definition:
lldb-private-enumerations.h:91
lldb
Definition:
SBAddress.h:15
lldb_private::OptionArgParser::ToChar
static char ToChar(llvm::StringRef s, char fail_value, bool *success_ptr)
Definition:
OptionArgParser.cpp:52
Generated on Fri Nov 22 2024 09:34:51 for LLDB by
1.9.6