Refactor OptionValue to return a std::optional instead of taking a fail value. This allows the caller to handle situations where there's no value, instead of being unable to distinguish between the absence of a value and the value happening the match the fail value. When a fail value is required, std::optional::value_or() provides the same functionality.
22 lines
706 B
C++
22 lines
706 B
C++
//===-- OptionValueArgs.cpp -----------------------------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "lldb/Interpreter/OptionValueArgs.h"
|
|
|
|
#include "lldb/Utility/Args.h"
|
|
|
|
using namespace lldb;
|
|
using namespace lldb_private;
|
|
|
|
size_t OptionValueArgs::GetArgs(Args &args) const {
|
|
args.Clear();
|
|
for (const auto &value : m_values)
|
|
args.AppendArgument(value->GetStringValue().value_or(""));
|
|
return args.GetArgumentCount();
|
|
}
|