mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-14 16:50:17 +02:00
scripted-diff: Use [[nodiscard]] (C++17) instead of NODISCARD
-BEGIN VERIFY SCRIPT- sed -i "s/NODISCARD/[[nodiscard]]/g" $(git grep -l "NODISCARD" ":(exclude)src/bench/nanobench.h" ":(exclude)src/attributes.h") -END VERIFY SCRIPT-
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
#include <vector>
|
||||
|
||||
/** Parse an HD keypaths like "m/7/0'/2000". */
|
||||
NODISCARD bool ParseHDKeypath(const std::string& keypath_str, std::vector<uint32_t>& keypath);
|
||||
[[nodiscard]] bool ParseHDKeypath(const std::string& keypath_str, std::vector<uint32_t>& keypath);
|
||||
|
||||
/** Write HD keypaths as strings */
|
||||
std::string WriteHDKeypath(const std::vector<uint32_t>& keypath);
|
||||
|
||||
@@ -19,6 +19,6 @@
|
||||
*/
|
||||
std::string FormatMoney(const CAmount& n);
|
||||
/** Parse an amount denoted in full coins. E.g. "0.0034" supplied on the command line. **/
|
||||
NODISCARD bool ParseMoney(const std::string& str, CAmount& nRet);
|
||||
[[nodiscard]] bool ParseMoney(const std::string& str, CAmount& nRet);
|
||||
|
||||
#endif // BITCOIN_UTIL_MONEYSTR_H
|
||||
|
||||
@@ -280,7 +280,7 @@ std::string DecodeBase32(const std::string& str, bool* pf_invalid)
|
||||
return std::string((const char*)vchRet.data(), vchRet.size());
|
||||
}
|
||||
|
||||
NODISCARD static bool ParsePrechecks(const std::string& str)
|
||||
[[nodiscard]] static bool ParsePrechecks(const std::string& str)
|
||||
{
|
||||
if (str.empty()) // No empty string allowed
|
||||
return false;
|
||||
|
||||
@@ -101,42 +101,42 @@ constexpr inline bool IsSpace(char c) noexcept {
|
||||
* @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(const std::string& str, int32_t *out);
|
||||
[[nodiscard]] bool ParseInt32(const std::string& 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(const std::string& str, int64_t *out);
|
||||
[[nodiscard]] bool ParseInt64(const std::string& 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(const std::string& str, uint8_t *out);
|
||||
[[nodiscard]] bool ParseUInt8(const std::string& str, uint8_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(const std::string& str, uint32_t *out);
|
||||
[[nodiscard]] bool ParseUInt32(const std::string& 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(const std::string& str, uint64_t *out);
|
||||
[[nodiscard]] bool ParseUInt64(const std::string& str, uint64_t *out);
|
||||
|
||||
/**
|
||||
* Convert string to double with strict parse error feedback.
|
||||
* @returns true if the entire string could be parsed as valid double,
|
||||
* false if not the entire string could be parsed or when overflow or underflow occurred.
|
||||
*/
|
||||
NODISCARD bool ParseDouble(const std::string& str, double *out);
|
||||
[[nodiscard]] bool ParseDouble(const std::string& str, double *out);
|
||||
|
||||
/**
|
||||
* Convert a span of bytes to a lower-case hexadecimal string.
|
||||
@@ -170,7 +170,7 @@ bool TimingResistantEqual(const T& a, const T& b)
|
||||
* @returns true on success, false on error.
|
||||
* @note The result must be in the range (-10^18,10^18), otherwise an overflow error will trigger.
|
||||
*/
|
||||
NODISCARD bool ParseFixedPoint(const std::string &val, int decimals, int64_t *amount_out);
|
||||
[[nodiscard]] bool ParseFixedPoint(const std::string &val, int decimals, int64_t *amount_out);
|
||||
|
||||
/** Convert from one power-of-2 number base to another. */
|
||||
template<int frombits, int tobits, bool pad, typename O, typename I>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
NODISCARD inline std::string TrimString(const std::string& str, const std::string& pattern = " \f\n\r\t\v")
|
||||
[[nodiscard]] inline std::string TrimString(const std::string& str, const std::string& pattern = " \f\n\r\t\v")
|
||||
{
|
||||
std::string::size_type front = str.find_first_not_of(pattern);
|
||||
if (front == std::string::npos) {
|
||||
@@ -59,7 +59,7 @@ inline std::string Join(const std::vector<std::string>& list, const std::string&
|
||||
/**
|
||||
* Check if a string does not contain any embedded NUL (\0) characters
|
||||
*/
|
||||
NODISCARD inline bool ValidAsCString(const std::string& str) noexcept
|
||||
[[nodiscard]] inline bool ValidAsCString(const std::string& str) noexcept
|
||||
{
|
||||
return str.size() == strlen(str.c_str());
|
||||
}
|
||||
@@ -80,7 +80,7 @@ std::string ToString(const T& t)
|
||||
* Check whether a container begins with the given prefix.
|
||||
*/
|
||||
template <typename T1, size_t PREFIX_LEN>
|
||||
NODISCARD inline bool HasPrefix(const T1& obj,
|
||||
[[nodiscard]] inline bool HasPrefix(const T1& obj,
|
||||
const std::array<uint8_t, PREFIX_LEN>& prefix)
|
||||
{
|
||||
return obj.size() >= PREFIX_LEN &&
|
||||
|
||||
@@ -188,7 +188,7 @@ protected:
|
||||
std::map<OptionsCategory, std::map<std::string, Arg>> m_available_args GUARDED_BY(cs_args);
|
||||
std::list<SectionInfo> m_config_sections GUARDED_BY(cs_args);
|
||||
|
||||
NODISCARD bool ReadConfigStream(std::istream& stream, const std::string& filepath, std::string& error, bool ignore_invalid_keys = false);
|
||||
[[nodiscard]] bool ReadConfigStream(std::istream& stream, const std::string& filepath, std::string& error, bool ignore_invalid_keys = false);
|
||||
|
||||
/**
|
||||
* Returns true if settings values from the default section should be used,
|
||||
@@ -220,8 +220,8 @@ public:
|
||||
*/
|
||||
void SelectConfigNetwork(const std::string& network);
|
||||
|
||||
NODISCARD bool ParseParameters(int argc, const char* const argv[], std::string& error);
|
||||
NODISCARD bool ReadConfigFiles(std::string& error, bool ignore_invalid_keys = false);
|
||||
[[nodiscard]] bool ParseParameters(int argc, const char* const argv[], std::string& error);
|
||||
[[nodiscard]] bool ReadConfigFiles(std::string& error, bool ignore_invalid_keys = false);
|
||||
|
||||
/**
|
||||
* Log warnings for options in m_section_only_args when
|
||||
|
||||
Reference in New Issue
Block a user