Added boost header

This commit is contained in:
Christophe Riccio
2012-01-08 01:26:07 +00:00
parent 9c3faaca40
commit c7d752cdf8
8946 changed files with 1732316 additions and 0 deletions

View File

@@ -0,0 +1,281 @@
//
// windows/basic_handle.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_ASIO_WINDOWS_BASIC_HANDLE_HPP
#define BOOST_ASIO_WINDOWS_BASIC_HANDLE_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
#if defined(BOOST_ASIO_HAS_WINDOWS_RANDOM_ACCESS_HANDLE) \
|| defined(BOOST_ASIO_HAS_WINDOWS_STREAM_HANDLE) \
|| defined(GENERATING_DOCUMENTATION)
#include <boost/asio/basic_io_object.hpp>
#include <boost/asio/detail/throw_error.hpp>
#include <boost/asio/error.hpp>
#include <boost/asio/detail/push_options.hpp>
namespace boost {
namespace asio {
namespace windows {
/// Provides Windows handle functionality.
/**
* The windows::basic_handle class template provides the ability to wrap a
* Windows handle.
*
* @par Thread Safety
* @e Distinct @e objects: Safe.@n
* @e Shared @e objects: Unsafe.
*/
template <typename HandleService>
class basic_handle
: public basic_io_object<HandleService>
{
public:
/// (Deprecated: Use native_handle_type.) The native representation of a
/// handle.
typedef typename HandleService::native_handle_type native_type;
/// The native representation of a handle.
typedef typename HandleService::native_handle_type native_handle_type;
/// A basic_handle is always the lowest layer.
typedef basic_handle<HandleService> lowest_layer_type;
/// Construct a basic_handle without opening it.
/**
* This constructor creates a handle without opening it.
*
* @param io_service The io_service object that the handle will use to
* dispatch handlers for any asynchronous operations performed on the handle.
*/
explicit basic_handle(boost::asio::io_service& io_service)
: basic_io_object<HandleService>(io_service)
{
}
/// Construct a basic_handle on an existing native handle.
/**
* This constructor creates a handle object to hold an existing native handle.
*
* @param io_service The io_service object that the handle will use to
* dispatch handlers for any asynchronous operations performed on the handle.
*
* @param handle A native handle.
*
* @throws boost::system::system_error Thrown on failure.
*/
basic_handle(boost::asio::io_service& io_service,
const native_handle_type& handle)
: basic_io_object<HandleService>(io_service)
{
boost::system::error_code ec;
this->get_service().assign(this->get_implementation(), handle, ec);
boost::asio::detail::throw_error(ec, "assign");
}
#if defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
/// Move-construct a basic_handle from another.
/**
* This constructor moves a handle from one object to another.
*
* @param other The other basic_handle object from which the move will occur.
*
* @note Following the move, the moved-from object is in the same state as if
* constructed using the @c basic_handle(io_service&) constructor.
*/
basic_handle(basic_handle&& other)
: basic_io_object<HandleService>(
BOOST_ASIO_MOVE_CAST(basic_handle)(other))
{
}
/// Move-assign a basic_handle from another.
/**
* This assignment operator moves a handle from one object to another.
*
* @param other The other basic_handle object from which the move will occur.
*
* @note Following the move, the moved-from object is in the same state as if
* constructed using the @c basic_handle(io_service&) constructor.
*/
basic_handle& operator=(basic_handle&& other)
{
basic_io_object<HandleService>::operator=(
BOOST_ASIO_MOVE_CAST(basic_handle)(other));
return *this;
}
#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
/// Get a reference to the lowest layer.
/**
* This function returns a reference to the lowest layer in a stack of
* layers. Since a basic_handle cannot contain any further layers, it simply
* returns a reference to itself.
*
* @return A reference to the lowest layer in the stack of layers. Ownership
* is not transferred to the caller.
*/
lowest_layer_type& lowest_layer()
{
return *this;
}
/// Get a const reference to the lowest layer.
/**
* This function returns a const reference to the lowest layer in a stack of
* layers. Since a basic_handle cannot contain any further layers, it simply
* returns a reference to itself.
*
* @return A const reference to the lowest layer in the stack of layers.
* Ownership is not transferred to the caller.
*/
const lowest_layer_type& lowest_layer() const
{
return *this;
}
/// Assign an existing native handle to the handle.
/*
* This function opens the handle to hold an existing native handle.
*
* @param handle A native handle.
*
* @throws boost::system::system_error Thrown on failure.
*/
void assign(const native_handle_type& handle)
{
boost::system::error_code ec;
this->get_service().assign(this->get_implementation(), handle, ec);
boost::asio::detail::throw_error(ec, "assign");
}
/// Assign an existing native handle to the handle.
/*
* This function opens the handle to hold an existing native handle.
*
* @param handle A native handle.
*
* @param ec Set to indicate what error occurred, if any.
*/
boost::system::error_code assign(const native_handle_type& handle,
boost::system::error_code& ec)
{
return this->get_service().assign(this->get_implementation(), handle, ec);
}
/// Determine whether the handle is open.
bool is_open() const
{
return this->get_service().is_open(this->get_implementation());
}
/// Close the handle.
/**
* This function is used to close the handle. Any asynchronous read or write
* operations will be cancelled immediately, and will complete with the
* boost::asio::error::operation_aborted error.
*
* @throws boost::system::system_error Thrown on failure.
*/
void close()
{
boost::system::error_code ec;
this->get_service().close(this->get_implementation(), ec);
boost::asio::detail::throw_error(ec, "close");
}
/// Close the handle.
/**
* This function is used to close the handle. Any asynchronous read or write
* operations will be cancelled immediately, and will complete with the
* boost::asio::error::operation_aborted error.
*
* @param ec Set to indicate what error occurred, if any.
*/
boost::system::error_code close(boost::system::error_code& ec)
{
return this->get_service().close(this->get_implementation(), ec);
}
/// (Deprecated: Use native_handle().) Get the native handle representation.
/**
* This function may be used to obtain the underlying representation of the
* handle. This is intended to allow access to native handle functionality
* that is not otherwise provided.
*/
native_type native()
{
return this->get_service().native_handle(this->get_implementation());
}
/// Get the native handle representation.
/**
* This function may be used to obtain the underlying representation of the
* handle. This is intended to allow access to native handle functionality
* that is not otherwise provided.
*/
native_handle_type native_handle()
{
return this->get_service().native_handle(this->get_implementation());
}
/// Cancel all asynchronous operations associated with the handle.
/**
* This function causes all outstanding asynchronous read or write operations
* to finish immediately, and the handlers for cancelled operations will be
* passed the boost::asio::error::operation_aborted error.
*
* @throws boost::system::system_error Thrown on failure.
*/
void cancel()
{
boost::system::error_code ec;
this->get_service().cancel(this->get_implementation(), ec);
boost::asio::detail::throw_error(ec, "cancel");
}
/// Cancel all asynchronous operations associated with the handle.
/**
* This function causes all outstanding asynchronous read or write operations
* to finish immediately, and the handlers for cancelled operations will be
* passed the boost::asio::error::operation_aborted error.
*
* @param ec Set to indicate what error occurred, if any.
*/
boost::system::error_code cancel(boost::system::error_code& ec)
{
return this->get_service().cancel(this->get_implementation(), ec);
}
protected:
/// Protected destructor to prevent deletion through this type.
~basic_handle()
{
}
};
} // namespace windows
} // namespace asio
} // namespace boost
#include <boost/asio/detail/pop_options.hpp>
#endif // defined(BOOST_ASIO_HAS_WINDOWS_RANDOM_ACCESS_HANDLE)
// || defined(BOOST_ASIO_HAS_WINDOWS_STREAM_HANDLE)
// || defined(GENERATING_DOCUMENTATION)
#endif // BOOST_ASIO_WINDOWS_BASIC_HANDLE_HPP

View File

@@ -0,0 +1,374 @@
//
// windows/basic_random_access_handle.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_ASIO_WINDOWS_BASIC_RANDOM_ACCESS_HANDLE_HPP
#define BOOST_ASIO_WINDOWS_BASIC_RANDOM_ACCESS_HANDLE_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
#if defined(BOOST_ASIO_HAS_WINDOWS_RANDOM_ACCESS_HANDLE) \
|| defined(GENERATING_DOCUMENTATION)
#include <cstddef>
#include <boost/asio/detail/handler_type_requirements.hpp>
#include <boost/asio/detail/throw_error.hpp>
#include <boost/asio/error.hpp>
#include <boost/asio/windows/basic_handle.hpp>
#include <boost/asio/windows/random_access_handle_service.hpp>
#include <boost/asio/detail/push_options.hpp>
namespace boost {
namespace asio {
namespace windows {
/// Provides random-access handle functionality.
/**
* The windows::basic_random_access_handle class template provides asynchronous
* and blocking random-access handle functionality.
*
* @par Thread Safety
* @e Distinct @e objects: Safe.@n
* @e Shared @e objects: Unsafe.
*/
template <typename RandomAccessHandleService = random_access_handle_service>
class basic_random_access_handle
: public basic_handle<RandomAccessHandleService>
{
public:
/// (Deprecated: Use native_handle_type.) The native representation of a
/// handle.
typedef typename RandomAccessHandleService::native_handle_type native_type;
/// The native representation of a handle.
typedef typename RandomAccessHandleService::native_handle_type
native_handle_type;
/// Construct a basic_random_access_handle without opening it.
/**
* This constructor creates a random-access handle without opening it. The
* handle needs to be opened before data can be written to or or read from it.
*
* @param io_service The io_service object that the random-access handle will
* use to dispatch handlers for any asynchronous operations performed on the
* handle.
*/
explicit basic_random_access_handle(boost::asio::io_service& io_service)
: basic_handle<RandomAccessHandleService>(io_service)
{
}
/// Construct a basic_random_access_handle on an existing native handle.
/**
* This constructor creates a random-access handle object to hold an existing
* native handle.
*
* @param io_service The io_service object that the random-access handle will
* use to dispatch handlers for any asynchronous operations performed on the
* handle.
*
* @param handle The new underlying handle implementation.
*
* @throws boost::system::system_error Thrown on failure.
*/
basic_random_access_handle(boost::asio::io_service& io_service,
const native_handle_type& handle)
: basic_handle<RandomAccessHandleService>(io_service, handle)
{
}
#if defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
/// Move-construct a basic_random_access_handle from another.
/**
* This constructor moves a random-access handle from one object to another.
*
* @param other The other basic_random_access_handle object from which the
* move will occur.
*
* @note Following the move, the moved-from object is in the same state as if
* constructed using the @c basic_random_access_handle(io_service&)
* constructor.
*/
basic_random_access_handle(basic_random_access_handle&& other)
: basic_handle<RandomAccessHandleService>(
BOOST_ASIO_MOVE_CAST(basic_random_access_handle)(other))
{
}
/// Move-assign a basic_random_access_handle from another.
/**
* This assignment operator moves a random-access handle from one object to
* another.
*
* @param other The other basic_random_access_handle object from which the
* move will occur.
*
* @note Following the move, the moved-from object is in the same state as if
* constructed using the @c basic_random_access_handle(io_service&)
* constructor.
*/
basic_random_access_handle& operator=(basic_random_access_handle&& other)
{
basic_handle<RandomAccessHandleService>::operator=(
BOOST_ASIO_MOVE_CAST(basic_random_access_handle)(other));
return *this;
}
#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
/// Write some data to the handle at the specified offset.
/**
* This function is used to write data to the random-access handle. The
* function call will block until one or more bytes of the data has been
* written successfully, or until an error occurs.
*
* @param offset The offset at which the data will be written.
*
* @param buffers One or more data buffers to be written to the handle.
*
* @returns The number of bytes written.
*
* @throws boost::system::system_error Thrown on failure. An error code of
* boost::asio::error::eof indicates that the connection was closed by the
* peer.
*
* @note The write_some_at operation may not write all of the data. Consider
* using the @ref write_at function if you need to ensure that all data is
* written before the blocking operation completes.
*
* @par Example
* To write a single data buffer use the @ref buffer function as follows:
* @code
* handle.write_some_at(42, boost::asio::buffer(data, size));
* @endcode
* See the @ref buffer documentation for information on writing multiple
* buffers in one go, and how to use it with arrays, boost::array or
* std::vector.
*/
template <typename ConstBufferSequence>
std::size_t write_some_at(boost::uint64_t offset,
const ConstBufferSequence& buffers)
{
boost::system::error_code ec;
std::size_t s = this->get_service().write_some_at(
this->get_implementation(), offset, buffers, ec);
boost::asio::detail::throw_error(ec, "write_some_at");
return s;
}
/// Write some data to the handle at the specified offset.
/**
* This function is used to write data to the random-access handle. The
* function call will block until one or more bytes of the data has been
* written successfully, or until an error occurs.
*
* @param offset The offset at which the data will be written.
*
* @param buffers One or more data buffers to be written to the handle.
*
* @param ec Set to indicate what error occurred, if any.
*
* @returns The number of bytes written. Returns 0 if an error occurred.
*
* @note The write_some operation may not transmit all of the data to the
* peer. Consider using the @ref write_at function if you need to ensure that
* all data is written before the blocking operation completes.
*/
template <typename ConstBufferSequence>
std::size_t write_some_at(boost::uint64_t offset,
const ConstBufferSequence& buffers, boost::system::error_code& ec)
{
return this->get_service().write_some_at(
this->get_implementation(), offset, buffers, ec);
}
/// Start an asynchronous write at the specified offset.
/**
* This function is used to asynchronously write data to the random-access
* handle. The function call always returns immediately.
*
* @param offset The offset at which the data will be written.
*
* @param buffers One or more data buffers to be written to the handle.
* Although the buffers object may be copied as necessary, ownership of the
* underlying memory blocks is retained by the caller, which must guarantee
* that they remain valid until the handler is called.
*
* @param handler The handler to be called when the write operation completes.
* Copies will be made of the handler as required. The function signature of
* the handler must be:
* @code void handler(
* const boost::system::error_code& error, // Result of operation.
* std::size_t bytes_transferred // Number of bytes written.
* ); @endcode
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* boost::asio::io_service::post().
*
* @note The write operation may not transmit all of the data to the peer.
* Consider using the @ref async_write_at function if you need to ensure that
* all data is written before the asynchronous operation completes.
*
* @par Example
* To write a single data buffer use the @ref buffer function as follows:
* @code
* handle.async_write_some_at(42, boost::asio::buffer(data, size), handler);
* @endcode
* See the @ref buffer documentation for information on writing multiple
* buffers in one go, and how to use it with arrays, boost::array or
* std::vector.
*/
template <typename ConstBufferSequence, typename WriteHandler>
void async_write_some_at(boost::uint64_t offset,
const ConstBufferSequence& buffers,
BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
{
// If you get an error on the following line it means that your handler does
// not meet the documented type requirements for a WriteHandler.
BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
this->get_service().async_write_some_at(this->get_implementation(),
offset, buffers, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
}
/// Read some data from the handle at the specified offset.
/**
* This function is used to read data from the random-access handle. The
* function call will block until one or more bytes of data has been read
* successfully, or until an error occurs.
*
* @param offset The offset at which the data will be read.
*
* @param buffers One or more buffers into which the data will be read.
*
* @returns The number of bytes read.
*
* @throws boost::system::system_error Thrown on failure. An error code of
* boost::asio::error::eof indicates that the connection was closed by the
* peer.
*
* @note The read_some operation may not read all of the requested number of
* bytes. Consider using the @ref read_at function if you need to ensure that
* the requested amount of data is read before the blocking operation
* completes.
*
* @par Example
* To read into a single data buffer use the @ref buffer function as follows:
* @code
* handle.read_some_at(42, boost::asio::buffer(data, size));
* @endcode
* See the @ref buffer documentation for information on reading into multiple
* buffers in one go, and how to use it with arrays, boost::array or
* std::vector.
*/
template <typename MutableBufferSequence>
std::size_t read_some_at(boost::uint64_t offset,
const MutableBufferSequence& buffers)
{
boost::system::error_code ec;
std::size_t s = this->get_service().read_some_at(
this->get_implementation(), offset, buffers, ec);
boost::asio::detail::throw_error(ec, "read_some_at");
return s;
}
/// Read some data from the handle at the specified offset.
/**
* This function is used to read data from the random-access handle. The
* function call will block until one or more bytes of data has been read
* successfully, or until an error occurs.
*
* @param offset The offset at which the data will be read.
*
* @param buffers One or more buffers into which the data will be read.
*
* @param ec Set to indicate what error occurred, if any.
*
* @returns The number of bytes read. Returns 0 if an error occurred.
*
* @note The read_some operation may not read all of the requested number of
* bytes. Consider using the @ref read_at function if you need to ensure that
* the requested amount of data is read before the blocking operation
* completes.
*/
template <typename MutableBufferSequence>
std::size_t read_some_at(boost::uint64_t offset,
const MutableBufferSequence& buffers, boost::system::error_code& ec)
{
return this->get_service().read_some_at(
this->get_implementation(), offset, buffers, ec);
}
/// Start an asynchronous read at the specified offset.
/**
* This function is used to asynchronously read data from the random-access
* handle. The function call always returns immediately.
*
* @param offset The offset at which the data will be read.
*
* @param buffers One or more buffers into which the data will be read.
* Although the buffers object may be copied as necessary, ownership of the
* underlying memory blocks is retained by the caller, which must guarantee
* that they remain valid until the handler is called.
*
* @param handler The handler to be called when the read operation completes.
* Copies will be made of the handler as required. The function signature of
* the handler must be:
* @code void handler(
* const boost::system::error_code& error, // Result of operation.
* std::size_t bytes_transferred // Number of bytes read.
* ); @endcode
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* boost::asio::io_service::post().
*
* @note The read operation may not read all of the requested number of bytes.
* Consider using the @ref async_read_at function if you need to ensure that
* the requested amount of data is read before the asynchronous operation
* completes.
*
* @par Example
* To read into a single data buffer use the @ref buffer function as follows:
* @code
* handle.async_read_some_at(42, boost::asio::buffer(data, size), handler);
* @endcode
* See the @ref buffer documentation for information on reading into multiple
* buffers in one go, and how to use it with arrays, boost::array or
* std::vector.
*/
template <typename MutableBufferSequence, typename ReadHandler>
void async_read_some_at(boost::uint64_t offset,
const MutableBufferSequence& buffers,
BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
{
// If you get an error on the following line it means that your handler does
// not meet the documented type requirements for a ReadHandler.
BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
this->get_service().async_read_some_at(this->get_implementation(),
offset, buffers, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
}
};
} // namespace windows
} // namespace asio
} // namespace boost
#include <boost/asio/detail/pop_options.hpp>
#endif // defined(BOOST_ASIO_HAS_WINDOWS_RANDOM_ACCESS_HANDLE)
// || defined(GENERATING_DOCUMENTATION)
#endif // BOOST_ASIO_WINDOWS_BASIC_RANDOM_ACCESS_HANDLE_HPP

View File

@@ -0,0 +1,357 @@
//
// windows/basic_stream_handle.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_ASIO_WINDOWS_BASIC_STREAM_HANDLE_HPP
#define BOOST_ASIO_WINDOWS_BASIC_STREAM_HANDLE_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
#if defined(BOOST_ASIO_HAS_WINDOWS_STREAM_HANDLE) \
|| defined(GENERATING_DOCUMENTATION)
#include <cstddef>
#include <boost/asio/detail/handler_type_requirements.hpp>
#include <boost/asio/detail/throw_error.hpp>
#include <boost/asio/error.hpp>
#include <boost/asio/windows/basic_handle.hpp>
#include <boost/asio/windows/stream_handle_service.hpp>
#include <boost/asio/detail/push_options.hpp>
namespace boost {
namespace asio {
namespace windows {
/// Provides stream-oriented handle functionality.
/**
* The windows::basic_stream_handle class template provides asynchronous and
* blocking stream-oriented handle functionality.
*
* @par Thread Safety
* @e Distinct @e objects: Safe.@n
* @e Shared @e objects: Unsafe.
*
* @par Concepts:
* AsyncReadStream, AsyncWriteStream, Stream, SyncReadStream, SyncWriteStream.
*/
template <typename StreamHandleService = stream_handle_service>
class basic_stream_handle
: public basic_handle<StreamHandleService>
{
public:
/// (Deprecated: Use native_handle_type.) The native representation of a
/// handle.
typedef typename StreamHandleService::native_handle_type native_type;
/// The native representation of a handle.
typedef typename StreamHandleService::native_handle_type native_handle_type;
/// Construct a basic_stream_handle without opening it.
/**
* This constructor creates a stream handle without opening it. The handle
* needs to be opened and then connected or accepted before data can be sent
* or received on it.
*
* @param io_service The io_service object that the stream handle will use to
* dispatch handlers for any asynchronous operations performed on the handle.
*/
explicit basic_stream_handle(boost::asio::io_service& io_service)
: basic_handle<StreamHandleService>(io_service)
{
}
/// Construct a basic_stream_handle on an existing native handle.
/**
* This constructor creates a stream handle object to hold an existing native
* handle.
*
* @param io_service The io_service object that the stream handle will use to
* dispatch handlers for any asynchronous operations performed on the handle.
*
* @param handle The new underlying handle implementation.
*
* @throws boost::system::system_error Thrown on failure.
*/
basic_stream_handle(boost::asio::io_service& io_service,
const native_handle_type& handle)
: basic_handle<StreamHandleService>(io_service, handle)
{
}
#if defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
/// Move-construct a basic_stream_handle from another.
/**
* This constructor moves a stream handle from one object to another.
*
* @param other The other basic_stream_handle object from which the move
* will occur.
*
* @note Following the move, the moved-from object is in the same state as if
* constructed using the @c basic_stream_handle(io_service&) constructor.
*/
basic_stream_handle(basic_stream_handle&& other)
: basic_handle<StreamHandleService>(
BOOST_ASIO_MOVE_CAST(basic_stream_handle)(other))
{
}
/// Move-assign a basic_stream_handle from another.
/**
* This assignment operator moves a stream handle from one object to
* another.
*
* @param other The other basic_stream_handle object from which the move
* will occur.
*
* @note Following the move, the moved-from object is in the same state as if
* constructed using the @c basic_stream_handle(io_service&) constructor.
*/
basic_stream_handle& operator=(basic_stream_handle&& other)
{
basic_handle<StreamHandleService>::operator=(
BOOST_ASIO_MOVE_CAST(basic_stream_handle)(other));
return *this;
}
#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
/// Write some data to the handle.
/**
* This function is used to write data to the stream handle. The function call
* will block until one or more bytes of the data has been written
* successfully, or until an error occurs.
*
* @param buffers One or more data buffers to be written to the handle.
*
* @returns The number of bytes written.
*
* @throws boost::system::system_error Thrown on failure. An error code of
* boost::asio::error::eof indicates that the connection was closed by the
* peer.
*
* @note The write_some operation may not transmit all of the data to the
* peer. Consider using the @ref write function if you need to ensure that
* all data is written before the blocking operation completes.
*
* @par Example
* To write a single data buffer use the @ref buffer function as follows:
* @code
* handle.write_some(boost::asio::buffer(data, size));
* @endcode
* See the @ref buffer documentation for information on writing multiple
* buffers in one go, and how to use it with arrays, boost::array or
* std::vector.
*/
template <typename ConstBufferSequence>
std::size_t write_some(const ConstBufferSequence& buffers)
{
boost::system::error_code ec;
std::size_t s = this->get_service().write_some(
this->get_implementation(), buffers, ec);
boost::asio::detail::throw_error(ec, "write_some");
return s;
}
/// Write some data to the handle.
/**
* This function is used to write data to the stream handle. The function call
* will block until one or more bytes of the data has been written
* successfully, or until an error occurs.
*
* @param buffers One or more data buffers to be written to the handle.
*
* @param ec Set to indicate what error occurred, if any.
*
* @returns The number of bytes written. Returns 0 if an error occurred.
*
* @note The write_some operation may not transmit all of the data to the
* peer. Consider using the @ref write function if you need to ensure that
* all data is written before the blocking operation completes.
*/
template <typename ConstBufferSequence>
std::size_t write_some(const ConstBufferSequence& buffers,
boost::system::error_code& ec)
{
return this->get_service().write_some(
this->get_implementation(), buffers, ec);
}
/// Start an asynchronous write.
/**
* This function is used to asynchronously write data to the stream handle.
* The function call always returns immediately.
*
* @param buffers One or more data buffers to be written to the handle.
* Although the buffers object may be copied as necessary, ownership of the
* underlying memory blocks is retained by the caller, which must guarantee
* that they remain valid until the handler is called.
*
* @param handler The handler to be called when the write operation completes.
* Copies will be made of the handler as required. The function signature of
* the handler must be:
* @code void handler(
* const boost::system::error_code& error, // Result of operation.
* std::size_t bytes_transferred // Number of bytes written.
* ); @endcode
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* boost::asio::io_service::post().
*
* @note The write operation may not transmit all of the data to the peer.
* Consider using the @ref async_write function if you need to ensure that all
* data is written before the asynchronous operation completes.
*
* @par Example
* To write a single data buffer use the @ref buffer function as follows:
* @code
* handle.async_write_some(boost::asio::buffer(data, size), handler);
* @endcode
* See the @ref buffer documentation for information on writing multiple
* buffers in one go, and how to use it with arrays, boost::array or
* std::vector.
*/
template <typename ConstBufferSequence, typename WriteHandler>
void async_write_some(const ConstBufferSequence& buffers,
BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
{
// If you get an error on the following line it means that your handler does
// not meet the documented type requirements for a WriteHandler.
BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
this->get_service().async_write_some(this->get_implementation(),
buffers, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
}
/// Read some data from the handle.
/**
* This function is used to read data from the stream handle. The function
* call will block until one or more bytes of data has been read successfully,
* or until an error occurs.
*
* @param buffers One or more buffers into which the data will be read.
*
* @returns The number of bytes read.
*
* @throws boost::system::system_error Thrown on failure. An error code of
* boost::asio::error::eof indicates that the connection was closed by the
* peer.
*
* @note The read_some operation may not read all of the requested number of
* bytes. Consider using the @ref read function if you need to ensure that
* the requested amount of data is read before the blocking operation
* completes.
*
* @par Example
* To read into a single data buffer use the @ref buffer function as follows:
* @code
* handle.read_some(boost::asio::buffer(data, size));
* @endcode
* See the @ref buffer documentation for information on reading into multiple
* buffers in one go, and how to use it with arrays, boost::array or
* std::vector.
*/
template <typename MutableBufferSequence>
std::size_t read_some(const MutableBufferSequence& buffers)
{
boost::system::error_code ec;
std::size_t s = this->get_service().read_some(
this->get_implementation(), buffers, ec);
boost::asio::detail::throw_error(ec, "read_some");
return s;
}
/// Read some data from the handle.
/**
* This function is used to read data from the stream handle. The function
* call will block until one or more bytes of data has been read successfully,
* or until an error occurs.
*
* @param buffers One or more buffers into which the data will be read.
*
* @param ec Set to indicate what error occurred, if any.
*
* @returns The number of bytes read. Returns 0 if an error occurred.
*
* @note The read_some operation may not read all of the requested number of
* bytes. Consider using the @ref read function if you need to ensure that
* the requested amount of data is read before the blocking operation
* completes.
*/
template <typename MutableBufferSequence>
std::size_t read_some(const MutableBufferSequence& buffers,
boost::system::error_code& ec)
{
return this->get_service().read_some(
this->get_implementation(), buffers, ec);
}
/// Start an asynchronous read.
/**
* This function is used to asynchronously read data from the stream handle.
* The function call always returns immediately.
*
* @param buffers One or more buffers into which the data will be read.
* Although the buffers object may be copied as necessary, ownership of the
* underlying memory blocks is retained by the caller, which must guarantee
* that they remain valid until the handler is called.
*
* @param handler The handler to be called when the read operation completes.
* Copies will be made of the handler as required. The function signature of
* the handler must be:
* @code void handler(
* const boost::system::error_code& error, // Result of operation.
* std::size_t bytes_transferred // Number of bytes read.
* ); @endcode
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* boost::asio::io_service::post().
*
* @note The read operation may not read all of the requested number of bytes.
* Consider using the @ref async_read function if you need to ensure that the
* requested amount of data is read before the asynchronous operation
* completes.
*
* @par Example
* To read into a single data buffer use the @ref buffer function as follows:
* @code
* handle.async_read_some(boost::asio::buffer(data, size), handler);
* @endcode
* See the @ref buffer documentation for information on reading into multiple
* buffers in one go, and how to use it with arrays, boost::array or
* std::vector.
*/
template <typename MutableBufferSequence, typename ReadHandler>
void async_read_some(const MutableBufferSequence& buffers,
BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
{
// If you get an error on the following line it means that your handler does
// not meet the documented type requirements for a ReadHandler.
BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
this->get_service().async_read_some(this->get_implementation(),
buffers, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
}
};
} // namespace windows
} // namespace asio
} // namespace boost
#include <boost/asio/detail/pop_options.hpp>
#endif // defined(BOOST_ASIO_HAS_WINDOWS_STREAM_HANDLE)
// || defined(GENERATING_DOCUMENTATION)
#endif // BOOST_ASIO_WINDOWS_BASIC_STREAM_HANDLE_HPP

View File

@@ -0,0 +1,118 @@
//
// windows/overlapped_ptr.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_ASIO_WINDOWS_OVERLAPPED_PTR_HPP
#define BOOST_ASIO_WINDOWS_OVERLAPPED_PTR_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
#if defined(BOOST_ASIO_HAS_WINDOWS_OVERLAPPED_PTR) \
|| defined(GENERATING_DOCUMENTATION)
#include <boost/asio/detail/noncopyable.hpp>
#include <boost/asio/detail/win_iocp_overlapped_ptr.hpp>
#include <boost/asio/io_service.hpp>
#include <boost/asio/detail/push_options.hpp>
namespace boost {
namespace asio {
namespace windows {
/// Wraps a handler to create an OVERLAPPED object for use with overlapped I/O.
/**
* A special-purpose smart pointer used to wrap an application handler so that
* it can be passed as the LPOVERLAPPED argument to overlapped I/O functions.
*
* @par Thread Safety
* @e Distinct @e objects: Safe.@n
* @e Shared @e objects: Unsafe.
*/
class overlapped_ptr
: private noncopyable
{
public:
/// Construct an empty overlapped_ptr.
overlapped_ptr()
: impl_()
{
}
/// Construct an overlapped_ptr to contain the specified handler.
template <typename Handler>
explicit overlapped_ptr(boost::asio::io_service& io_service,
BOOST_ASIO_MOVE_ARG(Handler) handler)
: impl_(io_service, BOOST_ASIO_MOVE_CAST(Handler)(handler))
{
}
/// Destructor automatically frees the OVERLAPPED object unless released.
~overlapped_ptr()
{
}
/// Reset to empty.
void reset()
{
impl_.reset();
}
/// Reset to contain the specified handler, freeing any current OVERLAPPED
/// object.
template <typename Handler>
void reset(boost::asio::io_service& io_service,
BOOST_ASIO_MOVE_ARG(Handler) handler)
{
impl_.reset(io_service, BOOST_ASIO_MOVE_CAST(Handler)(handler));
}
/// Get the contained OVERLAPPED object.
OVERLAPPED* get()
{
return impl_.get();
}
/// Get the contained OVERLAPPED object.
const OVERLAPPED* get() const
{
return impl_.get();
}
/// Release ownership of the OVERLAPPED object.
OVERLAPPED* release()
{
return impl_.release();
}
/// Post completion notification for overlapped operation. Releases ownership.
void complete(const boost::system::error_code& ec,
std::size_t bytes_transferred)
{
impl_.complete(ec, bytes_transferred);
}
private:
detail::win_iocp_overlapped_ptr impl_;
};
} // namespace windows
} // namespace asio
} // namespace boost
#include <boost/asio/detail/pop_options.hpp>
#endif // defined(BOOST_ASIO_HAS_WINDOWS_OVERLAPPED_PTR)
// || defined(GENERATING_DOCUMENTATION)
#endif // BOOST_ASIO_WINDOWS_OVERLAPPED_PTR_HPP

View File

@@ -0,0 +1,39 @@
//
// windows/random_access_handle.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_ASIO_WINDOWS_RANDOM_ACCESS_HANDLE_HPP
#define BOOST_ASIO_WINDOWS_RANDOM_ACCESS_HANDLE_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
#if defined(BOOST_ASIO_HAS_WINDOWS_RANDOM_ACCESS_HANDLE) \
|| defined(GENERATING_DOCUMENTATION)
#include <boost/asio/windows/basic_random_access_handle.hpp>
namespace boost {
namespace asio {
namespace windows {
/// Typedef for the typical usage of a random-access handle.
typedef basic_random_access_handle<> random_access_handle;
} // namespace windows
} // namespace asio
} // namespace boost
#endif // defined(BOOST_ASIO_HAS_WINDOWS_RANDOM_ACCESS_HANDLE)
// || defined(GENERATING_DOCUMENTATION)
#endif // BOOST_ASIO_WINDOWS_RANDOM_ACCESS_HANDLE_HPP

View File

@@ -0,0 +1,208 @@
//
// windows/random_access_handle_service.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_ASIO_WINDOWS_RANDOM_ACCESS_HANDLE_SERVICE_HPP
#define BOOST_ASIO_WINDOWS_RANDOM_ACCESS_HANDLE_SERVICE_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
#if defined(BOOST_ASIO_HAS_WINDOWS_RANDOM_ACCESS_HANDLE) \
|| defined(GENERATING_DOCUMENTATION)
#include <cstddef>
#include <boost/config.hpp>
#include <boost/cstdint.hpp>
#include <boost/asio/detail/win_iocp_handle_service.hpp>
#include <boost/asio/error.hpp>
#include <boost/asio/io_service.hpp>
#include <boost/asio/detail/push_options.hpp>
namespace boost {
namespace asio {
namespace windows {
/// Default service implementation for a random-access handle.
class random_access_handle_service
#if defined(GENERATING_DOCUMENTATION)
: public boost::asio::io_service::service
#else
: public boost::asio::detail::service_base<random_access_handle_service>
#endif
{
public:
#if defined(GENERATING_DOCUMENTATION)
/// The unique service identifier.
static boost::asio::io_service::id id;
#endif
private:
// The type of the platform-specific implementation.
typedef detail::win_iocp_handle_service service_impl_type;
public:
/// The type of a random-access handle implementation.
#if defined(GENERATING_DOCUMENTATION)
typedef implementation_defined implementation_type;
#else
typedef service_impl_type::implementation_type implementation_type;
#endif
/// (Deprecated: Use native_handle_type.) The native handle type.
#if defined(GENERATING_DOCUMENTATION)
typedef implementation_defined native_type;
#else
typedef service_impl_type::native_handle_type native_type;
#endif
/// The native handle type.
#if defined(GENERATING_DOCUMENTATION)
typedef implementation_defined native_handle_type;
#else
typedef service_impl_type::native_handle_type native_handle_type;
#endif
/// Construct a new random-access handle service for the specified io_service.
explicit random_access_handle_service(boost::asio::io_service& io_service)
: boost::asio::detail::service_base<
random_access_handle_service>(io_service),
service_impl_(io_service)
{
}
/// Construct a new random-access handle implementation.
void construct(implementation_type& impl)
{
service_impl_.construct(impl);
}
#if defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
/// Move-construct a new random-access handle implementation.
void move_construct(implementation_type& impl,
implementation_type& other_impl)
{
service_impl_.move_construct(impl, other_impl);
}
/// Move-assign from another random-access handle implementation.
void move_assign(implementation_type& impl,
random_access_handle_service& other_service,
implementation_type& other_impl)
{
service_impl_.move_assign(impl, other_service.service_impl_, other_impl);
}
#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
/// Destroy a random-access handle implementation.
void destroy(implementation_type& impl)
{
service_impl_.destroy(impl);
}
/// Assign an existing native handle to a random-access handle.
boost::system::error_code assign(implementation_type& impl,
const native_handle_type& handle, boost::system::error_code& ec)
{
return service_impl_.assign(impl, handle, ec);
}
/// Determine whether the handle is open.
bool is_open(const implementation_type& impl) const
{
return service_impl_.is_open(impl);
}
/// Close a random-access handle implementation.
boost::system::error_code close(implementation_type& impl,
boost::system::error_code& ec)
{
return service_impl_.close(impl, ec);
}
/// (Deprecated: Use native_handle().) Get the native handle implementation.
native_type native(implementation_type& impl)
{
return service_impl_.native_handle(impl);
}
/// Get the native handle implementation.
native_handle_type native_handle(implementation_type& impl)
{
return service_impl_.native_handle(impl);
}
/// Cancel all asynchronous operations associated with the handle.
boost::system::error_code cancel(implementation_type& impl,
boost::system::error_code& ec)
{
return service_impl_.cancel(impl, ec);
}
/// Write the given data at the specified offset.
template <typename ConstBufferSequence>
std::size_t write_some_at(implementation_type& impl, boost::uint64_t offset,
const ConstBufferSequence& buffers, boost::system::error_code& ec)
{
return service_impl_.write_some_at(impl, offset, buffers, ec);
}
/// Start an asynchronous write at the specified offset.
template <typename ConstBufferSequence, typename WriteHandler>
void async_write_some_at(implementation_type& impl,
boost::uint64_t offset, const ConstBufferSequence& buffers,
BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
{
service_impl_.async_write_some_at(impl, offset, buffers,
BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
}
/// Read some data from the specified offset.
template <typename MutableBufferSequence>
std::size_t read_some_at(implementation_type& impl, boost::uint64_t offset,
const MutableBufferSequence& buffers, boost::system::error_code& ec)
{
return service_impl_.read_some_at(impl, offset, buffers, ec);
}
/// Start an asynchronous read at the specified offset.
template <typename MutableBufferSequence, typename ReadHandler>
void async_read_some_at(implementation_type& impl,
boost::uint64_t offset, const MutableBufferSequence& buffers,
BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
{
service_impl_.async_read_some_at(impl, offset, buffers,
BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
}
private:
// Destroy all user-defined handler objects owned by the service.
void shutdown_service()
{
service_impl_.shutdown_service();
}
// The platform-specific implementation.
service_impl_type service_impl_;
};
} // namespace windows
} // namespace asio
} // namespace boost
#include <boost/asio/detail/pop_options.hpp>
#endif // defined(BOOST_ASIO_HAS_WINDOWS_RANDOM_ACCESS_HANDLE)
// || defined(GENERATING_DOCUMENTATION)
#endif // BOOST_ASIO_WINDOWS_RANDOM_ACCESS_HANDLE_SERVICE_HPP

View File

@@ -0,0 +1,39 @@
//
// windows/stream_handle.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_ASIO_WINDOWS_STREAM_HANDLE_HPP
#define BOOST_ASIO_WINDOWS_STREAM_HANDLE_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
#if defined(BOOST_ASIO_HAS_WINDOWS_STREAM_HANDLE) \
|| defined(GENERATING_DOCUMENTATION)
#include <boost/asio/windows/basic_stream_handle.hpp>
namespace boost {
namespace asio {
namespace windows {
/// Typedef for the typical usage of a stream-oriented handle.
typedef basic_stream_handle<> stream_handle;
} // namespace windows
} // namespace asio
} // namespace boost
#endif // defined(BOOST_ASIO_HAS_WINDOWS_STREAM_HANDLE)
// || defined(GENERATING_DOCUMENTATION)
#endif // BOOST_ASIO_WINDOWS_STREAM_HANDLE_HPP

View File

@@ -0,0 +1,205 @@
//
// windows/stream_handle_service.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_ASIO_WINDOWS_STREAM_HANDLE_SERVICE_HPP
#define BOOST_ASIO_WINDOWS_STREAM_HANDLE_SERVICE_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
#if defined(BOOST_ASIO_HAS_WINDOWS_STREAM_HANDLE) \
|| defined(GENERATING_DOCUMENTATION)
#include <cstddef>
#include <boost/asio/detail/win_iocp_handle_service.hpp>
#include <boost/asio/error.hpp>
#include <boost/asio/io_service.hpp>
#include <boost/asio/detail/push_options.hpp>
namespace boost {
namespace asio {
namespace windows {
/// Default service implementation for a stream handle.
class stream_handle_service
#if defined(GENERATING_DOCUMENTATION)
: public boost::asio::io_service::service
#else
: public boost::asio::detail::service_base<stream_handle_service>
#endif
{
public:
#if defined(GENERATING_DOCUMENTATION)
/// The unique service identifier.
static boost::asio::io_service::id id;
#endif
private:
// The type of the platform-specific implementation.
typedef detail::win_iocp_handle_service service_impl_type;
public:
/// The type of a stream handle implementation.
#if defined(GENERATING_DOCUMENTATION)
typedef implementation_defined implementation_type;
#else
typedef service_impl_type::implementation_type implementation_type;
#endif
/// (Deprecated: Use native_handle_type.) The native handle type.
#if defined(GENERATING_DOCUMENTATION)
typedef implementation_defined native_type;
#else
typedef service_impl_type::native_handle_type native_type;
#endif
/// The native handle type.
#if defined(GENERATING_DOCUMENTATION)
typedef implementation_defined native_handle_type;
#else
typedef service_impl_type::native_handle_type native_handle_type;
#endif
/// Construct a new stream handle service for the specified io_service.
explicit stream_handle_service(boost::asio::io_service& io_service)
: boost::asio::detail::service_base<stream_handle_service>(io_service),
service_impl_(io_service)
{
}
/// Construct a new stream handle implementation.
void construct(implementation_type& impl)
{
service_impl_.construct(impl);
}
#if defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
/// Move-construct a new stream handle implementation.
void move_construct(implementation_type& impl,
implementation_type& other_impl)
{
service_impl_.move_construct(impl, other_impl);
}
/// Move-assign from another stream handle implementation.
void move_assign(implementation_type& impl,
stream_handle_service& other_service,
implementation_type& other_impl)
{
service_impl_.move_assign(impl, other_service.service_impl_, other_impl);
}
#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
/// Destroy a stream handle implementation.
void destroy(implementation_type& impl)
{
service_impl_.destroy(impl);
}
/// Assign an existing native handle to a stream handle.
boost::system::error_code assign(implementation_type& impl,
const native_handle_type& handle, boost::system::error_code& ec)
{
return service_impl_.assign(impl, handle, ec);
}
/// Determine whether the handle is open.
bool is_open(const implementation_type& impl) const
{
return service_impl_.is_open(impl);
}
/// Close a stream handle implementation.
boost::system::error_code close(implementation_type& impl,
boost::system::error_code& ec)
{
return service_impl_.close(impl, ec);
}
/// (Deprecated: Use native_handle().) Get the native handle implementation.
native_type native(implementation_type& impl)
{
return service_impl_.native_handle(impl);
}
/// Get the native handle implementation.
native_handle_type native_handle(implementation_type& impl)
{
return service_impl_.native_handle(impl);
}
/// Cancel all asynchronous operations associated with the handle.
boost::system::error_code cancel(implementation_type& impl,
boost::system::error_code& ec)
{
return service_impl_.cancel(impl, ec);
}
/// Write the given data to the stream.
template <typename ConstBufferSequence>
std::size_t write_some(implementation_type& impl,
const ConstBufferSequence& buffers, boost::system::error_code& ec)
{
return service_impl_.write_some(impl, buffers, ec);
}
/// Start an asynchronous write.
template <typename ConstBufferSequence, typename WriteHandler>
void async_write_some(implementation_type& impl,
const ConstBufferSequence& buffers,
BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
{
service_impl_.async_write_some(impl, buffers,
BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
}
/// Read some data from the stream.
template <typename MutableBufferSequence>
std::size_t read_some(implementation_type& impl,
const MutableBufferSequence& buffers, boost::system::error_code& ec)
{
return service_impl_.read_some(impl, buffers, ec);
}
/// Start an asynchronous read.
template <typename MutableBufferSequence, typename ReadHandler>
void async_read_some(implementation_type& impl,
const MutableBufferSequence& buffers,
BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
{
service_impl_.async_read_some(impl, buffers,
BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
}
private:
// Destroy all user-defined handler objects owned by the service.
void shutdown_service()
{
service_impl_.shutdown_service();
}
// The platform-specific implementation.
service_impl_type service_impl_;
};
} // namespace windows
} // namespace asio
} // namespace boost
#include <boost/asio/detail/pop_options.hpp>
#endif // defined(BOOST_ASIO_HAS_WINDOWS_STREAM_HANDLE)
// || defined(GENERATING_DOCUMENTATION)
#endif // BOOST_ASIO_WINDOWS_STREAM_HANDLE_SERVICE_HPP