mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-13 07:28:59 +01:00
Merge #21415: refactor: remove Optional & nullopt
ebc4ab721brefactor: post Optional<> removal cleanups (fanquake)57e980d13cscripted-diff: remove Optional & nullopt (fanquake) Pull request description: Same rationale & motivation as #21404, which turned out to be quite low in the number of potential conflicts. Lets see what the bot has to say here. ACKs for top commit: practicalswift: cr ACKebc4ab721b: patch looks correct jnewbery: utACKebc4ab721blaanwj: Code review ACKebc4ab721bTree-SHA512: 550fbeef09b9d35ddefaa805d1755c18c8fd499c4b0f77ebfece8c20296a7abd1cf6c699e2261f92fe3552deeb7555ec2a2287ffe3ab9e98bb9f8612a4d43be3
This commit is contained in:
@@ -315,7 +315,7 @@ bool ArgsManager::ParseParameters(int argc, const char* const argv[], std::strin
|
||||
if (key[0] != '-') {
|
||||
if (!m_accept_any_command && m_command.empty()) {
|
||||
// The first non-dash arg is a registered command
|
||||
Optional<unsigned int> flags = GetArgFlags(key);
|
||||
std::optional<unsigned int> flags = GetArgFlags(key);
|
||||
if (!flags || !(*flags & ArgsManager::COMMAND)) {
|
||||
error = strprintf("Invalid command '%s'", argv[i]);
|
||||
return false;
|
||||
@@ -337,7 +337,7 @@ bool ArgsManager::ParseParameters(int argc, const char* const argv[], std::strin
|
||||
key.erase(0, 1);
|
||||
std::string section;
|
||||
util::SettingsValue value = InterpretOption(section, key, val);
|
||||
Optional<unsigned int> flags = GetArgFlags('-' + key);
|
||||
std::optional<unsigned int> flags = GetArgFlags('-' + key);
|
||||
|
||||
// Unknown command line options and command line options with dot
|
||||
// characters (which are returned from InterpretOption with nonempty
|
||||
@@ -363,7 +363,7 @@ bool ArgsManager::ParseParameters(int argc, const char* const argv[], std::strin
|
||||
return success;
|
||||
}
|
||||
|
||||
Optional<unsigned int> ArgsManager::GetArgFlags(const std::string& name) const
|
||||
std::optional<unsigned int> ArgsManager::GetArgFlags(const std::string& name) const
|
||||
{
|
||||
LOCK(cs_args);
|
||||
for (const auto& arg_map : m_available_args) {
|
||||
@@ -372,7 +372,7 @@ Optional<unsigned int> ArgsManager::GetArgFlags(const std::string& name) const
|
||||
return search->second.m_flags;
|
||||
}
|
||||
}
|
||||
return nullopt;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::optional<const ArgsManager::Command> ArgsManager::GetCommand() const
|
||||
@@ -874,7 +874,7 @@ bool ArgsManager::ReadConfigStream(std::istream& stream, const std::string& file
|
||||
std::string section;
|
||||
std::string key = option.first;
|
||||
util::SettingsValue value = InterpretOption(section, key, option.second);
|
||||
Optional<unsigned int> flags = GetArgFlags('-' + key);
|
||||
std::optional<unsigned int> flags = GetArgFlags('-' + key);
|
||||
if (flags) {
|
||||
if (!CheckValid(key, value, *flags, error)) {
|
||||
return false;
|
||||
@@ -1034,7 +1034,7 @@ void ArgsManager::logArgsPrefix(
|
||||
std::string section_str = section.empty() ? "" : "[" + section + "] ";
|
||||
for (const auto& arg : args) {
|
||||
for (const auto& value : arg.second) {
|
||||
Optional<unsigned int> flags = GetArgFlags('-' + arg.first);
|
||||
std::optional<unsigned int> flags = GetArgFlags('-' + arg.first);
|
||||
if (flags) {
|
||||
std::string value_str = (*flags & SENSITIVE) ? "****" : value.write();
|
||||
LogPrintf("%s %s%s=%s\n", prefix, section_str, arg.first, value_str);
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
#include <compat/assumptions.h>
|
||||
#include <fs.h>
|
||||
#include <logging.h>
|
||||
#include <optional.h>
|
||||
#include <sync.h>
|
||||
#include <tinyformat.h>
|
||||
#include <util/settings.h>
|
||||
@@ -28,6 +27,7 @@
|
||||
|
||||
#include <exception>
|
||||
#include <map>
|
||||
#include <optional>
|
||||
#include <set>
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
@@ -375,7 +375,7 @@ public:
|
||||
* Return Flags for known arg.
|
||||
* Return nullopt for unknown arg.
|
||||
*/
|
||||
Optional<unsigned int> GetArgFlags(const std::string& name) const;
|
||||
std::optional<unsigned int> GetArgFlags(const std::string& name) const;
|
||||
|
||||
/**
|
||||
* Read and update settings file with saved settings. This needs to be
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <optional>
|
||||
#include <unistd.h>
|
||||
|
||||
TokenPipeEnd TokenPipe::TakeReadEnd()
|
||||
|
||||
Reference in New Issue
Block a user