Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef ACE_IOS_BUFFERED_STREAM_BUFFER_H
00010 #define ACE_IOS_BUFFERED_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 template <class ACE_CHAR_T, class TR = std::char_traits<ACE_CHAR_T> >
00044 class BasicBufferedStreamBuffer
00045 : public std::basic_streambuf<ACE_CHAR_T, TR>
00046 {
00047 public:
00048 typedef std::basic_streambuf<ACE_CHAR_T, TR> base_type;
00049 typedef std::basic_ios<ACE_CHAR_T, TR> ios_type;
00050 typedef ACE_CHAR_T char_type;
00051 typedef TR char_traits;
00052 typedef typename base_type::int_type int_type;
00053 typedef typename base_type::pos_type pos_type;
00054 typedef typename base_type::off_type off_type;
00055 typedef typename ios_type::seekdir seekdir;
00056 typedef typename ios_type::openmode openmode;
00057 typedef StreamInterceptorBase<char_type, char_traits> interceptor_type;
00058
00059 BasicBufferedStreamBuffer (std::streamsize bufsz,
00060 typename std::basic_ios<ACE_CHAR_T, TR>::openmode mode);
00061
00062 virtual ~BasicBufferedStreamBuffer ();
00063
00064 virtual int_type overflow (int_type c);
00065 virtual int_type underflow ();
00066 virtual int sync ();
00067
00068 void set_interceptor (interceptor_type& interceptor);
00069
00070 protected:
00071 void set_mode (typename std::basic_ios<ACE_CHAR_T, TR>::openmode mode);
00072
00073 typename std::basic_ios<ACE_CHAR_T, TR>::openmode get_mode () const;
00074
00075 virtual int read_from_stream (char_type* buffer, std::streamsize length);
00076
00077 virtual int write_to_stream (const char_type* buffer, std::streamsize length);
00078
00079 void reset_buffers ();
00080
00081 private:
00082 int flush_buffer ();
00083
00084 std::streamsize bufsize_;
00085 ACE_Auto_Ptr<char_type> buffer_;
00086 typename std::basic_ios<ACE_CHAR_T, TR>::openmode mode_;
00087 interceptor_type* interceptor_;
00088
00089 BasicBufferedStreamBuffer(const BasicBufferedStreamBuffer&);
00090 BasicBufferedStreamBuffer& operator = (const BasicBufferedStreamBuffer&);
00091 };
00092
00093
00094 typedef BasicBufferedStreamBuffer<char, std::char_traits<char> > BufferedStreamBuffer;
00095 }
00096 }
00097
00098 ACE_END_VERSIONED_NAMESPACE_DECL
00099
00100 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
00101 #include "ace/INet/BufferedStreamBuffer.cpp"
00102 #endif
00103
00104 #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
00105 #pragma implementation ("BufferedStreamBuffer.cpp")
00106 #endif
00107
00108 #include "ace/post.h"
00109 #endif