Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:28:39

0001 //
0002 // detail/io_control.hpp
0003 // ~~~~~~~~~~~~~~~~~~~~~
0004 //
0005 // Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com)
0006 //
0007 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0008 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0009 //
0010 
0011 #ifndef BOOST_ASIO_DETAIL_IO_CONTROL_HPP
0012 #define BOOST_ASIO_DETAIL_IO_CONTROL_HPP
0013 
0014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0015 # pragma once
0016 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
0017 
0018 #include <boost/asio/detail/config.hpp>
0019 #include <cstddef>
0020 #include <boost/asio/detail/socket_types.hpp>
0021 
0022 #include <boost/asio/detail/push_options.hpp>
0023 
0024 namespace boost {
0025 namespace asio {
0026 namespace detail {
0027 namespace io_control {
0028 
0029 // I/O control command for getting number of bytes available.
0030 class bytes_readable
0031 {
0032 public:
0033   // Default constructor.
0034   bytes_readable()
0035     : value_(0)
0036   {
0037   }
0038 
0039   // Construct with a specific command value.
0040   bytes_readable(std::size_t value)
0041     : value_(static_cast<detail::ioctl_arg_type>(value))
0042   {
0043   }
0044 
0045   // Get the name of the IO control command.
0046   int name() const
0047   {
0048     return static_cast<int>(BOOST_ASIO_OS_DEF(FIONREAD));
0049   }
0050 
0051   // Set the value of the I/O control command.
0052   void set(std::size_t value)
0053   {
0054     value_ = static_cast<detail::ioctl_arg_type>(value);
0055   }
0056 
0057   // Get the current value of the I/O control command.
0058   std::size_t get() const
0059   {
0060     return static_cast<std::size_t>(value_);
0061   }
0062 
0063   // Get the address of the command data.
0064   detail::ioctl_arg_type* data()
0065   {
0066     return &value_;
0067   }
0068 
0069   // Get the address of the command data.
0070   const detail::ioctl_arg_type* data() const
0071   {
0072     return &value_;
0073   }
0074 
0075 private:
0076   detail::ioctl_arg_type value_;
0077 };
0078 
0079 } // namespace io_control
0080 } // namespace detail
0081 } // namespace asio
0082 } // namespace boost
0083 
0084 #include <boost/asio/detail/pop_options.hpp>
0085 
0086 #endif // BOOST_ASIO_DETAIL_IO_CONTROL_HPP