cplusplus.com cplusplus.com
cplusplus.com   C++ : Reference : IOstream Library : streambuf : setbuf
- -
C++
Information
Documentation
Reference
Articles
Sourcecode
Forum
Reference
C Library
IOstream Library
Strings library
STL Containers
STL Algorithms
IOstream Library
manipulators
classes:
· filebuf
· fstream
· ifstream
· ios
· iostream
· ios_base
· istream
· istringstream
· ofstream
· ostream
· ostringstream
· streambuf
· stringbuf
· stringstream
objects:
· cerr
· cin
· clog
· cout
types:
· fpos
· streamoff
· streampos
· streamsize
streambuf
· streambuf::streambuf
· streambuf::~streambuf
public members:
· streambuf::getloc
· streambuf::in_avail
· streambuf::pubimbue
· streambuf::pubseekoff
· streambuf::pubseekpos
· streambuf::pubsetbuf
· streambuf::pubsync
· streambuf::sbumpc
· streambuf::sgetc
· streambuf::sgetn
· streambuf::snextc
· streambuf::sputbackc
· streambuf::sputc
· streambuf::sputn
· streambuf::sungetc
protected members:
· streambuf::eback
· streambuf::egptr
· streambuf::epptr
· streambuf::gbump
· streambuf::gptr
· streambuf::pbase
· streambuf::pbump
· streambuf::pptr
· streambuf::setg
· streambuf::setp
virtual prot. members:
· streambuf::imbue
· streambuf::overflow
· streambuf::pbackfail
· streambuf::seekoff
· streambuf::seekpos
· streambuf::setbuf
· streambuf::showmanyc
· streambuf::sync
· streambuf::uflow
· streambuf::underflow
· streambuf::xsgetn
· streambuf::xsputn

-

streambuf::setbuf virtual protected member function
streambuf * setbuf ( char * s, streamsize n );

Set buffer

This member is called to set a new buffer for the streambuf object. The public member function pubsetbuf calls this protected member function to perform this action.

This is a virtual member function that shall be redefined in derived classes to behave as expected by setting the array of n characters pointed by s as the new character buffer. Its default behavior in streambuf is to do nothing and return a reference to the object (this), but it is redefined in both standard derived class, filebuf and stringbuf, to behave as expected specifically for each type of buffer (see filebuf::setbuf and stringbuf::setbuf).

Parameters

s
Pointer to an array of n characters already allocated in memory. If this parameter is a null pointer, the stream shall be unbuffered.
n
Length in characters of the buffer pointed by s.
This is an integer value of type streamsize.

Return Value

In case of success, the member function should return the pointer this, otherwise a null pointer.

Basic template member declaration

( basic_streambuf<charT,traits> )
typedef charT char_type;
basic_streambuf* setbuf ( char_type* s, streamsize n );

See also

streambuf::pubsetbuf Set buffer array (public member function)

© The C++ Resources Network, 2000-2007 - All rights reserved
Spotted an error? - contact us