1//
2// detail/io_control.hpp
3// ~~~~~~~~~~~~~~~~~~~~~
4//
5// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6//
7// Distributed under the Boost Software License, Version 1.0. (See accompanying
8// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9//
10
11#ifndef BOOST_ASIO_DETAIL_IO_CONTROL_HPP
12#define BOOST_ASIO_DETAIL_IO_CONTROL_HPP
13
14#if defined(_MSC_VER) && (_MSC_VER >= 1200)
15# pragma once
16#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17
18#include <boost/asio/detail/config.hpp>
19#include <cstddef>
20#include <boost/asio/detail/socket_types.hpp>
21
22#include <boost/asio/detail/push_options.hpp>
23
24namespace boost {
25namespace asio {
26namespace detail {
27namespace io_control {
28
29// I/O control command for getting number of bytes available.
30class bytes_readable
31{
32public:
33 // Default constructor.
34 bytes_readable()
35 : value_(0)
36 {
37 }
38
39 // Construct with a specific command value.
40 bytes_readable(std::size_t value)
41 : value_(static_cast<detail::ioctl_arg_type>(value))
42 {
43 }
44
45 // Get the name of the IO control command.
46 int name() const
47 {
48 return static_cast<int>(BOOST_ASIO_OS_DEF(FIONREAD));
49 }
50
51 // Set the value of the I/O control command.
52 void set(std::size_t value)
53 {
54 value_ = static_cast<detail::ioctl_arg_type>(value);
55 }
56
57 // Get the current value of the I/O control command.
58 std::size_t get() const
59 {
60 return static_cast<std::size_t>(value_);
61 }
62
63 // Get the address of the command data.
64 detail::ioctl_arg_type* data()
65 {
66 return &value_;
67 }
68
69 // Get the address of the command data.
70 const detail::ioctl_arg_type* data() const
71 {
72 return &value_;
73 }
74
75private:
76 detail::ioctl_arg_type value_;
77};
78
79} // namespace io_control
80} // namespace detail
81} // namespace asio
82} // namespace boost
83
84#include <boost/asio/detail/pop_options.hpp>
85
86#endif // BOOST_ASIO_DETAIL_IO_CONTROL_HPP
87

source code of boost/libs/asio/include/boost/asio/detail/io_control.hpp