Path: blob/main/contrib/llvm-project/lldb/source/Interpreter/OptionValueChar.cpp
39587 views
//===-- OptionValueChar.cpp -----------------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include "lldb/Interpreter/OptionValueChar.h"910#include "lldb/Interpreter/OptionArgParser.h"11#include "lldb/Utility/Stream.h"12#include "lldb/Utility/StringList.h"13#include "llvm/ADT/STLExtras.h"1415using namespace lldb;16using namespace lldb_private;1718void OptionValueChar::DumpValue(const ExecutionContext *exe_ctx, Stream &strm,19uint32_t dump_mask) {20if (dump_mask & eDumpOptionType)21strm.Printf("(%s)", GetTypeAsCString());2223if (dump_mask & eDumpOptionValue) {24if (dump_mask & eDumpOptionType)25strm.PutCString(" = ");26if (m_current_value != '\0')27strm.PutChar(m_current_value);28else29strm.PutCString("(null)");30}31}3233Status OptionValueChar::SetValueFromString(llvm::StringRef value,34VarSetOperationType op) {35Status error;36switch (op) {37case eVarSetOperationClear:38Clear();39break;4041case eVarSetOperationReplace:42case eVarSetOperationAssign: {43bool success = false;44char char_value = OptionArgParser::ToChar(value, '\0', &success);45if (success) {46m_current_value = char_value;47m_value_was_set = true;48} else49error.SetErrorStringWithFormat("'%s' cannot be longer than 1 character",50value.str().c_str());51} break;5253default:54error = OptionValue::SetValueFromString(value, op);55break;56}57return error;58}596061