// public string constructor IPAddress::IPAddress(StringPiece str) : addr_(), family_(AF_UNSPEC) { auto maybeIp = tryFromString(str); if (maybeIp.hasError()) { throw IPAddressFormatException( to<std::string>("Invalid IP address '", str, "'")); } *this = std::move(maybeIp.value()); }
Version Version::fromString(const QString& str) { tl::optional<Version> version = tryFromString(str); if (version) { return *version; } else { throw RuntimeError( __FILE__, __LINE__, QString(Version::tr("Invalid version number: \"%1\"")).arg(str)); } }
bool Version::isValid(const QString& str) noexcept { tl::optional<Version> version = tryFromString(str); return version.has_value(); }