rwlogo
SourcePro C++ 12.0

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

RWChainedMemoryStreambuf Class Reference
[Streams]

Implementation of the iostreams std::streambuf interface, providing increased performance. More...

#include <rw/stream/RWChainedMemoryStreambuf.h>

List of all members.

Public Types

typedef std::streambuf::char_type char_type
typedef std::streambuf::traits_type traits_type

Public Member Functions

 RWChainedMemoryStreambuf ()
 RWChainedMemoryStreambuf (const char_type *s, RWSize len)
virtual ~RWChainedMemoryStreambuf ()
int in_avail () const
int out_waiting () const
RWSize num_avail () const
char_typestr ()
void clear ()

Protected Member Functions

virtual int_type overflow (int_type c=RWChainedMemoryStreambuf::traits_type::eof())
virtual int_type underflow ()
virtual int_type pbackfail (int_type c=RWChainedMemoryStreambuf::traits_type::eof())
virtual int sync ()
virtual pos_type seekoff (off_type off, std::ios_base::seekdir way, std::ios_base::openmode which=std::ios_base::in|std::ios_base::out)
virtual pos_type seekpos (pos_type sp, std::ios_base::openmode which=std::ios_base::in|std::ios_base::out)
virtual std::streamsize xsgetn (char_type *s, std::streamsize n)
virtual std::streamsize xsputn (const char_type *s, std::streamsize n)

Detailed Description

Class RWChainedMemoryStreambuf implements the iostreams std::streambuf interface. It provides increased performance characteristic over using classes std::strstreambuf or std::stringbuf, because it uses efficient internal data structures and reduces the amount of data copying. In addition RWChainedMemoryStreambuf can be used to store binary data and will return the number of bytes currently being stored. RWChainedMemoryStreambuf creates a linked list of buffers, so that data is not copied as the number of characters is increased.


Member Typedef Documentation

typedef std::streambuf::char_type RWChainedMemoryStreambuf::char_type

A typedef for the character type.

typedef std::streambuf::traits_type RWChainedMemoryStreambuf::traits_type

A typedef for the character traits type.


Constructor & Destructor Documentation

RWChainedMemoryStreambuf::RWChainedMemoryStreambuf (  ) 

Creates a buffer suitable for output.

RWChainedMemoryStreambuf::RWChainedMemoryStreambuf ( const char_type s,
RWSize  len 
)

Creates a buffer that can be used for input. If output is performed to an RWChainedMemoryStreambuf that was given initial text, it is appended to the end.

Parameters:
s A pointer to the initial text.
len The length of the initial text.
virtual RWChainedMemoryStreambuf::~RWChainedMemoryStreambuf (  )  [virtual]

Destructor.


Member Function Documentation

void RWChainedMemoryStreambuf::clear (  ) 

Frees the memory associated with the current internal buffer, and allocate a new empty buffer.

int RWChainedMemoryStreambuf::in_avail (  )  const

Returns the number of characters available. Can also be called on a buffer that was created with an initial set of characters to determine the number left to be read.

RWSize RWChainedMemoryStreambuf::num_avail (  )  const

Returns the length of the string that the str() function would return.

int RWChainedMemoryStreambuf::out_waiting (  )  const

Returns the length of the string that the str() function would return.

virtual int_type RWChainedMemoryStreambuf::overflow ( int_type  c = RWChainedMemoryStreambuf::traits_type::eof()  )  [protected, virtual]

The allocated buffer is chained to the buffer currently being used, and then becomes the default buffer into which elements are inserted. If an error occurs, overflow() returns traits_type::eof(); otherwise it returns a value other than traits_type::eof().

Parameters:
c Forces a new internal buffer to be allocated, or any other 8-bit value that should be inserted in the put area.
virtual int_type RWChainedMemoryStreambuf::pbackfail ( int_type  c = RWChainedMemoryStreambuf::traits_type::eof()  )  [protected, virtual]

This function is used to fill a string backward. It adds characters starting at the last position available. The function returns traits_type::eof() in case of failure; otherwise it returns a value other than traits_type::eof().

Parameters:
c The character to be added, or traits_type::eof() to move the input sequence one position backward.
virtual pos_type RWChainedMemoryStreambuf::seekoff ( off_type  off,
std::ios_base::seekdir  way,
std::ios_base::openmode  which = std::ios_base::in|std::ios_base::out 
) [protected, virtual]

This function always returns traits_type::eof() to indicate failure.

virtual pos_type RWChainedMemoryStreambuf::seekpos ( pos_type  sp,
std::ios_base::openmode  which = std::ios_base::in|std::ios_base::out 
) [protected, virtual]

This function always returns traits_type::eof() to indicate failure.

char_type* RWChainedMemoryStreambuf::str (  ) 

Returns the data as a string. This function takes all of the characters out of the buffer and returns them as a single string. Once they have been returned, they are removed from the buffer. The caller must delete the string.

virtual int RWChainedMemoryStreambuf::sync (  )  [protected, virtual]

This function always returns zero.

virtual int_type RWChainedMemoryStreambuf::underflow (  )  [protected, virtual]

Returns the first character in the get area if called when there are characters in the get area (and if you are using a standard C++ library implementation). If the get area is empty, then the function sets the get sequence so that it points to the appropriate internal buffer. If no characters are available, the function returns traits_type::eof().

virtual std::streamsize RWChainedMemoryStreambuf::xsgetn ( char_type s,
std::streamsize  n 
) [protected, virtual]

This function gets n characters from the input sequence, and stores them in the array pointed at by s. The function returns the number of characters read.

Parameters:
s A pointer to the first element of the character array.
n The number of elements to be read.
virtual std::streamsize RWChainedMemoryStreambuf::xsputn ( const char_type s,
std::streamsize  n 
) [protected, virtual]

This function stores n characters pointed to by s after the put pointer, and increments the put pointer by n.

Parameters:
s A pointer to the first element of the character array.
n The number of elements to be read.
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends

© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.