aboutsummaryrefslogtreecommitdiff
path: root/src/util/strencodings.h
diff options
context:
space:
mode:
authorJon Atack <jon@atack.com>2021-03-02 22:37:50 +0100
committerJon Atack <jon@atack.com>2021-03-16 19:52:33 +0100
commit2875a764f7d8b1503c7bdb2f262964f7a0cb5fc3 (patch)
tree56880cb31aa5896e256f08b29285e3e774819d65 /src/util/strencodings.h
parent6423c8175fad3163c10ffdb49e0df48e4e4931f1 (diff)
downloadbitcoin-2875a764f7d8b1503c7bdb2f262964f7a0cb5fc3.tar.xz
util: add ParseUInt16(), use it in SplitHostPort()
Diffstat (limited to 'src/util/strencodings.h')
-rw-r--r--src/util/strencodings.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/util/strencodings.h b/src/util/strencodings.h
index a450b30ca2..26dc0a0ce3 100644
--- a/src/util/strencodings.h
+++ b/src/util/strencodings.h
@@ -116,6 +116,13 @@ constexpr inline bool IsSpace(char c) noexcept {
[[nodiscard]] bool ParseUInt8(const std::string& 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(const std::string& 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.