99#ifndef BITCOIN_UTIL_STRENCODINGS_H
1010#define BITCOIN_UTIL_STRENCODINGS_H
1111
12- #include < stdint.h>
12+ #include < attributes.h>
13+
14+ #include < cstdint>
1315#include < string>
1416#include < vector>
1517
@@ -92,35 +94,35 @@ constexpr inline bool IsSpace(char c) noexcept {
9294 * @returns true if the entire string could be parsed as valid integer,
9395 * false if not the entire string could be parsed or when overflow or underflow occurred.
9496 */
95- bool ParseInt32 (const std::string& str, int32_t *out);
97+ NODISCARD bool ParseInt32 (const std::string& str, int32_t *out);
9698
9799/* *
98100 * Convert string to signed 64-bit integer with strict parse error feedback.
99101 * @returns true if the entire string could be parsed as valid integer,
100102 * false if not the entire string could be parsed or when overflow or underflow occurred.
101103 */
102- bool ParseInt64 (const std::string& str, int64_t *out);
104+ NODISCARD bool ParseInt64 (const std::string& str, int64_t *out);
103105
104106/* *
105107 * Convert decimal string to unsigned 32-bit integer with strict parse error feedback.
106108 * @returns true if the entire string could be parsed as valid integer,
107109 * false if not the entire string could be parsed or when overflow or underflow occurred.
108110 */
109- bool ParseUInt32 (const std::string& str, uint32_t *out);
111+ NODISCARD bool ParseUInt32 (const std::string& str, uint32_t *out);
110112
111113/* *
112114 * Convert decimal string to unsigned 64-bit integer with strict parse error feedback.
113115 * @returns true if the entire string could be parsed as valid integer,
114116 * false if not the entire string could be parsed or when overflow or underflow occurred.
115117 */
116- bool ParseUInt64 (const std::string& str, uint64_t *out);
118+ NODISCARD bool ParseUInt64 (const std::string& str, uint64_t *out);
117119
118120/* *
119121 * Convert string to double with strict parse error feedback.
120122 * @returns true if the entire string could be parsed as valid double,
121123 * false if not the entire string could be parsed or when overflow or underflow occurred.
122124 */
123- bool ParseDouble (const std::string& str, double *out);
125+ NODISCARD bool ParseDouble (const std::string& str, double *out);
124126
125127template <typename T>
126128std::string HexStr (const T itbegin, const T itend, bool fSpaces =false )
@@ -173,7 +175,7 @@ bool TimingResistantEqual(const T& a, const T& b)
173175 * @returns true on success, false on error.
174176 * @note The result must be in the range (-10^18,10^18), otherwise an overflow error will trigger.
175177 */
176- bool ParseFixedPoint (const std::string &val, int decimals, int64_t *amount_out);
178+ NODISCARD bool ParseFixedPoint (const std::string &val, int decimals, int64_t *amount_out);
177179
178180/* * Convert from one power-of-2 number base to another. */
179181template <int frombits, int tobits, bool pad, typename O, typename I>
@@ -200,7 +202,7 @@ bool ConvertBits(const O& outfn, I it, I end) {
200202}
201203
202204/* * Parse an HD keypaths like "m/7/0'/2000". */
203- bool ParseHDKeypath (const std::string& keypath_str, std::vector<uint32_t >& keypath);
205+ NODISCARD bool ParseHDKeypath (const std::string& keypath_str, std::vector<uint32_t >& keypath);
204206
205207/* *
206208 * Converts the given character to its lowercase equivalent.
0 commit comments