/Src/Dependencies/Boost/boost/asio/ip/impl/address.hpp

http://hadesmem.googlecode.com/ · C++ Header · 55 lines · 35 code · 11 blank · 9 comment · 5 complexity · cf09f7f9ce447f76d28a5f5608a48362 MD5 · raw file

  1. //
  2. // ip/impl/address.hpp
  3. // ~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com)
  6. //
  7. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  8. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  9. //
  10. #ifndef BOOST_ASIO_IP_IMPL_ADDRESS_HPP
  11. #define BOOST_ASIO_IP_IMPL_ADDRESS_HPP
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  15. #if !defined(BOOST_NO_IOSTREAM)
  16. #include <boost/asio/detail/throw_error.hpp>
  17. #include <boost/asio/detail/push_options.hpp>
  18. namespace boost {
  19. namespace asio {
  20. namespace ip {
  21. template <typename Elem, typename Traits>
  22. std::basic_ostream<Elem, Traits>& operator<<(
  23. std::basic_ostream<Elem, Traits>& os, const address& addr)
  24. {
  25. boost::system::error_code ec;
  26. std::string s = addr.to_string(ec);
  27. if (ec)
  28. {
  29. if (os.exceptions() & std::basic_ostream<Elem, Traits>::failbit)
  30. boost::asio::detail::throw_error(ec);
  31. else
  32. os.setstate(std::basic_ostream<Elem, Traits>::failbit);
  33. }
  34. else
  35. for (std::string::iterator i = s.begin(); i != s.end(); ++i)
  36. os << os.widen(*i);
  37. return os;
  38. }
  39. } // namespace ip
  40. } // namespace asio
  41. } // namespace boost
  42. #include <boost/asio/detail/pop_options.hpp>
  43. #endif // !defined(BOOST_NO_IOSTREAM)
  44. #endif // BOOST_ASIO_IP_IMPL_ADDRESS_HPP