changeset 541:218545c3c560

Sockets: rename AddressIterator -> Iterator
author David Demelier <markand@malikania.fr>
date Mon, 13 Jun 2016 14:07:31 +0200
parents fd2ba28ac54b
children 3b62482f929e
files modules/net/net.hpp
diffstat 1 files changed, 17 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/modules/net/net.hpp	Wed Jun 08 22:12:58 2016 +0200
+++ b/modules/net/net.hpp	Mon Jun 13 14:07:31 2016 +0200
@@ -3565,7 +3565,7 @@
  *
  * ````cpp
  * net::SocketTcpIp sc;
- * net::AddressIterator end, it = net::resolve("hostname.test", "80");
+ * net::Iterator end, it = net::resolve("hostname.test", "80");
  *
  * while (!connected_condition && it != end)
  *   sc.connect(it->address(), it->length());
@@ -3573,7 +3573,7 @@
  *
  * When an iterator equals to a default constructed iterator, it is considered not dereferenceable.
  */
-class AddressIterator : public std::iterator<std::forward_iterator_tag, Generic> {
+class Iterator : public std::iterator<std::forward_iterator_tag, Generic> {
 private:
 	std::vector<Generic> m_addresses;
 	std::size_t m_index{0};
@@ -3584,7 +3584,7 @@
 	 *
 	 * The default constructed iterator is not dereferenceable.
 	 */
-	inline AddressIterator() noexcept = default;
+	inline Iterator() noexcept = default;
 
 	/**
 	 * Construct an address iterator with a set of addresses.
@@ -3593,7 +3593,7 @@
 	 * \param addresses the addresses
 	 * \param index the first index
 	 */
-	inline AddressIterator(std::vector<Generic> addresses, std::size_t index = 0) noexcept
+	inline Iterator(std::vector<Generic> addresses, std::size_t index = 0) noexcept
 		: m_addresses(std::move(addresses))
 		, m_index(index)
 	{
@@ -3657,7 +3657,7 @@
 	 *
 	 * \return this
 	 */
-	inline AddressIterator &operator++(int) noexcept
+	inline Iterator &operator++(int) noexcept
 	{
 		if (m_index + 1 >= m_addresses.size()) {
 			m_addresses.clear();
@@ -3673,9 +3673,9 @@
 	 *
 	 * \return copy of this
 	 */
-	inline AddressIterator operator++() noexcept
-	{
-		AddressIterator save = *this;
+	inline Iterator operator++() noexcept
+	{
+		Iterator save = *this;
 
 		if (m_index + 1 >= m_addresses.size()) {
 			m_addresses.clear();
@@ -3686,8 +3686,8 @@
 		return save;
 	}
 
-	friend bool operator==(const AddressIterator &, const AddressIterator &) noexcept;
-	friend bool operator!=(const AddressIterator &, const AddressIterator &) noexcept;
+	friend bool operator==(const Iterator &, const Iterator &) noexcept;
+	friend bool operator!=(const Iterator &, const Iterator &) noexcept;
 };
 
 /**
@@ -3697,7 +3697,7 @@
  * \param i2 the second iterator
  * \return true if they equal
  */
-inline bool operator==(const AddressIterator &i1, const AddressIterator &i2) noexcept
+inline bool operator==(const Iterator &i1, const Iterator &i2) noexcept
 {
 	return i1.m_addresses == i2.m_addresses && i1.m_index == i2.m_index;
 }
@@ -3709,7 +3709,7 @@
  * \param i2 the second iterator
  * \return false if they equal
  */
-inline bool operator!=(const AddressIterator &i1, const AddressIterator &i2) noexcept
+inline bool operator!=(const Iterator &i1, const Iterator &i2) noexcept
 {
 	return !(i1 == i2);
 }
@@ -4964,7 +4964,7 @@
  * \return the address iterator
  * \throw net::Error on failures
  */
-inline address::AddressIterator resolve(const std::string &host, const std::string &service, int domain = AF_UNSPEC, int type = 0)
+inline address::Iterator resolve(const std::string &host, const std::string &service, int domain = AF_UNSPEC, int type = 0)
 {
 #if !defined(NET_NO_AUTO_INIT)
 		net::init();
@@ -4986,7 +4986,7 @@
 	for (p = res; p != nullptr; p = p->ai_next)
 		addresses.push_back(address::Generic(p->ai_addr, p->ai_addrlen));
 
-	return address::AddressIterator(addresses, 0);
+	return address::Iterator(addresses, 0);
 }
 
 /**
@@ -5001,7 +5001,7 @@
  * \throw net::Error on failures
  */
 template <typename Address, typename Protocol>
-address::AddressIterator resolve(const Socket<Address, Protocol> &sc, const std::string &host, const std::string &service)
+address::Iterator resolve(const Socket<Address, Protocol> &sc, const std::string &host, const std::string &service)
 {
 	return resolve(host, service, Address().domain(), sc.protocol().type());
 }
@@ -5021,8 +5021,8 @@
  */
 inline address::Generic resolveOne(const std::string &host, const std::string &service, int domain, int type)
 {
-	address::AddressIterator end;
-	address::AddressIterator it = resolve(host, service, domain, type);
+	address::Iterator end;
+	address::Iterator it = resolve(host, service, domain, type);
 
 	if (it == end)
 		throw Error(Error::Other, "resolveOne", "no address available");