2 * @file BidirStreamBuffer.h
4 * @author Martin Corino <mcorino@remedy.nl>
7 #ifndef ACE_IOS_BIDIR_STREAM_BUFFER_H
8 #define ACE_IOS_BIDIR_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 */
19 #include "ace/INet/StreamInterceptor.h"
24 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
31 * @class ACE_IOS_BasicBidirStreamBuffer
33 * @brief Encapsulates bidirectional streambuffer attached
34 * to a StreamHandler implementation.
36 * Implements a C++ standard bidirectional streambuffer using
37 * a streamed connection handler as data source/destination.
38 * Used as a base for implementing C++ standard streams capable
39 * of performing C++ standard formatted input and output on
40 * any streamed connection that can be represented by a stream
43 template <class ACE_CHAR_T
, class STREAM_HANDLER
, class TR
= std::char_traits
<ACE_CHAR_T
> >
44 class BasicBidirStreamBuffer
45 : public std::basic_streambuf
<ACE_CHAR_T
, TR
>
49 typedef std::basic_streambuf
<ACE_CHAR_T
, TR
> base_type
;
50 typedef std::basic_ios
<ACE_CHAR_T
, TR
> ios_type
;
51 typedef ACE_CHAR_T char_type
;
52 typedef TR char_traits
;
53 typedef typename
base_type::int_type int_type
;
54 typedef typename
base_type::pos_type pos_type
;
55 typedef typename
base_type::off_type off_type
;
56 typedef typename
ios_type::openmode openmode
;
57 typedef StreamInterceptorBase
<char_type
, char_traits
> interceptor_type
;
60 BasicBidirStreamBuffer (STREAM_HANDLER
* sh
, std::streamsize bufsz
, openmode mode
);
63 virtual ~BasicBidirStreamBuffer ();
65 virtual int_type
overflow (int_type c
);
66 virtual int_type
underflow ();
69 const STREAM_HANDLER
& stream () const;
73 void set_interceptor (interceptor_type
& interceptor
);
76 void set_mode (openmode mode
);
78 openmode
get_mode () const;
83 virtual int read_from_stream (char_type
* buffer
, std::streamsize length
);
85 virtual int write_to_stream (const char_type
* buffer
, std::streamsize length
);
89 std::streamsize bufsize_
;
90 std::unique_ptr
<char_type
[]> read_buffer_
;
91 std::unique_ptr
<char_type
[]> write_buffer_
;
93 STREAM_HANDLER
*stream_
;
94 interceptor_type
* interceptor_
;
96 BasicBidirStreamBuffer(const BasicBidirStreamBuffer
&);
97 BasicBidirStreamBuffer
& operator = (const BasicBidirStreamBuffer
&);
101 * @class ACE_IOS_BidirStreamBuffer
103 * @brief Encapsulates bidirectional character streambuffer attached
104 * to a StreamHandler implementation.
107 template <class STREAM_HANDLER
>
108 class BidirStreamBuffer
109 : public BasicBidirStreamBuffer
<char, STREAM_HANDLER
>
112 typedef BasicBidirStreamBuffer
< char, STREAM_HANDLER
> super
;
113 typedef typename
super::openmode openmode
;
115 BidirStreamBuffer (STREAM_HANDLER
* sh
, std::streamsize bufsz
, openmode mode
);
116 virtual ~BidirStreamBuffer ();
119 BidirStreamBuffer(const BidirStreamBuffer
&);
120 BidirStreamBuffer
& operator = (const BidirStreamBuffer
&);
125 ACE_END_VERSIONED_NAMESPACE_DECL
127 #include "ace/INet/BidirStreamBuffer.cpp"
129 #include /**/ "ace/post.h"
130 #endif /* ACE_IOS_BIDIR_STREAM_BUFFER_H */