streambuf::pubseekoff
streampos pubseekoff ( streamoff off, ios_base::seekdir way, ios_base::openmode which = ios_base::in | ios_base::out ); | streambuf |
cplusplus.com |
Set position of internal position pointer.
Calls protected virtual member seekoff.
The standard behavior of function seekoff
in derived stream buffer classes is to set a new position value for an internal position
pointer. Often, strembuf derived object have independent input and output
position pointers, which parameter determines which one is affected.
Parameters.
Return Value.
The new position value of the modified position pointer.
Example.
// get file size using pubseekoff
#include <iostream>
#include <fstream>
using namespace std;
int main () {
long size;
filebuf* pbuf;
fstream filestr ("test.txt");
pbuf = filestr.rdbuf();
size = pbuf->pubseekoff(0,ios_base::end);
filestr.close();
cout << "size of file is " << size << endl;
return 0;
}
This program prints out the size of file test.txt using the value returned by
pubseekoff when repositioning to the end.
Basic template member declaration ( basic_streambuf<charT,traits> ):
typedef traits::pos_type pos_type; typedef traits::off_type off_type; pos_type pubseekoff (off_type off, ios_base::seekdir way, ios_base which = ios_base::in | ios_base::out ); |
See also.
pubseekpos
streambuf class