]>
Commit | Line | Data |
---|---|---|
7c673cae | 1 | // |
b32b8144 | 2 | // ip/impl/network_v4.hpp |
7c673cae FG |
3 | // ~~~~~~~~~~~~~~~~~~~~~~ |
4 | // | |
f67539c2 | 5 | // Copyright (c) 2003-2020 Christopher M. Kohlhoff (chris at kohlhoff dot com) |
b32b8144 | 6 | // Copyright (c) 2014 Oliver Kowalke (oliver dot kowalke at gmail dot com) |
7c673cae FG |
7 | // |
8 | // Distributed under the Boost Software License, Version 1.0. (See accompanying | |
9 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
10 | // | |
11 | ||
b32b8144 FG |
12 | #ifndef BOOST_ASIO_IP_IMPL_NETWORK_V4_HPP |
13 | #define BOOST_ASIO_IP_IMPL_NETWORK_V4_HPP | |
7c673cae FG |
14 | |
15 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) | |
16 | # pragma once | |
17 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) | |
18 | ||
19 | #if !defined(BOOST_ASIO_NO_IOSTREAM) | |
20 | ||
21 | #include <boost/asio/detail/throw_error.hpp> | |
22 | ||
23 | #include <boost/asio/detail/push_options.hpp> | |
24 | ||
25 | namespace boost { | |
26 | namespace asio { | |
27 | namespace ip { | |
28 | ||
29 | template <typename Elem, typename Traits> | |
30 | std::basic_ostream<Elem, Traits>& operator<<( | |
b32b8144 | 31 | std::basic_ostream<Elem, Traits>& os, const network_v4& addr) |
7c673cae FG |
32 | { |
33 | boost::system::error_code ec; | |
34 | std::string s = addr.to_string(ec); | |
35 | if (ec) | |
36 | { | |
37 | if (os.exceptions() & std::basic_ostream<Elem, Traits>::failbit) | |
38 | boost::asio::detail::throw_error(ec); | |
39 | else | |
40 | os.setstate(std::basic_ostream<Elem, Traits>::failbit); | |
41 | } | |
42 | else | |
43 | for (std::string::iterator i = s.begin(); i != s.end(); ++i) | |
44 | os << os.widen(*i); | |
45 | return os; | |
46 | } | |
47 | ||
48 | } // namespace ip | |
49 | } // namespace asio | |
50 | } // namespace boost | |
51 | ||
52 | #include <boost/asio/detail/pop_options.hpp> | |
53 | ||
54 | #endif // !defined(BOOST_ASIO_NO_IOSTREAM) | |
55 | ||
b32b8144 | 56 | #endif // BOOST_ASIO_IP_IMPL_NETWORK_V4_HPP |