Module: Advanced Tools Package: Streams
RWChainedMemoryStreambuf std::streambuf
#include <rw/stream/RWChainedMemoryStreambuf.h>
Class RWChainedMemoryStreambuf implements the iostreams std::streambuf interface. It provides increased performance characteristic over using classes strstreambuf or 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.
typedef char char_type char_type typedef streambuf::char_type traits_type
RWChainedMemoryStreambuf();
Creates a buffer suitable for output.
virtual ~RWChainedMemoryStreambuf();
Destructor.
void clear();
Frees the memory associated with the current internal buffer, and allocate a new empty buffer.
int 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 num_avail() const;
Returns the length of the string that the str() function would return.
int out_waiting() const;
Returns the length of the string that the str() function would return.
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.
Parameter List
s |
A pointer to the initial text. |
len |
The length of the initial text. |
char_type* 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_type overflow(int_type c = traits_type::eof());
(Use if a standard C++ library implementation and the Standard iostreams are defined.)
virtual int overflow(int c=EOF);
(Use if a standard C++ library implementation and the Standard iostreams are not defined.)
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; otherwise it returns a value other than EOF.
Parameter List
c traits_type |
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 pbackfail(int_type c = traits_type::eof());
(Use if a standard C++ library implementation and the Standard iostreams are defined.)
virtual int pbackfail(int c= EOF);
(Use if a standard C++ library implementation and the Standard iostreams are not defined.)
This function is used to fill a string backward. It adds characters starting at the last position available. The function returns traits_type in case of failure; otherwise it returns a value other than traits_type.
Parameter List
c |
The character to be added, or traits_type to move the input sequence one position backward. |
virtual pos_type seekoff(off_type off, ios_base::seekdir way, ios_base::openmode which = ios_base::in | ios_base::out);
(Use if a standard C++ library implementation and the Standard iostreams are defined.)
virtual streampos seekoff(streamoff offset, ios::seek_dir dir, int mode= ios::in | ios::out);
(Use if the Standard iostreams are not defined.)
This function always returns EOF to indicate failure.
virtual pos_type seekpos(pos_type sp, ios_base::openmode which = ios_base::in | ios_base::out);
(Use if a standard C++ library implementation and the Standard iostreams are defined.)
virtual streampos seekpos(streampos, int mode= ios::in | ios::out);
(Use if the Standard iostreams are not defined.)
This function always returns EOF to indicate failure.
virtual int showmanyc();
Returns the number of characters available in the input sequence. It is guaranteed that this many characters can be read with no errors being reported.
virtual int sync();
This function always returns zero.
virtual int_type underflow();
(Use if a standard C++ library implementation and the Standard iostreams are defined.)
virtual int underflow();
(Use if the Standard iostreams are not defined.)
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 EOF.
virtual streamsize xsgetn(char_type* s, streamsize n);
(Use if a standard C++ library implementation and the Standard iostreams are defined.)
virtual int xsgetn(char_type* s, int n);
(Use if the Standard iostreams are not defined.)
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. (Use if RW_NO_IOSTD is defined.)
Parameter List
s |
A pointer to the first element of the character array. |
n |
The number of elements to be read. |
virtual streamsize xsputn(const char_type* s, streamsize n);
(Use if a standard C++ library implementation and the Standard iostreams are defined.)
virtual int xsputn(const char_type* s, int n);
(Use if the Standard iostreams are not defined.)
This function stores n characters pointed to by s after the put pointer, and increments the put pointer by n.
Parameter List
s |
A pointer to the first element of the character array. |
n |
The number of elements to be written. |
© 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.