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

ACE::IOS::BasicBidirStreamBuffer< ACE_CHAR_T, STREAM_HANDLER, TR > Class Template Reference

#include <BidirStreamBuffer.h>

Collaboration diagram for ACE::IOS::BasicBidirStreamBuffer< ACE_CHAR_T, STREAM_HANDLER, 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::openmode openmode
typedef StreamInterceptorBase
< char_type, char_traits
interceptor_type

Public Member Functions

 BasicBidirStreamBuffer (STREAM_HANDLER *sh, std::streamsize bufsz, openmode mode)
 Constructor.
virtual ~BasicBidirStreamBuffer ()
 Destructor.
virtual int_type overflow (int_type c)
virtual int_type underflow ()
virtual int sync ()
const STREAM_HANDLER & stream () const
void close_stream ()
void set_interceptor (interceptor_type &interceptor)

Protected Member Functions

void set_mode (openmode mode)
openmode get_mode () const
void reset_buffers ()

Private Member Functions

virtual int read_from_stream (char_type *buffer, std::streamsize length)
virtual int write_to_stream (const char_type *buffer, std::streamsize length)
int flush_buffer ()
 BasicBidirStreamBuffer (const BasicBidirStreamBuffer &)
BasicBidirStreamBufferoperator= (const BasicBidirStreamBuffer &)

Private Attributes

std::streamsize bufsize_
ACE_Auto_Ptr< char_typeread_buffer_
ACE_Auto_Ptr< char_typewrite_buffer_
openmode mode_
STREAM_HANDLER * stream_
interceptor_typeinterceptor_

Detailed Description

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

Definition at line 46 of file BidirStreamBuffer.h.


Member Typedef Documentation

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

Definition at line 51 of file BidirStreamBuffer.h.

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

Definition at line 54 of file BidirStreamBuffer.h.

template<class ACE_CHAR_T, class STREAM_HANDLER, class TR = std::char_traits<ACE_CHAR_T>>
typedef ACE_CHAR_T ACE::IOS::BasicBidirStreamBuffer< ACE_CHAR_T, STREAM_HANDLER, TR >::char_type

Definition at line 53 of file BidirStreamBuffer.h.

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

Definition at line 55 of file BidirStreamBuffer.h.

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

Definition at line 59 of file BidirStreamBuffer.h.

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

Definition at line 52 of file BidirStreamBuffer.h.

template<class ACE_CHAR_T, class STREAM_HANDLER, class TR = std::char_traits<ACE_CHAR_T>>
typedef base_type::off_type ACE::IOS::BasicBidirStreamBuffer< ACE_CHAR_T, STREAM_HANDLER, TR >::off_type

Definition at line 57 of file BidirStreamBuffer.h.

template<class ACE_CHAR_T, class STREAM_HANDLER, class TR = std::char_traits<ACE_CHAR_T>>
typedef ios_type::openmode ACE::IOS::BasicBidirStreamBuffer< ACE_CHAR_T, STREAM_HANDLER, TR >::openmode
template<class ACE_CHAR_T, class STREAM_HANDLER, class TR = std::char_traits<ACE_CHAR_T>>
typedef base_type::pos_type ACE::IOS::BasicBidirStreamBuffer< ACE_CHAR_T, STREAM_HANDLER, TR >::pos_type

Definition at line 56 of file BidirStreamBuffer.h.


Constructor & Destructor Documentation

template<class ACE_CHAR_T , class STREAM_HANDLER, class TR >
ACE::IOS::BasicBidirStreamBuffer< ACE_CHAR_T, STREAM_HANDLER, TR >::BasicBidirStreamBuffer ( STREAM_HANDLER *  sh,
std::streamsize  bufsz,
openmode  mode 
)

Constructor.

Definition at line 18 of file BidirStreamBuffer.cpp.

      : bufsize_ (bufsz),
        mode_ (mode),
        stream_ (sh),
        interceptor_ (0)
      {
        this->stream_->add_reference ();

        char_type* p = 0;
        ACE_NEW_NORETURN (p, char_type [bufsz]);
        this->read_buffer_.reset (p);
        p = 0;
        ACE_NEW_NORETURN (p, char_type [bufsz]);
        this->write_buffer_.reset (p);

        this->reset_buffers ();
      }

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

Destructor.

