Chris@16: // Chris@16: // detail/io_control.hpp Chris@16: // ~~~~~~~~~~~~~~~~~~~~~ Chris@16: // Chris@101: // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com) Chris@16: // Chris@16: // Distributed under the Boost Software License, Version 1.0. (See accompanying Chris@16: // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Chris@16: // Chris@16: Chris@16: #ifndef BOOST_ASIO_DETAIL_IO_CONTROL_HPP Chris@16: #define BOOST_ASIO_DETAIL_IO_CONTROL_HPP Chris@16: Chris@16: #if defined(_MSC_VER) && (_MSC_VER >= 1200) Chris@16: # pragma once Chris@16: #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: #include Chris@16: Chris@16: namespace boost { Chris@16: namespace asio { Chris@16: namespace detail { Chris@16: namespace io_control { Chris@16: Chris@16: // IO control command for non-blocking I/O. Chris@16: class non_blocking_io Chris@16: { Chris@16: public: Chris@16: // Default constructor. Chris@16: non_blocking_io() Chris@16: : value_(0) Chris@16: { Chris@16: } Chris@16: Chris@16: // Construct with a specific command value. Chris@16: non_blocking_io(bool value) Chris@16: : value_(value ? 1 : 0) Chris@16: { Chris@16: } Chris@16: Chris@16: // Get the name of the IO control command. Chris@16: int name() const Chris@16: { Chris@16: return static_cast(BOOST_ASIO_OS_DEF(FIONBIO)); Chris@16: } Chris@16: Chris@16: // Set the value of the I/O control command. Chris@16: void set(bool value) Chris@16: { Chris@16: value_ = value ? 1 : 0; Chris@16: } Chris@16: Chris@16: // Get the current value of the I/O control command. Chris@16: bool get() const Chris@16: { Chris@16: return value_ != 0; Chris@16: } Chris@16: Chris@16: // Get the address of the command data. Chris@16: detail::ioctl_arg_type* data() Chris@16: { Chris@16: return &value_; Chris@16: } Chris@16: Chris@16: // Get the address of the command data. Chris@16: const detail::ioctl_arg_type* data() const Chris@16: { Chris@16: return &value_; Chris@16: } Chris@16: Chris@16: private: Chris@16: detail::ioctl_arg_type value_; Chris@16: }; Chris@16: Chris@16: // I/O control command for getting number of bytes available. Chris@16: class bytes_readable Chris@16: { Chris@16: public: Chris@16: // Default constructor. Chris@16: bytes_readable() Chris@16: : value_(0) Chris@16: { Chris@16: } Chris@16: Chris@16: // Construct with a specific command value. Chris@16: bytes_readable(std::size_t value) Chris@16: : value_(static_cast(value)) Chris@16: { Chris@16: } Chris@16: Chris@16: // Get the name of the IO control command. Chris@16: int name() const Chris@16: { Chris@16: return static_cast(BOOST_ASIO_OS_DEF(FIONREAD)); Chris@16: } Chris@16: Chris@16: // Set the value of the I/O control command. Chris@16: void set(std::size_t value) Chris@16: { Chris@16: value_ = static_cast(value); Chris@16: } Chris@16: Chris@16: // Get the current value of the I/O control command. Chris@16: std::size_t get() const Chris@16: { Chris@16: return static_cast(value_); Chris@16: } Chris@16: Chris@16: // Get the address of the command data. Chris@16: detail::ioctl_arg_type* data() Chris@16: { Chris@16: return &value_; Chris@16: } Chris@16: Chris@16: // Get the address of the command data. Chris@16: const detail::ioctl_arg_type* data() const Chris@16: { Chris@16: return &value_; Chris@16: } Chris@16: Chris@16: private: Chris@16: detail::ioctl_arg_type value_; Chris@16: }; Chris@16: Chris@16: } // namespace io_control Chris@16: } // namespace detail Chris@16: } // namespace asio Chris@16: } // namespace boost Chris@16: Chris@16: #include Chris@16: Chris@16: #endif // BOOST_ASIO_DETAIL_IO_CONTROL_HPP