Add type traits for determining whether a stream supports buffering.
This commit is contained in:
parent
0e338b7762
commit
c02689f35d
@ -9,8 +9,11 @@ nobase_include_HEADERS = \
|
||||
asio/basic_stream_socket.hpp \
|
||||
asio/basic_timer.hpp \
|
||||
asio/buffered_recv_stream.hpp \
|
||||
asio/buffered_recv_stream_fwd.hpp \
|
||||
asio/buffered_send_stream.hpp \
|
||||
asio/buffered_send_stream_fwd.hpp \
|
||||
asio/buffered_stream.hpp \
|
||||
asio/buffered_stream_fwd.hpp \
|
||||
asio/default_error_handler.hpp \
|
||||
asio/demuxer.hpp \
|
||||
asio/detail/bind_handler.hpp \
|
||||
@ -63,6 +66,8 @@ nobase_include_HEADERS = \
|
||||
asio/ipv4/address.hpp \
|
||||
asio/ipv4/tcp.hpp \
|
||||
asio/ipv4/udp.hpp \
|
||||
asio/is_recv_buffered.hpp \
|
||||
asio/is_send_buffered.hpp \
|
||||
asio/locking_dispatcher.hpp \
|
||||
asio/recv.hpp \
|
||||
asio/send.hpp \
|
||||
|
@ -34,6 +34,8 @@
|
||||
#include "asio/ipv4/address.hpp"
|
||||
#include "asio/ipv4/tcp.hpp"
|
||||
#include "asio/ipv4/udp.hpp"
|
||||
#include "asio/is_recv_buffered.hpp"
|
||||
#include "asio/is_send_buffered.hpp"
|
||||
#include "asio/locking_dispatcher.hpp"
|
||||
#include "asio/recv.hpp"
|
||||
#include "asio/send.hpp"
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include <boost/type_traits.hpp>
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
|
||||
#include "asio/fixed_buffer.hpp"
|
||||
#include "asio/buffered_recv_stream_fwd.hpp"
|
||||
#include "asio/detail/bind_handler.hpp"
|
||||
#include "asio/detail/buffer_resize_guard.hpp"
|
||||
|
||||
@ -31,7 +31,7 @@ namespace asio {
|
||||
|
||||
/// The buffered_recv_stream class template can be used to add buffering to the
|
||||
/// recv-related operations of a stream.
|
||||
template <typename Next_Layer, typename Buffer = fixed_buffer<8192> >
|
||||
template <typename Next_Layer, typename Buffer>
|
||||
class buffered_recv_stream
|
||||
: private boost::noncopyable
|
||||
{
|
||||
|
31
asio/include/asio/buffered_recv_stream_fwd.hpp
Normal file
31
asio/include/asio/buffered_recv_stream_fwd.hpp
Normal file
@ -0,0 +1,31 @@
|
||||
//
|
||||
// buffered_recv_stream_fwd.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003, 2004 Christopher M. Kohlhoff (chris@kohlhoff.com)
|
||||
//
|
||||
// Permission to use, copy, modify, distribute and sell this software and its
|
||||
// documentation for any purpose is hereby granted without fee, provided that
|
||||
// the above copyright notice appears in all copies and that both the copyright
|
||||
// notice and this permission notice appear in supporting documentation. This
|
||||
// software is provided "as is" without express or implied warranty, and with
|
||||
// no claim as to its suitability for any purpose.
|
||||
//
|
||||
|
||||
#ifndef ASIO_BUFFERED_RECV_STREAM_FWD_HPP
|
||||
#define ASIO_BUFFERED_RECV_STREAM_FWD_HPP
|
||||
|
||||
#include "asio/detail/push_options.hpp"
|
||||
|
||||
#include "asio/fixed_buffer.hpp"
|
||||
|
||||
namespace asio {
|
||||
|
||||
template <typename Next_Layer, typename Buffer = fixed_buffer<8192> >
|
||||
class buffered_recv_stream;
|
||||
|
||||
} // namespace asio
|
||||
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
|
||||
#endif // ASIO_BUFFERED_RECV_STREAM_FWD_HPP
|
@ -23,14 +23,14 @@
|
||||
#include <boost/type_traits.hpp>
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
|
||||
#include "asio/buffered_send_stream_fwd.hpp"
|
||||
#include "asio/send.hpp"
|
||||
#include "asio/fixed_buffer.hpp"
|
||||
|
||||
namespace asio {
|
||||
|
||||
/// The buffered_send_stream class template can be used to add buffering to the
|
||||
/// send-related operations of a stream.
|
||||
template <typename Next_Layer, typename Buffer = fixed_buffer<8192> >
|
||||
template <typename Next_Layer, typename Buffer>
|
||||
class buffered_send_stream
|
||||
: private boost::noncopyable
|
||||
{
|
||||
|
31
asio/include/asio/buffered_send_stream_fwd.hpp
Normal file
31
asio/include/asio/buffered_send_stream_fwd.hpp
Normal file
@ -0,0 +1,31 @@
|
||||
//
|
||||
// buffered_send_stream_fwd.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003, 2004 Christopher M. Kohlhoff (chris@kohlhoff.com)
|
||||
//
|
||||
// Permission to use, copy, modify, distribute and sell this software and its
|
||||
// documentation for any purpose is hereby granted without fee, provided that
|
||||
// the above copyright notice appears in all copies and that both the copyright
|
||||
// notice and this permission notice appear in supporting documentation. This
|
||||
// software is provided "as is" without express or implied warranty, and with
|
||||
// no claim as to its suitability for any purpose.
|
||||
//
|
||||
|
||||
#ifndef ASIO_BUFFERED_SEND_STREAM_FWD_HPP
|
||||
#define ASIO_BUFFERED_SEND_STREAM_FWD_HPP
|
||||
|
||||
#include "asio/detail/push_options.hpp"
|
||||
|
||||
#include "asio/fixed_buffer.hpp"
|
||||
|
||||
namespace asio {
|
||||
|
||||
template <typename Next_Layer, typename Buffer = fixed_buffer<8192> >
|
||||
class buffered_send_stream;
|
||||
|
||||
} // namespace asio
|
||||
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
|
||||
#endif // ASIO_BUFFERED_SEND_STREAM_FWD_HPP
|
@ -23,13 +23,13 @@
|
||||
|
||||
#include "asio/buffered_recv_stream.hpp"
|
||||
#include "asio/buffered_send_stream.hpp"
|
||||
#include "asio/fixed_buffer.hpp"
|
||||
#include "asio/buffered_stream_fwd.hpp"
|
||||
|
||||
namespace asio {
|
||||
|
||||
/// The buffered_stream class template can be used to add buffering to both the
|
||||
/// send- and recv- related operations of a stream.
|
||||
template <typename Next_Layer, typename Buffer = fixed_buffer<8192> >
|
||||
template <typename Next_Layer, typename Buffer>
|
||||
class buffered_stream
|
||||
: private boost::noncopyable
|
||||
{
|
||||
|
31
asio/include/asio/buffered_stream_fwd.hpp
Normal file
31
asio/include/asio/buffered_stream_fwd.hpp
Normal file
@ -0,0 +1,31 @@
|
||||
//
|
||||
// buffered_stream_fwd.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003, 2004 Christopher M. Kohlhoff (chris@kohlhoff.com)
|
||||
//
|
||||
// Permission to use, copy, modify, distribute and sell this software and its
|
||||
// documentation for any purpose is hereby granted without fee, provided that
|
||||
// the above copyright notice appears in all copies and that both the copyright
|
||||
// notice and this permission notice appear in supporting documentation. This
|
||||
// software is provided "as is" without express or implied warranty, and with
|
||||
// no claim as to its suitability for any purpose.
|
||||
//
|
||||
|
||||
#ifndef ASIO_BUFFERED_STREAM_FWD_HPP
|
||||
#define ASIO_BUFFERED_STREAM_FWD_HPP
|
||||
|
||||
#include "asio/detail/push_options.hpp"
|
||||
|
||||
#include "asio/fixed_buffer.hpp"
|
||||
|
||||
namespace asio {
|
||||
|
||||
template <typename Next_Layer, typename Buffer = fixed_buffer<8192> >
|
||||
class buffered_stream;
|
||||
|
||||
} // namespace asio
|
||||
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
|
||||
#endif // ASIO_BUFFERED_STREAM_FWD_HPP
|
57
asio/include/asio/is_recv_buffered.hpp
Normal file
57
asio/include/asio/is_recv_buffered.hpp
Normal file
@ -0,0 +1,57 @@
|
||||
//
|
||||
// is_recv_buffered.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003, 2004 Christopher M. Kohlhoff (chris@kohlhoff.com)
|
||||
//
|
||||
// Permission to use, copy, modify, distribute and sell this software and its
|
||||
// documentation for any purpose is hereby granted without fee, provided that
|
||||
// the above copyright notice appears in all copies and that both the copyright
|
||||
// notice and this permission notice appear in supporting documentation. This
|
||||
// software is provided "as is" without express or implied warranty, and with
|
||||
// no claim as to its suitability for any purpose.
|
||||
//
|
||||
|
||||
#ifndef ASIO_IS_RECV_BUFFERED_HPP
|
||||
#define ASIO_IS_RECV_BUFFERED_HPP
|
||||
|
||||
#include "asio/detail/push_options.hpp"
|
||||
|
||||
#include "asio/buffered_recv_stream_fwd.hpp"
|
||||
#include "asio/buffered_stream_fwd.hpp"
|
||||
|
||||
namespace asio {
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <typename Next_Layer, typename Buffer>
|
||||
char is_recv_buffered_helper(buffered_stream<Next_Layer, Buffer>* s);
|
||||
|
||||
template <typename Next_Layer, typename Buffer>
|
||||
char is_recv_buffered_helper(buffered_recv_stream<Next_Layer, Buffer>* s);
|
||||
|
||||
struct is_recv_buffered_big_type { char data[10]; };
|
||||
is_recv_buffered_big_type is_recv_buffered_helper(...);
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/// The is_recv_buffered class is a traits class that may be used to determine
|
||||
/// whether a stream type supports buffering of received data.
|
||||
template <typename Stream>
|
||||
class is_recv_buffered
|
||||
{
|
||||
public:
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
/// The value member is true only if the Stream type supports buffering of
|
||||
/// received data.
|
||||
static const bool value;
|
||||
#else
|
||||
enum { value = sizeof(detail::is_recv_buffered_helper((Stream*)0)) == 1 };
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace asio
|
||||
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
|
||||
#endif // ASIO_IS_RECV_BUFFERED_HPP
|
57
asio/include/asio/is_send_buffered.hpp
Normal file
57
asio/include/asio/is_send_buffered.hpp
Normal file
@ -0,0 +1,57 @@
|
||||
//
|
||||
// is_send_buffered.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003, 2004 Christopher M. Kohlhoff (chris@kohlhoff.com)
|
||||
//
|
||||
// Permission to use, copy, modify, distribute and sell this software and its
|
||||
// documentation for any purpose is hereby granted without fee, provided that
|
||||
// the above copyright notice appears in all copies and that both the copyright
|
||||
// notice and this permission notice appear in supporting documentation. This
|
||||
// software is provided "as is" without express or implied warranty, and with
|
||||
// no claim as to its suitability for any purpose.
|
||||
//
|
||||
|
||||
#ifndef ASIO_IS_SEND_BUFFERED_HPP
|
||||
#define ASIO_IS_SEND_BUFFERED_HPP
|
||||
|
||||
#include "asio/detail/push_options.hpp"
|
||||
|
||||
#include "asio/buffered_recv_stream_fwd.hpp"
|
||||
#include "asio/buffered_stream_fwd.hpp"
|
||||
|
||||
namespace asio {
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <typename Next_Layer, typename Buffer>
|
||||
char is_send_buffered_helper(buffered_stream<Next_Layer, Buffer>* s);
|
||||
|
||||
template <typename Next_Layer, typename Buffer>
|
||||
char is_send_buffered_helper(buffered_send_stream<Next_Layer, Buffer>* s);
|
||||
|
||||
struct is_send_buffered_big_type { char data[10]; };
|
||||
is_send_buffered_big_type is_send_buffered_helper(...);
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/// The is_send_buffered class is a traits class that may be used to determine
|
||||
/// whether a stream type supports buffering of sent data.
|
||||
template <typename Stream>
|
||||
class is_send_buffered
|
||||
{
|
||||
public:
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
/// The value member is true only if the Stream type supports buffering of
|
||||
/// sent data.
|
||||
static const bool value;
|
||||
#else
|
||||
enum { value = sizeof(detail::is_send_buffered_helper((Stream*)0)) == 1 };
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace asio
|
||||
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
|
||||
#endif // ASIO_IS_SEND_BUFFERED_HPP
|
@ -76,6 +76,11 @@ documentation</a> for more information on how to use <tt>boost::bind</tt>.
|
||||
\li asio::buffered_send_stream
|
||||
\li asio::buffered_stream
|
||||
|
||||
<H2>Type Traits</H2>
|
||||
|
||||
\li asio::is_recv_buffered
|
||||
\li asio::is_send_buffered
|
||||
|
||||
</TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
|
Loading…
Reference in New Issue
Block a user