Exemple #1
0
// 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());
}
Exemple #2
0
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));
  }
}
Exemple #3
0
bool Version::isValid(const QString& str) noexcept {
  tl::optional<Version> version = tryFromString(str);
  return version.has_value();
}