IPAddress::IPAddress(const std::string& addr) { IPv4AddressImpl empty4 = IPv4AddressImpl(); if (addr.empty() || trim(addr) == "0.0.0.0") { newIPv4(empty4.addr()); return; } IPv4AddressImpl addr4(IPv4AddressImpl::parse(addr)); if (addr4 != empty4) { newIPv4(addr4.addr()); return; } #if defined(POCO_HAVE_IPv6) IPv6AddressImpl empty6 = IPv6AddressImpl(); if (addr.empty() || trim(addr) == "::") { newIPv6(empty6.addr()); return; } IPv6AddressImpl addr6(IPv6AddressImpl::parse(addr)); if (addr6 != IPv6AddressImpl()) { newIPv6(addr6.addr(), addr6.scope()); return; } #endif throw InvalidAddressException(addr); }
bool CBase58Data::SetString(const char* psz, unsigned int nVersionBytes) { std::vector<unsigned char> vchTemp; bool rc58 = DecodeBase58Check(psz, vchTemp); if ((!rc58) || (vchTemp.size() < nVersionBytes)) { vchData.clear(); vchVersion.clear(); throw InvalidAddressException(); } vchVersion.assign(vchTemp.begin(), vchTemp.begin() + nVersionBytes); vchData.resize(vchTemp.size() - nVersionBytes); if (!vchData.empty()) memcpy(vchData.data(), vchTemp.data() + nVersionBytes, vchData.size()); return true; }