std::ostream & operator<<(std::ostream & os, INet4Network const & addr);
/** \brief Initialize INet4Address instance from a string representation
+
sets std::ios::failbit on the stream if an error occurred
\see INet4Address from_string()
\related INet4Network
#include "INet4Address.cti"
#endif
-\f
+
// Local Variables:
// mode: c++
// fill-column: 100
BOOST_CHECK_THROW( senf::INet4Network(""), senf::AddressSyntaxException );
BOOST_CHECK_THROW( senf::INet4Network("192.0.2.0/24/beef"), senf::AddressSyntaxException );
+
+ {
+ std::stringstream str;
+ senf::INet4Network net;
+ str >> net;
+ BOOST_CHECK( str.fail());
+ }
+ {
+ std::stringstream str;
+ senf::INet4Network net ("128.129.130.131/128");
+ str << net;
+ BOOST_CHECK_EQUAL( str.str(), "128.129.130.131/128");
+ str >> net;
+ BOOST_CHECK( ! str.fail());
+ BOOST_CHECK_EQUAL(net, senf::INet4Network("128.129.130.131/128"));
+ }
}
///////////////////////////////cc.e////////////////////////////////////////
#undef prefix_
-\f
+
// Local Variables:
// mode: c++
// fill-column: 100
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"
-\f
+
// Local Variables:
// mode: c++
// fill-column: 100
\related INet6Address
*/
std::ostream & operator<<(std::ostream & os, INet6Address const & addr);
+
/** \brief Try to initialize INet6Address instance from a string representation
+
sets std::ios::failbit on the stream if an error occurred
\see INet6Address from_string()
\related INet6Address
\related INet6Network
*/
std::ostream & operator<<(std::ostream & os, INet6Network const & addr);
+
+ /** \brief Try to initialize INet6Network instance from a string representation
+
+ sets std::ios::failbit on the stream if an error occurred
+ \related INet6Network
+ */
+ std::istream & operator>>(std::istream & is, INet6Network & addr);
}
///////////////////////////////hh.e////////////////////////////////////////
#include "INet6Address.cti"
#endif
-\f
+
// Local Variables:
// mode: c++
// fill-column: 100
BOOST_CHECK_THROW( INet6Network(""), AddressSyntaxException );
BOOST_CHECK_THROW( INet6Network("2001:db8:1234::/beef"), AddressSyntaxException );
+
+ {
+ std::stringstream str;
+ INet6Network net;
+ str >> net;
+ BOOST_CHECK( str.fail());
+ }
+ {
+ std::stringstream str;
+ INet6Network net ("2001:db8:1230::/44");
+ str << net;
+ BOOST_CHECK_EQUAL( str.str(), "2001:db8:1230::/44");
+ str >> net;
+ BOOST_CHECK( ! str.fail());
+ BOOST_CHECK_EQUAL(net, INet6Network("2001:db8:1230::/44"));
+ }
}
///////////////////////////////cc.e////////////////////////////////////////
#undef prefix_
-\f
+
// Local Variables:
// mode: c++
// fill-column: 100