write_op.hpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. //
  2. // ssl/detail/write_op.hpp
  3. // ~~~~~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2015 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. #ifndef ASIO_SSL_DETAIL_WRITE_OP_HPP
  11. #define ASIO_SSL_DETAIL_WRITE_OP_HPP
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  15. #include "asio/detail/config.hpp"
  16. #if !defined(ASIO_ENABLE_OLD_SSL)
  17. # include "asio/detail/buffer_sequence_adapter.hpp"
  18. # include "asio/ssl/detail/engine.hpp"
  19. #endif // !defined(ASIO_ENABLE_OLD_SSL)
  20. #include "asio/detail/push_options.hpp"
  21. namespace asio {
  22. namespace ssl {
  23. namespace detail {
  24. #if !defined(ASIO_ENABLE_OLD_SSL)
  25. template <typename ConstBufferSequence>
  26. class write_op
  27. {
  28. public:
  29. write_op(const ConstBufferSequence& buffers)
  30. : buffers_(buffers)
  31. {
  32. }
  33. engine::want operator()(engine& eng,
  34. asio::error_code& ec,
  35. std::size_t& bytes_transferred) const
  36. {
  37. asio::const_buffer buffer =
  38. asio::detail::buffer_sequence_adapter<asio::const_buffer,
  39. ConstBufferSequence>::first(buffers_);
  40. return eng.write(buffer, ec, bytes_transferred);
  41. }
  42. template <typename Handler>
  43. void call_handler(Handler& handler,
  44. const asio::error_code& ec,
  45. const std::size_t& bytes_transferred) const
  46. {
  47. handler(ec, bytes_transferred);
  48. }
  49. private:
  50. ConstBufferSequence buffers_;
  51. };
  52. #endif // !defined(ASIO_ENABLE_OLD_SSL)
  53. } // namespace detail
  54. } // namespace ssl
  55. } // namespace asio
  56. #include "asio/detail/pop_options.hpp"
  57. #endif // ASIO_SSL_DETAIL_WRITE_OP_HPP