mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-02 17:24:58 +02:00
refactor: Remove unused Parse(U)Int*
This commit is contained in:
@@ -199,57 +199,6 @@ std::optional<std::vector<unsigned char>> DecodeBase32(std::string_view str)
|
||||
return ret;
|
||||
}
|
||||
|
||||
namespace {
|
||||
template <typename T>
|
||||
bool ParseIntegral(std::string_view str, T* out)
|
||||
{
|
||||
static_assert(std::is_integral_v<T>);
|
||||
// Replicate the exact behavior of strtol/strtoll/strtoul/strtoull when
|
||||
// handling leading +/- for backwards compatibility.
|
||||
if (str.length() >= 2 && str[0] == '+' && str[1] == '-') {
|
||||
return false;
|
||||
}
|
||||
const std::optional<T> opt_int = ToIntegral<T>((!str.empty() && str[0] == '+') ? str.substr(1) : str);
|
||||
if (!opt_int) {
|
||||
return false;
|
||||
}
|
||||
if (out != nullptr) {
|
||||
*out = *opt_int;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}; // namespace
|
||||
|
||||
bool ParseInt32(std::string_view str, int32_t* out)
|
||||
{
|
||||
return ParseIntegral<int32_t>(str, out);
|
||||
}
|
||||
|
||||
bool ParseInt64(std::string_view str, int64_t* out)
|
||||
{
|
||||
return ParseIntegral<int64_t>(str, out);
|
||||
}
|
||||
|
||||
bool ParseUInt8(std::string_view str, uint8_t* out)
|
||||
{
|
||||
return ParseIntegral<uint8_t>(str, out);
|
||||
}
|
||||
|
||||
bool ParseUInt16(std::string_view str, uint16_t* out)
|
||||
{
|
||||
return ParseIntegral<uint16_t>(str, out);
|
||||
}
|
||||
|
||||
bool ParseUInt32(std::string_view str, uint32_t* out)
|
||||
{
|
||||
return ParseIntegral<uint32_t>(str, out);
|
||||
}
|
||||
|
||||
bool ParseUInt64(std::string_view str, uint64_t* out)
|
||||
{
|
||||
return ParseIntegral<uint64_t>(str, out);
|
||||
}
|
||||
|
||||
std::string FormatParagraph(std::string_view in, size_t width, size_t indent)
|
||||
{
|
||||
assert(width >= indent);
|
||||
|
||||
@@ -187,48 +187,6 @@ std::optional<T> ToIntegral(std::string_view str)
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert string to signed 32-bit integer with strict parse error feedback.
|
||||
* @returns true if the entire string could be parsed as valid integer,
|
||||
* false if not the entire string could be parsed or when overflow or underflow occurred.
|
||||
*/
|
||||
[[nodiscard]] bool ParseInt32(std::string_view str, int32_t *out);
|
||||
|
||||
/**
|
||||
* Convert string to signed 64-bit integer with strict parse error feedback.
|
||||
* @returns true if the entire string could be parsed as valid integer,
|
||||
* false if not the entire string could be parsed or when overflow or underflow occurred.
|
||||
*/
|
||||
[[nodiscard]] bool ParseInt64(std::string_view str, int64_t *out);
|
||||
|
||||
/**
|
||||
* Convert decimal string to unsigned 8-bit integer with strict parse error feedback.
|
||||
* @returns true if the entire string could be parsed as valid integer,
|
||||
* false if not the entire string could be parsed or when overflow or underflow occurred.
|
||||
*/
|
||||
[[nodiscard]] bool ParseUInt8(std::string_view str, uint8_t *out);
|
||||
|
||||
/**
|
||||
* Convert decimal string to unsigned 16-bit integer with strict parse error feedback.
|
||||
* @returns true if the entire string could be parsed as valid integer,
|
||||
* false if the entire string could not be parsed or if overflow or underflow occurred.
|
||||
*/
|
||||
[[nodiscard]] bool ParseUInt16(std::string_view str, uint16_t* out);
|
||||
|
||||
/**
|
||||
* Convert decimal string to unsigned 32-bit integer with strict parse error feedback.
|
||||
* @returns true if the entire string could be parsed as valid integer,
|
||||
* false if not the entire string could be parsed or when overflow or underflow occurred.
|
||||
*/
|
||||
[[nodiscard]] bool ParseUInt32(std::string_view str, uint32_t *out);
|
||||
|
||||
/**
|
||||
* Convert decimal string to unsigned 64-bit integer with strict parse error feedback.
|
||||
* @returns true if the entire string could be parsed as valid integer,
|
||||
* false if not the entire string could be parsed or when overflow or underflow occurred.
|
||||
*/
|
||||
[[nodiscard]] bool ParseUInt64(std::string_view str, uint64_t *out);
|
||||
|
||||
/**
|
||||
* Format a paragraph of text to a fixed width, adding spaces for
|
||||
* indentation to any added line.
|
||||
|
||||
Reference in New Issue
Block a user