cplusplus.com cplusplus.com
cplusplus.com   C++ : Reference : IOstream Library : streambuf : pubsetbuf
- -
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::pubsetbuf public member function
streambuf* pubsetbuf ( char* s, streamsize n );

Set buffer array

Calls the protected virtual member setbuf, which is intended to set the array pointed by parameter s as the internal character sequece to be used by the stream buffer object, although specific implementations may vary.

If both parameters are zero, the object becomes unbuffered.

Parameters

s
Pointer to an array of n characters already allocated in memory.
n
Length of the character buffer pointed by s, measured in characters.
This is an intergral value of type streamsize.

Return Value

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

Example

// set character buffer (pubsetbuf)
#include <fstream>
using namespace std;

int main () {

  char mybuffer [512];
  fstream filestr;
  filestr.rdbuf()->pubsetbuf(mybuffer,512);

  // operations with file stream here.

  return 0;
}

The code in this example sets a new buffer of 512 characters for filestr's strembuf object if the iostream implementation allows for it.

Basic template member declaration

( basic_streambuf<charT,traits> )
basic_streambuf<charT,traits>* pubsetbuf (charT* s, streamsize n);

See also

streambuf::setbuf Set buffer (virtual protected member function)

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