Path: blob/main/contrib/llvm-project/lldb/source/Interpreter/OptionValueFormat.cpp
39587 views
//===-- OptionValueFormat.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/OptionValueFormat.h"910#include "lldb/DataFormatters/FormatManager.h"11#include "lldb/Interpreter/OptionArgParser.h"12#include "lldb/Utility/Stream.h"1314using namespace lldb;15using namespace lldb_private;1617void OptionValueFormat::DumpValue(const ExecutionContext *exe_ctx, Stream &strm,18uint32_t dump_mask) {19if (dump_mask & eDumpOptionType)20strm.Printf("(%s)", GetTypeAsCString());21if (dump_mask & eDumpOptionValue) {22if (dump_mask & eDumpOptionType)23strm.PutCString(" = ");24strm.PutCString(FormatManager::GetFormatAsCString(m_current_value));25}26}2728llvm::json::Value OptionValueFormat::ToJSON(const ExecutionContext *exe_ctx) {29return FormatManager::GetFormatAsCString(m_current_value);30}3132Status OptionValueFormat::SetValueFromString(llvm::StringRef value,33VarSetOperationType op) {34Status error;35switch (op) {36case eVarSetOperationClear:37Clear();38NotifyValueChanged();39break;4041case eVarSetOperationReplace:42case eVarSetOperationAssign: {43Format new_format;44error = OptionArgParser::ToFormat(value.str().c_str(), new_format, nullptr);45if (error.Success()) {46m_value_was_set = true;47m_current_value = new_format;48NotifyValueChanged();49}50} break;5152case eVarSetOperationInsertBefore:53case eVarSetOperationInsertAfter:54case eVarSetOperationRemove:55case eVarSetOperationAppend:56case eVarSetOperationInvalid:57error = OptionValue::SetValueFromString(value, op);58break;59}60return error;61}626364