util: add ParseUInt16(), use it in SplitHostPort()

This commit is contained in:
Jon Atack
2021-03-02 22:37:50 +01:00
parent 6423c8175f
commit 2875a764f7
2 changed files with 21 additions and 2 deletions

View File

@@ -115,6 +115,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,