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"
12 #include "lldb/Interpreter/OptionArgParser.h"
13 #include "lldb/Utility/Stream.h"
14 #include "lldb/Utility/StringList.h"
15 #include "llvm/ADT/STLExtras.h"
18 using namespace lldb_private;
20 void OptionValueChar::DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
22 if (dump_mask & eDumpOptionType)
23 strm.Printf("(%s)", GetTypeAsCString());
25 if (dump_mask & eDumpOptionValue) {
26 if (dump_mask & eDumpOptionType)
27 strm.PutCString(" = ");
28 if (m_current_value != '\0')
29 strm.PutChar(m_current_value);
31 strm.PutCString("(null)");
35 Status OptionValueChar::SetValueFromString(llvm::StringRef value,
36 VarSetOperationType op) {
39 case eVarSetOperationClear:
43 case eVarSetOperationReplace:
44 case eVarSetOperationAssign: {
46 char char_value = OptionArgParser::ToChar(value, '\0', &success);
48 m_current_value = char_value;
49 m_value_was_set = true;
51 error.SetErrorStringWithFormat("'%s' cannot be longer than 1 character",
56 error = OptionValue::SetValueFromString(value, op);
62 lldb::OptionValueSP OptionValueChar::DeepCopy() const {
63 return OptionValueSP(new OptionValueChar(*this));