X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=senf%2FSocket%2FProtocols%2FINet%2FINet6Address.cc;h=eddc78bb0368d73b1d75bc21ec2a299371e68bc9;hb=afae50abf125df375ff1610b7a659f9b1da61bc0;hp=f2c0204cba6b686b2d4f70365749829865369486;hpb=0fb5ed1adf2f67dbf47fdfed3f3c8be989cf3618;p=senf.git diff --git a/senf/Socket/Protocols/INet/INet6Address.cc b/senf/Socket/Protocols/INet/INet6Address.cc index f2c0204..eddc78b 100644 --- a/senf/Socket/Protocols/INet/INet6Address.cc +++ b/senf/Socket/Protocols/INet/INet6Address.cc @@ -50,7 +50,7 @@ prefix_ senf::INet6Address senf::INet6Address::from_string(std::string const & s return senf::INet6Address::from_data(&ina.s6_addr[0]); if (s.empty()) - throw AddressSyntaxException(); + throw AddressSyntaxException() << ": empty string"; int herr (0); @@ -131,21 +131,35 @@ prefix_ senf::INet6Network::INet6Network(std::string const & s) using boost::lambda::_2; std::string::size_type i (s.find('/')); if (i == std::string::npos) - throw AddressSyntaxException(); + throw AddressSyntaxException(s); try { prefix_len_ = boost::lexical_cast(std::string(s,i+1)); } catch (boost::bad_lexical_cast const &) { - throw AddressSyntaxException(); + throw AddressSyntaxException(s); } address_ = INet6Address::from_string(std::string(s, 0, i)); detail::apply_mask(prefix_len_, address_.begin(), address_.end(), _1 &= _2); } +prefix_ std::istream & senf::operator>>(std::istream & is, INet6Network & addr) +{ + std::string s; + if (!(is >> s)) + return is; + try { + addr = INet6Network(s); + } + catch (AddressException &) { + is.setstate(std::ios::failbit); + } + return is; +} + ///////////////////////////////cc.e//////////////////////////////////////// #undef prefix_ //#include "INet6Address.mpp" - + // Local Variables: // mode: c++ // fill-column: 100