SourcePro® API Reference Guide

 
List of all members | Public Types | Public Member Functions | Protected Member Functions
RWChainedMemoryStreambuf Class Reference

Implementation of the std::streambuf interface as a linked list of buffers. More...

#include <rw/stream/RWChainedMemoryStreambuf.h>

Inherits streambuf.

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 ()
 
void clear ()
 
int in_avail () const
 
RWSize num_avail () const
 
int out_waiting () const
 
char_typestr ()
 

Protected Member Functions

virtual int_type overflow (int_type c=RWChainedMemoryStreambuf::traits_type::eof())
 
virtual int_type pbackfail (int_type c=RWChainedMemoryStreambuf::traits_type::eof())
 
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 int sync ()
 
virtual int_type underflow ()
 
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 creates a linked list of buffers, so that existing data is not copied when additional data is written to the streambuf.

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
sA pointer to the initial text.
lenThe 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 allocates 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())
protectedvirtual

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
cForces 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())
protectedvirtual

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
cThe 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 
)
protectedvirtual

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 
)
protectedvirtual

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 ( )
protectedvirtual

This function always returns zero.

virtual int_type RWChainedMemoryStreambuf::underflow ( )
protectedvirtual

Returns the first character in the get area if called when there are characters in the get area. 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 
)
protectedvirtual

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
sA pointer to the first element of the character array.
nThe number of elements to be read.
virtual std::streamsize RWChainedMemoryStreambuf::xsputn ( const char_type s,
std::streamsize  n 
)
protectedvirtual

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

Parameters
sA pointer to the first element of the character array.
nThe number of elements to be read.

Copyright © 2023 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.