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_stringbuf::seekpos(3) C++ Standard Libary std::basic_stringbuf::seekpos(3)

std::basic_stringbuf::seekpos - std::basic_stringbuf::seekpos


protected:


virtual pos_type seekpos(pos_type sp,


std::ios_base::openmode which = std::ios_base::in | std::ios_base::out );


Repositions std::basic_streambuf::gptr and/or std::basic_streambuf::pptr, if
possible, to the position indicated by sp


Effectively executes seekoff(off_type(sp), std::ios_base::beg, which)


sp - stream position, such as one obtained by seekoff() or seekpos()
defines whether the input sequences, the output sequence, or both are
affected. It can be one or a combination of the following constants:
which -
Constant Explanation
in affect the input sequence
out affect the output sequence


sp on success or pos_type(off_type(-1)) on failure.


seekpos() is called by std::basic_streambuf::pubseekpos(), which is called by the
single-argument versions of std::basic_istream::seekg() and
std::basic_ostream::seekp()

// Run this code


#include <sstream>
#include <iostream>


struct mybuf : std::stringbuf
{
mybuf(const std::string& str) : std::stringbuf(str) {}
pos_type seekpos(pos_type sp, std::ios_base::openmode which) {
std::cout << "Before seekpos(" << sp << "), size of the get area is "
<< egptr()-eback() << " with "
<< egptr()-gptr() << " read positions available\n";
pos_type rc = std::stringbuf::seekpos(sp, which);
std::cout << "seekpos() returns " << rc << ".\nAfter the call, "
<< "size of the get area is "
<< egptr()-eback() << " with "
<< egptr()-gptr() << " read positions available\n";
return rc;
}
};


int main()
{
mybuf buf("12345");
std::iostream stream(&buf);
stream.seekg(2);
}


Before seekpos(2), size of the get area is 5 with 5 read positions available
seekpos() returns 2.
After the call, size of the get area is 5 with 3 read positions available


pubseekpos invokes seekpos()
(public member function of std::basic_streambuf<CharT,Traits>)
seekoff repositions the next pointer in the input sequence, output sequence, or
[virtual] both, using relative addressing
(virtual protected member function)
seekpos repositions the file position, using absolute addressing
[virtual] (virtual protected member function of std::basic_filebuf<CharT,Traits>)
seekpos repositions the next pointer in the input sequence, output sequence, or
[virtual] both using absolute addressing
(virtual protected member function of std::strstreambuf)

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.