Definition at line 40 of file BidirStreamBuffer.cpp.

      {
        this->close_stream ();
      }

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

Member Function Documentation

template<class ACE_CHAR_T , class STREAM_HANDLER , class TR >
void ACE::IOS::BasicBidirStreamBuffer< ACE_CHAR_T, STREAM_HANDLER, TR >::close_stream (  ) 

Definition at line 122 of file BidirStreamBuffer.cpp.

      {
        if (this->stream_ != 0)
          {
            ACE_Errno_Guard eguard (errno);
            this->stream_->remove_reference ();
            this->stream_ = 0;
          }
      }

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

Definition at line 180 of file BidirStreamBuffer.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 STREAM_HANDLER , class TR >
BasicBidirStreamBuffer< ACE_CHAR_T, STREAM_HANDLER, TR >::openmode ACE::IOS::BasicBidirStreamBuffer< ACE_CHAR_T, STREAM_HANDLER, TR >::get_mode ( void   )  const [protected]

Definition at line 148 of file BidirStreamBuffer.cpp.

      {
        return this->mode_;
      }

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

Definition at line 47 of file BidirStreamBuffer.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 STREAM_HANDLER , class TR >
int ACE::IOS::BasicBidirStreamBuffer< ACE_CHAR_T, STREAM_HANDLER, TR >::read_from_stream ( char_type buffer,
std::streamsize  length 
) [private, virtual]

Definition at line 166 of file BidirStreamBuffer.cpp.

      {
        return this->stream_ == 0 ? 0 : this->stream_->read_from_stream (buffer, length, sizeof(char_type));
      }

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

Definition at line 155 of file BidirStreamBuffer.cpp.

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

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

Definition at line 134 of file BidirStreamBuffer.cpp.

      {
        this->interceptor_ = &interceptor;
      }

template<class ACE_CHAR_T , class STREAM_HANDLER , class TR >
void ACE::IOS::BasicBidirStreamBuffer< ACE_CHAR_T, STREAM_HANDLER, TR >::set_mode ( openmode  mode  )  [protected]

Definition at line 141 of file BidirStreamBuffer.cpp.

      {
        this->mode_ = mode;
      }

template<class ACE_CHAR_T , class STREAM_HANDLER , class TR >
const STREAM_HANDLER & ACE::IOS::BasicBidirStreamBuffer< ACE_CHAR_T, STREAM_HANDLER, TR >::stream (  )  const

Definition at line 115 of file BidirStreamBuffer.cpp.

      {
        return *this->stream_;
      }

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

Definition at line 104 of file BidirStreamBuffer.cpp.

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

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

Definition at line 63 of file BidirStreamBuffer.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->read_buffer_.get () + (4 - putback),
                         this->gptr () - putback,
                         putback * sizeof (char_type));

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

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

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

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

            return char_traits::eof ();
          }

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

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

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

Definition at line 173 of file BidirStreamBuffer.cpp.

      {
        return this->stream_ == 0 ? 0 : this->stream_->write_to_stream (buffer, length, sizeof(char_type));
      }


Member Data Documentation

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

Definition at line 91 of file BidirStreamBuffer.h.

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

Definition at line 96 of file BidirStreamBuffer.h.

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

Definition at line 94 of file BidirStreamBuffer.h.

template<class ACE_CHAR_T, class STREAM_HANDLER, class TR = std::char_traits<ACE_CHAR_T>>
ACE_Auto_Ptr<char_type> ACE::IOS::BasicBidirStreamBuffer< ACE_CHAR_T, STREAM_HANDLER, TR >::read_buffer_ [private]

Definition at line 92 of file BidirStreamBuffer.h.

template<class ACE_CHAR_T, class STREAM_HANDLER, class TR = std::char_traits<ACE_CHAR_T>>
STREAM_HANDLER* ACE::IOS::BasicBidirStreamBuffer< ACE_CHAR_T, STREAM_HANDLER, TR >::stream_ [private]

Definition at line 95 of file BidirStreamBuffer.h.

template<class ACE_CHAR_T, class STREAM_HANDLER, class TR = std::char_traits<ACE_CHAR_T>>
ACE_Auto_Ptr<char_type> ACE::IOS::BasicBidirStreamBuffer< ACE_CHAR_T, STREAM_HANDLER, TR >::write_buffer_ [private]

Definition at line 93 of file BidirStreamBuffer.h.


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