123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233 |
- #ifndef BOOST_ASIO_IP_NETWORK_V6_HPP
- #define BOOST_ASIO_IP_NETWORK_V6_HPP
- #if defined(_MSC_VER) && (_MSC_VER >= 1200)
- # pragma once
- #endif
- #include <boost/asio/detail/config.hpp>
- #include <string>
- #include <boost/asio/detail/string_view.hpp>
- #include <boost/system/error_code.hpp>
- #include <boost/asio/ip/address_v6_range.hpp>
- #include <boost/asio/detail/push_options.hpp>
- namespace boost {
- namespace asio {
- namespace ip {
- class network_v6
- {
- public:
-
- network_v6() noexcept
- : address_(),
- prefix_length_(0)
- {
- }
-
- BOOST_ASIO_DECL network_v6(const address_v6& addr,
- unsigned short prefix_len);
-
- network_v6(const network_v6& other) noexcept
- : address_(other.address_),
- prefix_length_(other.prefix_length_)
- {
- }
-
- network_v6(network_v6&& other) noexcept
- : address_(static_cast<address_v6&&>(other.address_)),
- prefix_length_(other.prefix_length_)
- {
- }
-
- network_v6& operator=(const network_v6& other) noexcept
- {
- address_ = other.address_;
- prefix_length_ = other.prefix_length_;
- return *this;
- }
-
- network_v6& operator=(network_v6&& other) noexcept
- {
- address_ = static_cast<address_v6&&>(other.address_);
- prefix_length_ = other.prefix_length_;
- return *this;
- }
-
- address_v6 address() const noexcept
- {
- return address_;
- }
-
-
- unsigned short prefix_length() const noexcept
- {
- return prefix_length_;
- }
-
- BOOST_ASIO_DECL address_v6 network() const noexcept;
-
- BOOST_ASIO_DECL address_v6_range hosts() const noexcept;
-
- network_v6 canonical() const noexcept
- {
- return network_v6(network(), prefix_length());
- }
-
- bool is_host() const noexcept
- {
- return prefix_length_ == 128;
- }
-
- BOOST_ASIO_DECL bool is_subnet_of(const network_v6& other) const;
-
- BOOST_ASIO_DECL std::string to_string() const;
-
- BOOST_ASIO_DECL std::string to_string(boost::system::error_code& ec) const;
-
- friend bool operator==(const network_v6& a, const network_v6& b)
- {
- return a.address_ == b.address_ && a.prefix_length_ == b.prefix_length_;
- }
-
- friend bool operator!=(const network_v6& a, const network_v6& b)
- {
- return !(a == b);
- }
- private:
- address_v6 address_;
- unsigned short prefix_length_;
- };
- inline network_v6 make_network_v6(
- const address_v6& addr, unsigned short prefix_len)
- {
- return network_v6(addr, prefix_len);
- }
- BOOST_ASIO_DECL network_v6 make_network_v6(const char* str);
- BOOST_ASIO_DECL network_v6 make_network_v6(
- const char* str, boost::system::error_code& ec);
- BOOST_ASIO_DECL network_v6 make_network_v6(const std::string& str);
- BOOST_ASIO_DECL network_v6 make_network_v6(
- const std::string& str, boost::system::error_code& ec);
- #if defined(BOOST_ASIO_HAS_STRING_VIEW) \
- || defined(GENERATING_DOCUMENTATION)
- BOOST_ASIO_DECL network_v6 make_network_v6(string_view str);
- BOOST_ASIO_DECL network_v6 make_network_v6(
- string_view str, boost::system::error_code& ec);
- #endif
-
- #if !defined(BOOST_ASIO_NO_IOSTREAM)
- template <typename Elem, typename Traits>
- std::basic_ostream<Elem, Traits>& operator<<(
- std::basic_ostream<Elem, Traits>& os, const network_v6& net);
- #endif
- }
- }
- }
- #include <boost/asio/detail/pop_options.hpp>
- #include <boost/asio/ip/impl/network_v6.hpp>
- #if defined(BOOST_ASIO_HEADER_ONLY)
- # include <boost/asio/ip/impl/network_v6.ipp>
- #endif
- #endif
|