Path: blob/main/contrib/llvm-project/lldb/source/Interpreter/OptionValueRegex.cpp
39587 views
//===-- OptionValueRegex.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/OptionValueRegex.h"910#include "lldb/Utility/Stream.h"1112using namespace lldb;13using namespace lldb_private;1415void OptionValueRegex::DumpValue(const ExecutionContext *exe_ctx, Stream &strm,16uint32_t dump_mask) {17if (dump_mask & eDumpOptionType)18strm.Printf("(%s)", GetTypeAsCString());19if (dump_mask & eDumpOptionValue) {20if (dump_mask & eDumpOptionType)21strm.PutCString(" = ");22if (m_regex.IsValid()) {23llvm::StringRef regex_text = m_regex.GetText();24strm.Printf("%s", regex_text.str().c_str());25}26}27}2829Status OptionValueRegex::SetValueFromString(llvm::StringRef value,30VarSetOperationType op) {31Status error;32switch (op) {33case eVarSetOperationInvalid:34case eVarSetOperationInsertBefore:35case eVarSetOperationInsertAfter:36case eVarSetOperationRemove:37case eVarSetOperationAppend:38error = OptionValue::SetValueFromString(value, op);39break;4041case eVarSetOperationClear:42Clear();43NotifyValueChanged();44break;4546case eVarSetOperationReplace:47case eVarSetOperationAssign:48m_regex = RegularExpression(value);49if (m_regex.IsValid()) {50m_value_was_set = true;51NotifyValueChanged();52} else if (llvm::Error err = m_regex.GetError()) {53error.SetErrorString(llvm::toString(std::move(err)));54} else {55error.SetErrorString("regex error");56}57break;58}59return error;60}616263