annotate DEPENDENCIES/generic/include/boost/asio/detail/posix_fd_set_adapter.hpp @ 46:d572322e2efe

Fix to .cat file check (was susceptible to DOS line-endings) and subrepo update
author Chris Cannam
date Thu, 07 Aug 2014 14:39:38 +0100
parents 2665513ce2d3
children c530137014c0
rev   line source
Chris@16 1 //
Chris@16 2 // detail/posix_fd_set_adapter.hpp
Chris@16 3 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Chris@16 4 //
Chris@16 5 // Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
Chris@16 6 //
Chris@16 7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
Chris@16 8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 9 //
Chris@16 10
Chris@16 11 #ifndef BOOST_ASIO_DETAIL_POSIX_FD_SET_ADAPTER_HPP
Chris@16 12 #define BOOST_ASIO_DETAIL_POSIX_FD_SET_ADAPTER_HPP
Chris@16 13
Chris@16 14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
Chris@16 15 # pragma once
Chris@16 16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
Chris@16 17
Chris@16 18 #include <boost/asio/detail/config.hpp>
Chris@16 19
Chris@16 20 #if !defined(BOOST_ASIO_WINDOWS) \
Chris@16 21 && !defined(__CYGWIN__) \
Chris@16 22 && !defined(BOOST_ASIO_WINDOWS_RUNTIME)
Chris@16 23
Chris@16 24 #include <cstring>
Chris@16 25 #include <boost/asio/detail/noncopyable.hpp>
Chris@16 26 #include <boost/asio/detail/socket_types.hpp>
Chris@16 27
Chris@16 28 #include <boost/asio/detail/push_options.hpp>
Chris@16 29
Chris@16 30 namespace boost {
Chris@16 31 namespace asio {
Chris@16 32 namespace detail {
Chris@16 33
Chris@16 34 // Adapts the FD_SET type to meet the Descriptor_Set concept's requirements.
Chris@16 35 class posix_fd_set_adapter : noncopyable
Chris@16 36 {
Chris@16 37 public:
Chris@16 38 posix_fd_set_adapter()
Chris@16 39 : max_descriptor_(invalid_socket)
Chris@16 40 {
Chris@16 41 using namespace std; // Needed for memset on Solaris.
Chris@16 42 FD_ZERO(&fd_set_);
Chris@16 43 }
Chris@16 44
Chris@16 45 void reset()
Chris@16 46 {
Chris@16 47 using namespace std; // Needed for memset on Solaris.
Chris@16 48 FD_ZERO(&fd_set_);
Chris@16 49 }
Chris@16 50
Chris@16 51 bool set(socket_type descriptor)
Chris@16 52 {
Chris@16 53 if (descriptor < (socket_type)FD_SETSIZE)
Chris@16 54 {
Chris@16 55 if (max_descriptor_ == invalid_socket || descriptor > max_descriptor_)
Chris@16 56 max_descriptor_ = descriptor;
Chris@16 57 FD_SET(descriptor, &fd_set_);
Chris@16 58 return true;
Chris@16 59 }
Chris@16 60 return false;
Chris@16 61 }
Chris@16 62
Chris@16 63 bool is_set(socket_type descriptor) const
Chris@16 64 {
Chris@16 65 return FD_ISSET(descriptor, &fd_set_) != 0;
Chris@16 66 }
Chris@16 67
Chris@16 68 operator fd_set*()
Chris@16 69 {
Chris@16 70 return &fd_set_;
Chris@16 71 }
Chris@16 72
Chris@16 73 socket_type max_descriptor() const
Chris@16 74 {
Chris@16 75 return max_descriptor_;
Chris@16 76 }
Chris@16 77
Chris@16 78 private:
Chris@16 79 mutable fd_set fd_set_;
Chris@16 80 socket_type max_descriptor_;
Chris@16 81 };
Chris@16 82
Chris@16 83 } // namespace detail
Chris@16 84 } // namespace asio
Chris@16 85 } // namespace boost
Chris@16 86
Chris@16 87 #include <boost/asio/detail/pop_options.hpp>
Chris@16 88
Chris@16 89 #endif // !defined(BOOST_ASIO_WINDOWS)
Chris@16 90 // && !defined(__CYGWIN__)
Chris@16 91 // && !defined(BOOST_ASIO_WINDOWS_RUNTIME)
Chris@16 92
Chris@16 93 #endif // BOOST_ASIO_DETAIL_POSIX_FD_SET_ADAPTER_HPP