Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/boost/asio/ip/address_v4_iterator.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 //
0002 // ip/address_v4_iterator.hpp
0003 // ~~~~~~~~~~~~~~~~~~~~~~~~~~
0004 //
0005 // Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com)
0006 //
0007 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0008 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0009 //
0010 
0011 #ifndef BOOST_ASIO_IP_ADDRESS_V4_ITERATOR_HPP
0012 #define BOOST_ASIO_IP_ADDRESS_V4_ITERATOR_HPP
0013 
0014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0015 # pragma once
0016 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
0017 
0018 #include <boost/asio/detail/config.hpp>
0019 #include <boost/asio/ip/address_v4.hpp>
0020 
0021 #include <boost/asio/detail/push_options.hpp>
0022 
0023 namespace boost {
0024 namespace asio {
0025 namespace ip {
0026 
0027 template <typename> class basic_address_iterator;
0028 
0029 /// An input iterator that can be used for traversing IPv4 addresses.
0030 /**
0031  * In addition to satisfying the input iterator requirements, this iterator
0032  * also supports decrement.
0033  *
0034  * @par Thread Safety
0035  * @e Distinct @e objects: Safe.@n
0036  * @e Shared @e objects: Unsafe.
0037  */
0038 template <> class basic_address_iterator<address_v4>
0039 {
0040 public:
0041   /// The type of the elements pointed to by the iterator.
0042   typedef address_v4 value_type;
0043 
0044   /// Distance between two iterators.
0045   typedef std::ptrdiff_t difference_type;
0046 
0047   /// The type of a pointer to an element pointed to by the iterator.
0048   typedef const address_v4* pointer;
0049 
0050   /// The type of a reference to an element pointed to by the iterator.
0051   typedef const address_v4& reference;
0052 
0053   /// Denotes that the iterator satisfies the input iterator requirements.
0054   typedef std::input_iterator_tag iterator_category;
0055 
0056   /// Construct an iterator that points to the specified address.
0057   basic_address_iterator(const address_v4& addr) noexcept
0058     : address_(addr)
0059   {
0060   }
0061 
0062   /// Copy constructor.
0063   basic_address_iterator(const basic_address_iterator& other) noexcept
0064     : address_(other.address_)
0065   {
0066   }
0067 
0068   /// Move constructor.
0069   basic_address_iterator(basic_address_iterator&& other) noexcept
0070     : address_(static_cast<address_v4&&>(other.address_))
0071   {
0072   }
0073 
0074   /// Assignment operator.
0075   basic_address_iterator& operator=(
0076       const basic_address_iterator& other) noexcept
0077   {
0078     address_ = other.address_;
0079     return *this;
0080   }
0081 
0082   /// Move assignment operator.
0083   basic_address_iterator& operator=(basic_address_iterator&& other) noexcept
0084   {
0085     address_ = static_cast<address_v4&&>(other.address_);
0086     return *this;
0087   }
0088 
0089   /// Dereference the iterator.
0090   const address_v4& operator*() const noexcept
0091   {
0092     return address_;
0093   }
0094 
0095   /// Dereference the iterator.
0096   const address_v4* operator->() const noexcept
0097   {
0098     return &address_;
0099   }
0100 
0101   /// Pre-increment operator.
0102   basic_address_iterator& operator++() noexcept
0103   {
0104     address_ = address_v4((address_.to_uint() + 1) & 0xFFFFFFFF);
0105     return *this;
0106   }
0107 
0108   /// Post-increment operator.
0109   basic_address_iterator operator++(int) noexcept
0110   {
0111     basic_address_iterator tmp(*this);
0112     ++*this;
0113     return tmp;
0114   }
0115 
0116   /// Pre-decrement operator.
0117   basic_address_iterator& operator--() noexcept
0118   {
0119     address_ = address_v4((address_.to_uint() - 1) & 0xFFFFFFFF);
0120     return *this;
0121   }
0122 
0123   /// Post-decrement operator.
0124   basic_address_iterator operator--(int)
0125   {
0126     basic_address_iterator tmp(*this);
0127     --*this;
0128     return tmp;
0129   }
0130 
0131   /// Compare two addresses for equality.
0132   friend bool operator==(const basic_address_iterator& a,
0133       const basic_address_iterator& b)
0134   {
0135     return a.address_ == b.address_;
0136   }
0137 
0138   /// Compare two addresses for inequality.
0139   friend bool operator!=(const basic_address_iterator& a,
0140       const basic_address_iterator& b)
0141   {
0142     return a.address_ != b.address_;
0143   }
0144 
0145 private:
0146   address_v4 address_;
0147 };
0148 
0149 /// An input iterator that can be used for traversing IPv4 addresses.
0150 typedef basic_address_iterator<address_v4> address_v4_iterator;
0151 
0152 } // namespace ip
0153 } // namespace asio
0154 } // namespace boost
0155 
0156 #include <boost/asio/detail/pop_options.hpp>
0157 
0158 #endif // BOOST_ASIO_IP_ADDRESS_V4_ITERATOR_HPP