Path: blob/main/contrib/llvm-project/lldb/source/Interpreter/OptionGroupOutputFile.cpp
39587 views
//===-- OptionGroupOutputFile.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/OptionGroupOutputFile.h"910#include "lldb/Host/OptionParser.h"1112using namespace lldb;13using namespace lldb_private;1415OptionGroupOutputFile::OptionGroupOutputFile() : m_append(false, false) {}1617static const uint32_t SHORT_OPTION_APND = 0x61706e64; // 'apnd'1819static constexpr OptionDefinition g_option_table[] = {20{LLDB_OPT_SET_1, false, "outfile", 'o', OptionParser::eRequiredArgument,21nullptr, {}, 0, eArgTypeFilename,22"Specify a path for capturing command output."},23{LLDB_OPT_SET_1, false, "append-outfile", SHORT_OPTION_APND,24OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone,25"Append to the file specified with '--outfile <path>'."},26};2728llvm::ArrayRef<OptionDefinition> OptionGroupOutputFile::GetDefinitions() {29return llvm::ArrayRef(g_option_table);30}3132Status33OptionGroupOutputFile::SetOptionValue(uint32_t option_idx,34llvm::StringRef option_arg,35ExecutionContext *execution_context) {36Status error;37const int short_option = g_option_table[option_idx].short_option;3839switch (short_option) {40case 'o':41error = m_file.SetValueFromString(option_arg);42break;4344case SHORT_OPTION_APND:45m_append.SetCurrentValue(true);46break;4748default:49llvm_unreachable("Unimplemented option");50}5152return error;53}5455void OptionGroupOutputFile::OptionParsingStarting(56ExecutionContext *execution_context) {57m_file.Clear();58m_append.Clear();59}606162