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/Core/Stream.h"
17 #include "lldb/Core/StringList.h"
18 #include "lldb/Interpreter/Args.h"
19 #include "llvm/ADT/STLExtras.h"
22 using namespace lldb_private;
25 OptionValueChar::DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask)
27 if (dump_mask & eDumpOptionType)
28 strm.Printf ("(%s)", GetTypeAsCString ());
30 if (dump_mask & eDumpOptionValue)
32 if (dump_mask & eDumpOptionType)
33 strm.PutCString (" = ");
34 if (m_current_value != '\0')
35 strm.PutChar(m_current_value);
37 strm.PutCString("(null)");
42 OptionValueChar::SetValueFromString (llvm::StringRef value,
43 VarSetOperationType op)
48 case eVarSetOperationClear:
52 case eVarSetOperationReplace:
53 case eVarSetOperationAssign:
56 char char_value = Args::StringToChar(value.str().c_str(), '\0', &success);
59 m_current_value = char_value;
60 m_value_was_set = true;
63 error.SetErrorStringWithFormat("'%s' cannot be longer than 1 character", value.str().c_str());
68 error = OptionValue::SetValueFromString (value.str().c_str(), op);
75 OptionValueChar::DeepCopy () const
77 return OptionValueSP(new OptionValueChar(*this));