Clementine
io_control.hpp
1 //
2 // detail/io_control.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2020 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 ASIO_DETAIL_IO_CONTROL_HPP
12 #define 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 "asio/detail/config.hpp"
19 #include <cstddef>
20 #include "asio/detail/socket_types.hpp"
21 
22 #include "asio/detail/push_options.hpp"
23 
24 namespace asio {
25 namespace detail {
26 namespace io_control {
27 
28 // I/O control command for getting number of bytes available.
30 {
31 public:
32  // Default constructor.
34  : value_(0)
35  {
36  }
37 
38  // Construct with a specific command value.
39  bytes_readable(std::size_t value)
40  : value_(static_cast<detail::ioctl_arg_type>(value))
41  {
42  }
43 
44  // Get the name of the IO control command.
45  int name() const
46  {
47  return static_cast<int>(ASIO_OS_DEF(FIONREAD));
48  }
49 
50  // Set the value of the I/O control command.
51  void set(std::size_t value)
52  {
53  value_ = static_cast<detail::ioctl_arg_type>(value);
54  }
55 
56  // Get the current value of the I/O control command.
57  std::size_t get() const
58  {
59  return static_cast<std::size_t>(value_);
60  }
61 
62  // Get the address of the command data.
63  detail::ioctl_arg_type* data()
64  {
65  return &value_;
66  }
67 
68  // Get the address of the command data.
69  const detail::ioctl_arg_type* data() const
70  {
71  return &value_;
72  }
73 
74 private:
75  detail::ioctl_arg_type value_;
76 };
77 
78 } // namespace io_control
79 } // namespace detail
80 } // namespace asio
81 
82 #include "asio/detail/pop_options.hpp"
83 
84 #endif // ASIO_DETAIL_IO_CONTROL_HPP
Definition: chrono.h:284
Definition: io_control.hpp:29
Definition: any_io_executor.hpp:28