GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::basic_streambuf::pubsetbuf,std::basic_streambuf::setbuf(3) C++ Standard Libary std::basic_streambuf::pubsetbuf,std::basic_streambuf::setbuf(3)

std::basic_streambuf::pubsetbuf,std::basic_streambuf::setbuf - std::basic_streambuf::pubsetbuf,std::basic_streambuf::setbuf


basic_streambuf<CharT, Traits>* pubsetbuf( char_type* s, std::streamsize n ) (1)
protected:
virtual basic_streambuf<CharT, Traits>* setbuf( char_type* s, std::streamsize n (2)
)


1) Calls setbuf(s, n) of the most derived class
2) The base class version of this function has no effect. The derived classes may
override this function to allow removal or replacement of the controlled character
sequence (the buffer) with a user-provided array, or for any other
implementation-specific purpose.


s - pointer to the first CharT in the user-provided buffer
n - the number of CharT elements in the user-provided buffer


1) The return value of setbuf(s, n)
2) this


provide a 10k buffer for reading. On linux, the strace utility may be used to
observe the actual number of bytes read

// Run this code


#include <fstream>
#include <iostream>
#include <string>


int main()
{
int cnt = 0;
std::ifstream file;
char buf[1024*10 + 1];


file.rdbuf()->pubsetbuf(buf, sizeof buf);


file.open("/usr/share/dict/words");


for (std::string line; getline(file, line);) {
cnt++;
}


std::cout << cnt << '\n';
}


setbuf attempts to replace the controlled character sequence with an array
[virtual] (virtual protected member function of
std::basic_stringbuf<CharT,Traits,Allocator>)
setbuf provides user-supplied buffer or turns this filebuf unbuffered
[virtual] (virtual protected member function of std::basic_filebuf<CharT,Traits>)
setbuf attempts to replace the controlled character sequence with an array
[virtual] (virtual protected member function of std::strstreambuf)
setbuf sets the buffer for a file stream
(function)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.