Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes

ACE::IOS::BasicBufferedStreamBuffer< ACE_CHAR_T, TR > Class Template Reference

#include <BufferedStreamBuffer.h>

Inheritance diagram for ACE::IOS::BasicBufferedStreamBuffer< ACE_CHAR_T, TR >:
Inheritance graph
[legend]
Collaboration diagram for ACE::IOS::BasicBufferedStreamBuffer< ACE_CHAR_T, TR >:
Collaboration graph
[legend]

List of all members.

Public Types

typedef std::basic_streambuf
< ACE_CHAR_T, TR > 
base_type
typedef std::basic_ios
< ACE_CHAR_T, TR > 
ios_type
typedef ACE_CHAR_T char_type
typedef TR char_traits
typedef base_type::int_type int_type
typedef base_type::pos_type pos_type
typedef base_type::off_type off_type
typedef ios_type::seekdir seekdir
typedef ios_type::openmode openmode
typedef StreamInterceptorBase
< char_type, char_traits
interceptor_type

Public Member Functions

 BasicBufferedStreamBuffer (std::streamsize bufsz, typename std::basic_ios< ACE_CHAR_T, TR >::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 Member Functions

void set_mode (typename std::basic_ios< ACE_CHAR_T, TR >::openmode mode)
std::basic_ios< ACE_CHAR_T, TR >
::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 Member Functions

int flush_buffer ()
 BasicBufferedStreamBuffer (const BasicBufferedStreamBuffer &)
BasicBufferedStreamBufferoperator= (const BasicBufferedStreamBuffer &)

Private Attributes

std::streamsize bufsize_
ACE_Auto_Ptr< char_typebuffer_
std::basic_ios< ACE_CHAR_T, TR >
::openmode 
mode_
interceptor_typeinterceptor_

Detailed Description

template<class ACE_CHAR_T, class TR = std::char_traits<ACE_CHAR_T>>
class ACE::IOS::BasicBufferedStreamBuffer< ACE_CHAR_T, TR >

Definition at line 44 of file BufferedStreamBuffer.h.


Member Typedef Documentation

template<class ACE_CHAR_T, class TR = std::char_traits<ACE_CHAR_T>>
typedef std::basic_streambuf<ACE_CHAR_T, TR> ACE::IOS::BasicBufferedStreamBuffer< ACE_CHAR_T, TR >::base_type

Definition at line 48 of file BufferedStreamBuffer.h.

template<class ACE_CHAR_T, class TR = std::char_traits<ACE_CHAR_T>>
typedef TR ACE::IOS::BasicBufferedStreamBuffer< ACE_CHAR_T, TR >::char_traits

Definition at line 51 of file BufferedStreamBuffer.h.

template<class ACE_CHAR_T, class TR = std::char_traits<ACE_CHAR_T>>
typedef ACE_CHAR_T ACE::IOS::BasicBufferedStreamBuffer< ACE_CHAR_T, TR >::char_type
template<class ACE_CHAR_T, class TR = std::char_traits<ACE_CHAR_T>>
typedef base_type::int_type ACE::IOS::BasicBufferedStreamBuffer< ACE_CHAR_T, TR >::int_type

Definition at line 52 of file BufferedStreamBuffer.h.

template<class ACE_CHAR_T, class TR = std::char_traits<ACE_CHAR_T>>
typedef StreamInterceptorBase<char_type, char_traits> ACE::IOS::BasicBufferedStreamBuffer< ACE_CHAR_T, TR >::interceptor_type

Definition at line 57 of file BufferedStreamBuffer.h.

template<class ACE_CHAR_T, class TR = std::char_traits<ACE_CHAR_T>>
typedef std::basic_ios<ACE_CHAR_T, TR> ACE::IOS::BasicBufferedStreamBuffer< ACE_CHAR_T, TR >::ios_type

Definition at line 49 of file BufferedStreamBuffer.h.

template<class ACE_CHAR_T, class TR = std::char_traits<ACE_CHAR_T>>
typedef base_type::off_type ACE::IOS::BasicBufferedStreamBuffer< ACE_CHAR_T, TR >::off_type
template<class ACE_CHAR_T, class TR = std::char_traits<ACE_CHAR_T>>
typedef ios_type::openmode ACE::IOS::BasicBufferedStreamBuffer< ACE_CHAR_T, TR >::openmode
template<class ACE_CHAR_T, class TR = std::char_traits<ACE_CHAR_T>>
typedef base_type::pos_type ACE::IOS::BasicBufferedStreamBuffer< ACE_CHAR_T, TR >::pos_type
template<class ACE_CHAR_T, class TR = std::char_traits<ACE_CHAR_T>>
typedef ios_type::seekdir ACE::IOS::BasicBufferedStreamBuffer< ACE_CHAR_T, TR >::seekdir

Constructor & Destructor Documentation

template<class ACE_CHAR_T, class TR>
ACE::IOS::BasicBufferedStreamBuffer< ACE_CHAR_T, TR >::BasicBufferedStreamBuffer ( std::streamsize  bufsz,
typename std::basic_ios< ACE_CHAR_T, TR >::openmode  mode 
)

Definition at line 18 of file BufferedStreamBuffer.cpp.

      : bufsize_ (bufsz),
        mode_ (mode),
        interceptor_ (0)
      {
        char_type* p = 0;
        ACE_NEW_NORETURN (p, char_type [bufsz]);
        this->buffer_.reset (p);

        this->setg (this->buffer_.get () + 4,
                    this->buffer_.get () + 4,
                    this->buffer_.get () + 4);
        this->setp (this->buffer_.get (),
                    this->buffer_.get () + (this->bufsize_ - 1));
      }

template<class ACE_CHAR_T , class TR >
ACE::IOS::BasicBufferedStreamBuffer< ACE_CHAR_T, TR >::~BasicBufferedStreamBuffer (  )  [virtual]

Definition at line 37 of file BufferedStreamBuffer.cpp.

      {
      }

template<class ACE_CHAR_T, class TR = std::char_traits<ACE_CHAR_T>>
ACE::IOS::BasicBufferedStreamBuffer< ACE_CHAR_T, TR >::BasicBufferedStreamBuffer ( const BasicBufferedStreamBuffer< ACE_CHAR_T, TR > &   )  [private]

Member Function Documentation

template<class ACE_CHAR_T , class TR >
int ACE::IOS::BasicBufferedStreamBuffer< ACE_CHAR_T, TR >::flush_buffer (  )  [private]

Definition at line 160 of file BufferedStreamBuffer.cpp.

      {
        int n = int (this->pptr () - this->pbase ());

        if (this->interceptor_)
          this->interceptor_->before_write (this->pbase (), n);

        int n_out = this->write_to_stream (this->pbase (), n);

        if (this->interceptor_)
          this->interceptor_->after_write (n_out);

        if (n_out == n)
        {
          this->pbump (-n);
          return n;
        }
        return -1;
      }

template<class ACE_CHAR_T , class TR >
std::basic_ios< ACE_CHAR_T, TR >::openmode ACE::IOS::BasicBufferedStreamBuffer< ACE_CHAR_T, TR >::get_mode ( void   )  const [protected]

Definition at line 126 of file BufferedStreamBuffer.cpp.

      {
        return this->mode_;
      }

template<class ACE_CHAR_T, class TR = std::char_traits<ACE_CHAR_T>>
BasicBufferedStreamBuffer& ACE::IOS::BasicBufferedStreamBuffer< ACE_CHAR_T, TR >::operator= ( const BasicBufferedStreamBuffer< ACE_CHAR_T, TR > &   )  [private]
template<class ACE_CHAR_T , class TR >
BasicBufferedStreamBuffer< ACE_CHAR_T, TR >::int_type ACE::IOS::BasicBufferedStreamBuffer< ACE_CHAR_T, TR >::overflow ( int_type  c  )  [virtual]

Definition at line 43 of file BufferedStreamBuffer.cpp.

      {
        if (!(this->mode_ & ios_type::out)) return char_traits::eof ();

        if (c != char_traits::eof ())
        {
          *this->pptr () = char_traits::to_char_type (c);
          this->pbump (1);
        }
        if (this->flush_buffer () == std::streamsize (-1)) return char_traits::eof ();

        return c;
      }

template<class ACE_CHAR_T , class TR >
int ACE::IOS::BasicBufferedStreamBuffer< ACE_CHAR_T, TR >::read_from_stream ( char_type buffer,
std::streamsize  length 
) [protected, virtual]

Reimplemented in ACE::IOS::String_StreamBufferBase< ACE_CHAR_T, TR >, and ACE::IOS::String_StreamBufferBase< char_type, std::char_traits< char_type > >.

Definition at line 133 of file BufferedStreamBuffer.cpp.

      {
        // to be implemented in derived class
        return 0;
      }

template<class ACE_CHAR_T , class TR >
void ACE::IOS::BasicBufferedStreamBuffer< ACE_CHAR_T, TR >::reset_buffers (  )  [protected]

Definition at line 149 of file BufferedStreamBuffer.cpp.

      {
        this->setg (this->buffer_.get () + 4,
                    this->buffer_.get () + 4,
                    this->buffer_.get () + 4);
        this->setp (this->buffer_.get (),
                    this->buffer_.get () + (this->bufsize_ - 1));
      }

template<class ACE_CHAR_T , class TR >
void ACE::IOS::BasicBufferedStreamBuffer< ACE_CHAR_T, TR >::set_interceptor ( interceptor_type interceptor  ) 

Definition at line 111 of file BufferedStreamBuffer.cpp.

      {
        this->interceptor_ = &interceptor;
      }

template<class ACE_CHAR_T, class TR>
void ACE::IOS::BasicBufferedStreamBuffer< ACE_CHAR_T, TR >::set_mode ( typename std::basic_ios< ACE_CHAR_T, TR >::openmode  mode  )  [protected]

Definition at line 118 of file BufferedStreamBuffer.cpp.

      {
        this->mode_ = mode;
      }

template<class ACE_CHAR_T , class TR >
int ACE::IOS::BasicBufferedStreamBuffer< ACE_CHAR_T, TR >::sync ( void   )  [virtual]

Reimplemented in ACE::FTP::StreamBuffer, and ACE::HTTP::StreamBuffer.

Definition at line 100 of file BufferedStreamBuffer.cpp.

      {
        if (this->pptr () && this->pptr () > this->pbase ())
        {
          if (this->flush_buffer () == -1) return -1;
        }
        return 0;
      }

template<class ACE_CHAR_T , class TR >
BasicBufferedStreamBuffer< ACE_CHAR_T, TR >::int_type ACE::IOS::BasicBufferedStreamBuffer< ACE_CHAR_T, TR >::underflow ( void   )  [virtual]

Definition at line 59 of file BufferedStreamBuffer.cpp.

      {
        if (!(this->mode_ & ios_type::in)) return char_traits::eof ();

        if (this->gptr () && (this->gptr () < this->egptr ()))
          return char_traits::to_int_type (*this->gptr ());

        int putback = int (this->gptr () - this->eback ());
        if (putback > 4) putback = 4;

        ACE_OS::memmove (this->buffer_.get () + (4 - putback),
                         this->gptr (),
                         putback * sizeof (char_type));

        if (this->interceptor_)
          this->interceptor_->before_read (this->bufsize_ - 4);

        int n = this->read_from_stream (this->buffer_.get () + 4,
                                        this->bufsize_ - 4);

        if (this->interceptor_)
          this->interceptor_->after_read (this->buffer_.get () + 4, n);

        if (n <= 0)
          {
            if (this->interceptor_)
              this->interceptor_->on_eof ();

            return char_traits::eof ();
          }

        this->setg (this->buffer_.get () + (4 - putback),
                    this->buffer_.get () + 4,
                    this->buffer_.get () + 4 + n);

        // return next character
        return char_traits::to_int_type (*this->gptr ());
      }

template<class ACE_CHAR_T , class TR >
int ACE::IOS::BasicBufferedStreamBuffer< ACE_CHAR_T, TR >::write_to_stream ( const char_type buffer,
std::streamsize  length 
) [protected, virtual]

Reimplemented in ACE::IOS::String_StreamBufferBase< ACE_CHAR_T, TR >, and ACE::IOS::String_StreamBufferBase< char_type, std::char_traits< char_type > >.

Definition at line 141 of file BufferedStreamBuffer.cpp.

      {
        // to be implemented in derived class
        return 0;
      }


Member Data Documentation

template<class ACE_CHAR_T, class TR = std::char_traits<ACE_CHAR_T>>
ACE_Auto_Ptr<char_type> ACE::IOS::BasicBufferedStreamBuffer< ACE_CHAR_T, TR >::buffer_ [private]

Definition at line 85 of file BufferedStreamBuffer.h.

template<class ACE_CHAR_T, class TR = std::char_traits<ACE_CHAR_T>>
std::streamsize ACE::IOS::BasicBufferedStreamBuffer< ACE_CHAR_T, TR >::bufsize_ [private]

Definition at line 84 of file BufferedStreamBuffer.h.

template<class ACE_CHAR_T, class TR = std::char_traits<ACE_CHAR_T>>
interceptor_type* ACE::IOS::BasicBufferedStreamBuffer< ACE_CHAR_T, TR >::interceptor_ [private]

Definition at line 87 of file BufferedStreamBuffer.h.

template<class ACE_CHAR_T, class TR = std::char_traits<ACE_CHAR_T>>
std::basic_ios<ACE_CHAR_T, TR>::openmode ACE::IOS::BasicBufferedStreamBuffer< ACE_CHAR_T, TR >::mode_ [private]

Definition at line 86 of file BufferedStreamBuffer.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines