Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

address_v4_range.hpp 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. //
  2. // ip/address_v4_range.hpp
  3. // ~~~~~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2015 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 ASIO_IP_ADDRESS_V4_RANGE_HPP
  11. #define ASIO_IP_ADDRESS_V4_RANGE_HPP
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  15. #include "asio/detail/config.hpp"
  16. #include "asio/ip/address_v4_iterator.hpp"
  17. #include "asio/detail/push_options.hpp"
  18. namespace asio {
  19. namespace ip {
  20. template <typename> class basic_address_range;
  21. /// Represents a range of IPv4 addresses.
  22. /**
  23. * @par Thread Safety
  24. * @e Distinct @e objects: Safe.@n
  25. * @e Shared @e objects: Unsafe.
  26. */
  27. template <> class basic_address_range<address_v4>
  28. {
  29. public:
  30. /// The type of an iterator that points into the range.
  31. typedef basic_address_iterator<address_v4> iterator;
  32. /// Construct an empty range.
  33. basic_address_range() ASIO_NOEXCEPT
  34. : begin_(address_v4()),
  35. end_(address_v4())
  36. {
  37. }
  38. /// Construct an range that represents the given range of addresses.
  39. explicit basic_address_range(const iterator& first,
  40. const iterator& last) ASIO_NOEXCEPT
  41. : begin_(first),
  42. end_(last)
  43. {
  44. }
  45. /// Copy constructor.
  46. basic_address_range(const basic_address_range& other) ASIO_NOEXCEPT
  47. : begin_(other.begin_),
  48. end_(other.end_)
  49. {
  50. }
  51. #if defined(ASIO_HAS_MOVE)
  52. /// Move constructor.
  53. basic_address_range(basic_address_range&& other) ASIO_NOEXCEPT
  54. : begin_(ASIO_MOVE_CAST(iterator)(other.begin_)),
  55. end_(ASIO_MOVE_CAST(iterator)(other.end_))
  56. {
  57. }
  58. #endif // defined(ASIO_HAS_MOVE)
  59. /// Assignment operator.
  60. basic_address_range& operator=(
  61. const basic_address_range& other) ASIO_NOEXCEPT
  62. {
  63. begin_ = other.begin_;
  64. end_ = other.end_;
  65. return *this;
  66. }
  67. #if defined(ASIO_HAS_MOVE)
  68. /// Move assignment operator.
  69. basic_address_range& operator=(
  70. basic_address_range&& other) ASIO_NOEXCEPT
  71. {
  72. begin_ = ASIO_MOVE_CAST(iterator)(other.begin_);
  73. end_ = ASIO_MOVE_CAST(iterator)(other.end_);
  74. return *this;
  75. }
  76. #endif // defined(ASIO_HAS_MOVE)
  77. /// Obtain an iterator that points to the start of the range.
  78. iterator begin() const ASIO_NOEXCEPT
  79. {
  80. return begin_;
  81. }
  82. /// Obtain an iterator that points to the end of the range.
  83. iterator end() const ASIO_NOEXCEPT
  84. {
  85. return end_;
  86. }
  87. /// Determine whether the range is empty.
  88. bool empty() const ASIO_NOEXCEPT
  89. {
  90. return size() == 0;
  91. }
  92. /// Return the size of the range.
  93. std::size_t size() const ASIO_NOEXCEPT
  94. {
  95. return end_->to_uint() - begin_->to_uint();
  96. }
  97. /// Find an address in the range.
  98. iterator find(const address_v4& addr) const ASIO_NOEXCEPT
  99. {
  100. return addr >= *begin_ && addr < *end_ ? iterator(addr) : end_;
  101. }
  102. private:
  103. iterator begin_;
  104. iterator end_;
  105. };
  106. /// Represents a range of IPv4 addresses.
  107. typedef basic_address_range<address_v4> address_v4_range;
  108. } // namespace ip
  109. } // namespace asio
  110. #include "asio/detail/pop_options.hpp"
  111. #endif // ASIO_IP_ADDRESS_V4_RANGE_HPP