2 * @file BufferedStreamBuffer.h
4 * @author Martin Corino <mcorino@remedy.nl>
7 #ifndef ACE_IOS_BUFFERED_STREAM_BUFFER_H
8 #define ACE_IOS_BUFFERED_STREAM_BUFFER_H
10 #include /**/ "ace/pre.h"
12 #include /**/ "ace/config-all.h"
14 #if !defined (ACE_LACKS_PRAGMA_ONCE)
16 #endif /* ACE_LACKS_PRAGMA_ONCE */
18 #include "ace/INet/StreamInterceptor.h"
24 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
31 * @class ACE_IOS_BasicBufferedStreamBuffer
33 * @brief Encapsulates unidirectional streambuffer attached
34 * to an input OR output stream.
36 * Implements a base class for a C++ standard unidirectional
37 * streambuffer using any data source/destination that can be
38 * driven by overloading the <write_to_stream> or <read_from_stream>
41 template <class ACE_CHAR_T
, class TR
= std::char_traits
<ACE_CHAR_T
> >
42 class BasicBufferedStreamBuffer
43 : public std::basic_streambuf
<ACE_CHAR_T
, TR
>
46 typedef std::basic_streambuf
<ACE_CHAR_T
, TR
> base_type
;
47 typedef std::basic_ios
<ACE_CHAR_T
, TR
> ios_type
;
48 typedef ACE_CHAR_T char_type
;
49 typedef TR char_traits
;
50 typedef typename
base_type::int_type int_type
;
51 typedef typename
base_type::pos_type pos_type
;
52 typedef typename
base_type::off_type off_type
;
53 typedef typename
ios_type::seekdir seekdir
;
54 typedef typename
ios_type::openmode openmode
;
55 typedef StreamInterceptorBase
<char_type
, char_traits
> interceptor_type
;
57 BasicBufferedStreamBuffer (std::streamsize bufsz
,
58 typename
std::basic_ios
<ACE_CHAR_T
, TR
>::openmode mode
);
60 virtual ~BasicBufferedStreamBuffer ();
62 virtual int_type
overflow (int_type c
);
63 virtual int_type
underflow ();
66 void set_interceptor (interceptor_type
& interceptor
);
69 void set_mode (typename
std::basic_ios
<ACE_CHAR_T
, TR
>::openmode mode
);
71 typename
std::basic_ios
<ACE_CHAR_T
, TR
>::openmode
get_mode () const;
73 virtual int read_from_stream (char_type
* buffer
, std::streamsize length
);
75 virtual int write_to_stream (const char_type
* buffer
, std::streamsize length
);
77 void reset_buffers ();
82 std::streamsize bufsize_
;
83 std::unique_ptr
<char_type
[]> buffer_
;
84 typename
std::basic_ios
<ACE_CHAR_T
, TR
>::openmode mode_
;
85 interceptor_type
* interceptor_
;
87 BasicBufferedStreamBuffer(const BasicBufferedStreamBuffer
&);
88 BasicBufferedStreamBuffer
& operator = (const BasicBufferedStreamBuffer
&);
91 /// char specialization
92 typedef BasicBufferedStreamBuffer
<char, std::char_traits
<char> > BufferedStreamBuffer
;
96 ACE_END_VERSIONED_NAMESPACE_DECL
98 #include "ace/INet/BufferedStreamBuffer.cpp"
100 #include /**/ "ace/post.h"
101 #endif /* ACE_IOS_BUFFERED_STREAM_BUFFER_H */