1 //===-- OptionValueChar.cpp -------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "lldb/Interpreter/OptionValueChar.h"
14 // Other libraries and framework includes
16 #include "lldb/Interpreter/OptionArgParser.h"
17 #include "lldb/Utility/Stream.h"
18 #include "lldb/Utility/StringList.h"
19 #include "llvm/ADT/STLExtras.h"
22 using namespace lldb_private;
24 void OptionValueChar::DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
26 if (dump_mask & eDumpOptionType)
27 strm.Printf("(%s)", GetTypeAsCString());
29 if (dump_mask & eDumpOptionValue) {
30 if (dump_mask & eDumpOptionType)
31 strm.PutCString(" = ");
32 if (m_current_value != '\0')
33 strm.PutChar(m_current_value);
35 strm.PutCString("(null)");
39 Status OptionValueChar::SetValueFromString(llvm::StringRef value,
40 VarSetOperationType op) {
43 case eVarSetOperationClear:
47 case eVarSetOperationReplace:
48 case eVarSetOperationAssign: {
50 char char_value = OptionArgParser::ToChar(value, '\0', &success);
52 m_current_value = char_value;
53 m_value_was_set = true;
55 error.SetErrorStringWithFormat("'%s' cannot be longer than 1 character",
60 error = OptionValue::SetValueFromString(value, op);
66 lldb::OptionValueSP OptionValueChar::DeepCopy() const {
67 return OptionValueSP(new OptionValueChar(*this));