summaryrefslogtreecommitdiffstats
path: root/lib/asio/ip/basic_resolver_iterator.hpp
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2018-08-06 10:35:22 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2018-08-06 10:35:22 +0200
commite95946831f8ef53d29590735a2df661385edb008 (patch)
treee179b6beed4a5a0dd108f078a529ae9f8107ed8e /lib/asio/ip/basic_resolver_iterator.hpp
parent8bc01ff60629d9096f4b57cfb574ace672a6ef0e (diff)
downloaddabmod-e95946831f8ef53d29590735a2df661385edb008.tar.gz
dabmod-e95946831f8ef53d29590735a2df661385edb008.tar.bz2
dabmod-e95946831f8ef53d29590735a2df661385edb008.zip
Replace boost by the standalone asio library
Diffstat (limited to 'lib/asio/ip/basic_resolver_iterator.hpp')
-rw-r--r--lib/asio/ip/basic_resolver_iterator.hpp192
1 files changed, 192 insertions, 0 deletions
diff --git a/lib/asio/ip/basic_resolver_iterator.hpp b/lib/asio/ip/basic_resolver_iterator.hpp
new file mode 100644
index 0000000..ec5412c
--- /dev/null
+++ b/lib/asio/ip/basic_resolver_iterator.hpp
@@ -0,0 +1,192 @@
+//
+// ip/basic_resolver_iterator.hpp
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+
+#ifndef ASIO_IP_BASIC_RESOLVER_ITERATOR_HPP
+#define ASIO_IP_BASIC_RESOLVER_ITERATOR_HPP
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+# pragma once
+#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
+
+#include "asio/detail/config.hpp"
+#include <cstddef>
+#include <cstring>
+#include <iterator>
+#include <string>
+#include <vector>
+#include "asio/detail/memory.hpp"
+#include "asio/detail/socket_ops.hpp"
+#include "asio/detail/socket_types.hpp"
+#include "asio/ip/basic_resolver_entry.hpp"
+
+#if defined(ASIO_WINDOWS_RUNTIME)
+# include "asio/detail/winrt_utils.hpp"
+#endif // defined(ASIO_WINDOWS_RUNTIME)
+
+#include "asio/detail/push_options.hpp"
+
+namespace asio {
+namespace ip {
+
+/// An iterator over the entries produced by a resolver.
+/**
+ * The asio::ip::basic_resolver_iterator class template is used to define
+ * iterators over the results returned by a resolver.
+ *
+ * The iterator's value_type, obtained when the iterator is dereferenced, is:
+ * @code const basic_resolver_entry<InternetProtocol> @endcode
+ *
+ * @par Thread Safety
+ * @e Distinct @e objects: Safe.@n
+ * @e Shared @e objects: Unsafe.
+ */
+template <typename InternetProtocol>
+class basic_resolver_iterator
+{
+public:
+ /// The type used for the distance between two iterators.
+ typedef std::ptrdiff_t difference_type;
+
+ /// The type of the value pointed to by the iterator.
+ typedef basic_resolver_entry<InternetProtocol> value_type;
+
+ /// The type of the result of applying operator->() to the iterator.
+ typedef const basic_resolver_entry<InternetProtocol>* pointer;
+
+ /// The type of the result of applying operator*() to the iterator.
+ typedef const basic_resolver_entry<InternetProtocol>& reference;
+
+ /// The iterator category.
+ typedef std::forward_iterator_tag iterator_category;
+
+ /// Default constructor creates an end iterator.
+ basic_resolver_iterator()
+ : index_(0)
+ {
+ }
+
+ /// Copy constructor.
+ basic_resolver_iterator(const basic_resolver_iterator& other)
+ : values_(other.values_),
+ index_(other.index_)
+ {
+ }
+
+#if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
+ /// Move constructor.
+ basic_resolver_iterator(basic_resolver_iterator&& other)
+ : values_(ASIO_MOVE_CAST(values_ptr_type)(other.values_)),
+ index_(other.index_)
+ {
+ other.index_ = 0;
+ }
+#endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
+
+ /// Assignment operator.
+ basic_resolver_iterator& operator=(const basic_resolver_iterator& other)
+ {
+ values_ = other.values_;
+ index_ = other.index_;
+ return *this;
+ }
+
+#if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
+ /// Move-assignment operator.
+ basic_resolver_iterator& operator=(basic_resolver_iterator&& other)
+ {
+ if (this != &other)
+ {
+ values_ = ASIO_MOVE_CAST(values_ptr_type)(other.values_);
+ index_ = other.index_;
+ other.index_ = 0;
+ }
+
+ return *this;
+ }
+#endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
+
+ /// Dereference an iterator.
+ const basic_resolver_entry<InternetProtocol>& operator*() const
+ {
+ return dereference();
+ }
+
+ /// Dereference an iterator.
+ const basic_resolver_entry<InternetProtocol>* operator->() const
+ {
+ return &dereference();
+ }
+
+ /// Increment operator (prefix).
+ basic_resolver_iterator& operator++()
+ {
+ increment();
+ return *this;
+ }
+
+ /// Increment operator (postfix).
+ basic_resolver_iterator operator++(int)
+ {
+ basic_resolver_iterator tmp(*this);
+ ++*this;
+ return tmp;
+ }
+
+ /// Test two iterators for equality.
+ friend bool operator==(const basic_resolver_iterator& a,
+ const basic_resolver_iterator& b)
+ {
+ return a.equal(b);
+ }
+
+ /// Test two iterators for inequality.
+ friend bool operator!=(const basic_resolver_iterator& a,
+ const basic_resolver_iterator& b)
+ {
+ return !a.equal(b);
+ }
+
+protected:
+ void increment()
+ {
+ if (++index_ == values_->size())
+ {
+ // Reset state to match a default constructed end iterator.
+ values_.reset();
+ index_ = 0;
+ }
+ }
+
+ bool equal(const basic_resolver_iterator& other) const
+ {
+ if (!values_ && !other.values_)
+ return true;
+ if (values_ != other.values_)
+ return false;
+ return index_ == other.index_;
+ }
+
+ const basic_resolver_entry<InternetProtocol>& dereference() const
+ {
+ return (*values_)[index_];
+ }
+
+ typedef std::vector<basic_resolver_entry<InternetProtocol> > values_type;
+ typedef asio::detail::shared_ptr<values_type> values_ptr_type;
+ values_ptr_type values_;
+ std::size_t index_;
+};
+
+} // namespace ip
+} // namespace asio
+
+#include "asio/detail/pop_options.hpp"
+
+#endif // ASIO_IP_BASIC_RESOLVER_ITERATOR_HPP