Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef ACE_IOS_BIDIR_STREAM_BUFFER_H
00010 #define ACE_IOS_BIDIR_STREAM_BUFFER_H
00011
00012 #include "ace/pre.h"
00013
00014 #include "ace/config-all.h"
00015
00016 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00017 # pragma once
00018 #endif
00019
00020 #include "ace/Auto_Ptr.h"
00021 #include "ace/INet/StreamInterceptor.h"
00022 #include <streambuf>
00023 #include <iosfwd>
00024 #include <ios>
00025
00026 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00027
00028 namespace ACE
00029 {
00030 namespace IOS
00031 {
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 template <class ACE_CHAR_T, class STREAM_HANDLER, class TR = std::char_traits<ACE_CHAR_T> >
00046 class BasicBidirStreamBuffer
00047 : public std::basic_streambuf<ACE_CHAR_T, TR>
00048 {
00049 public:
00050
00051 typedef std::basic_streambuf<ACE_CHAR_T, TR> base_type;
00052 typedef std::basic_ios<ACE_CHAR_T, TR> ios_type;
00053 typedef ACE_CHAR_T char_type;
00054 typedef TR char_traits;
00055 typedef typename base_type::int_type int_type;
00056 typedef typename base_type::pos_type pos_type;
00057 typedef typename base_type::off_type off_type;
00058 typedef typename ios_type::openmode openmode;
00059 typedef StreamInterceptorBase<char_type, char_traits> interceptor_type;
00060
00061
00062 BasicBidirStreamBuffer (STREAM_HANDLER* sh, std::streamsize bufsz, openmode mode);
00063
00064
00065 virtual ~BasicBidirStreamBuffer ();
00066
00067 virtual int_type overflow (int_type c);
00068 virtual int_type underflow ();
00069 virtual int sync ();
00070
00071 const STREAM_HANDLER& stream () const;
00072
00073 void close_stream ();
00074
00075 void set_interceptor (interceptor_type& interceptor);
00076
00077 protected:
00078 void set_mode (openmode mode);
00079
00080 openmode get_mode () const;
00081
00082 void reset_buffers();
00083
00084 private:
00085 virtual int read_from_stream (char_type* buffer, std::streamsize length);
00086
00087 virtual int write_to_stream (const char_type* buffer, std::streamsize length);
00088
00089 int flush_buffer ();
00090
00091 std::streamsize bufsize_;
00092 ACE_Auto_Ptr<char_type> read_buffer_;
00093 ACE_Auto_Ptr<char_type> write_buffer_;
00094 openmode mode_;
00095 STREAM_HANDLER *stream_;
00096 interceptor_type* interceptor_;
00097
00098 BasicBidirStreamBuffer(const BasicBidirStreamBuffer&);
00099 BasicBidirStreamBuffer& operator = (const BasicBidirStreamBuffer&);
00100 };
00101
00102
00103
00104
00105
00106
00107
00108
00109 template <class STREAM_HANDLER>
00110 class BidirStreamBuffer
00111 : public BasicBidirStreamBuffer<char, STREAM_HANDLER>
00112 {
00113 public:
00114 typedef BasicBidirStreamBuffer< char, STREAM_HANDLER> super;
00115 typedef typename super::openmode openmode;
00116
00117 BidirStreamBuffer (STREAM_HANDLER* sh, std::streamsize bufsz, openmode mode);
00118 virtual ~BidirStreamBuffer ();
00119
00120 private:
00121 BidirStreamBuffer(const BidirStreamBuffer&);
00122 BidirStreamBuffer& operator = (const BidirStreamBuffer&);
00123 };
00124
00125 }
00126 }
00127
00128 ACE_END_VERSIONED_NAMESPACE_DECL
00129
00130 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
00131 #include "ace/INet/BidirStreamBuffer.cpp"
00132 #endif
00133
00134 #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
00135 #pragma implementation ("BidirStreamBuffer.cpp")
00136 #endif
00137
00138 #include "ace/post.h"
00139 #endif