/** * @file BufferedStreamBuffer.h * * @author Martin Corino */ #ifndef ACE_IOS_BUFFERED_STREAM_BUFFER_H #define ACE_IOS_BUFFERED_STREAM_BUFFER_H #include /**/ "ace/pre.h" #include /**/ "ace/config-all.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ace/Auto_Ptr.h" #include "ace/INet/StreamInterceptor.h" #include #include #include ACE_BEGIN_VERSIONED_NAMESPACE_DECL namespace ACE { namespace IOS { /** * @class ACE_IOS_BasicBufferedStreamBuffer * * @brief Encapsulates unidirectional streambuffer attached * to an input OR output stream. * * Implements a base class for a C++ standard unidirectional * streambuffer using any data source/destination that can be * driven by overloading the or * methods. */ template > class BasicBufferedStreamBuffer : public std::basic_streambuf { public: typedef std::basic_streambuf base_type; typedef std::basic_ios ios_type; typedef ACE_CHAR_T char_type; typedef TR char_traits; typedef typename base_type::int_type int_type; typedef typename base_type::pos_type pos_type; typedef typename base_type::off_type off_type; typedef typename ios_type::seekdir seekdir; typedef typename ios_type::openmode openmode; typedef StreamInterceptorBase interceptor_type; BasicBufferedStreamBuffer (std::streamsize bufsz, typename std::basic_ios::openmode mode); virtual ~BasicBufferedStreamBuffer (); virtual int_type overflow (int_type c); virtual int_type underflow (); virtual int sync (); void set_interceptor (interceptor_type& interceptor); protected: void set_mode (typename std::basic_ios::openmode mode); typename std::basic_ios::openmode get_mode () const; virtual int read_from_stream (char_type* buffer, std::streamsize length); virtual int write_to_stream (const char_type* buffer, std::streamsize length); void reset_buffers (); private: int flush_buffer (); std::streamsize bufsize_; ACE_Auto_Array_Ptr buffer_; typename std::basic_ios::openmode mode_; interceptor_type* interceptor_; BasicBufferedStreamBuffer(const BasicBufferedStreamBuffer&); BasicBufferedStreamBuffer& operator = (const BasicBufferedStreamBuffer&); }; /// char specialization typedef BasicBufferedStreamBuffer > BufferedStreamBuffer; } } ACE_END_VERSIONED_NAMESPACE_DECL #include "ace/INet/BufferedStreamBuffer.cpp" #include /**/ "ace/post.h" #endif /* ACE_IOS_BUFFERED_STREAM_BUFFER_H */