std::basic_stringbuf<CharT,Traits,Allocator>::seekpos (3) - Linux Manuals
std::basic_stringbuf<CharT,Traits,Allocator>::seekpos: std::basic_stringbuf<CharT,Traits,Allocator>::seekpos
Command to display std::basic_stringbuf<CharT,Traits,Allocator>::seekpos
manual in Linux: $ man 3 std::basic_stringbuf<CharT,Traits,Allocator>::seekpos
NAME
std::basic_stringbuf<CharT,Traits,Allocator>::seekpos - std::basic_stringbuf<CharT,Traits,Allocator>::seekpos
Synopsis
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)
Parameters
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
Return value
sp on success or pos_type(off_type(-1)) on failure.
Notes
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()
Example
// 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);
}
Output:
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
See also
invokes seekpos()
pubseekpos (public member function of std::basic_streambuf<CharT,Traits>)
seekoff repositions the next pointer in the input sequence, output sequence, or both, using relative addressing
(virtual protected member function)
[virtual]
seekpos repositions the file position, using absolute addressing
(virtual protected member function of std::basic_filebuf<CharT,Traits>)
[virtual]
seekpos repositions the next pointer in the input sequence, output sequence, or both using absolute addressing
(virtual protected member function of std::strstreambuf)
[virtual]
Pages related to std::basic_stringbuf<CharT,Traits,Allocator>::seekpos
- std::basic_stringbuf<CharT,Traits,Allocator>::seekoff (3) - std::basic_stringbuf<CharT,Traits,Allocator>::seekoff
- std::basic_stringbuf<CharT,Traits,Allocator>::setbuf (3) - std::basic_stringbuf<CharT,Traits,Allocator>::setbuf
- std::basic_stringbuf<CharT,Traits,Allocator>::str (3) - std::basic_stringbuf<CharT,Traits,Allocator>::str
- std::basic_stringbuf<CharT,Traits,Allocator>::swap (3) - std::basic_stringbuf<CharT,Traits,Allocator>::swap
- std::basic_stringbuf<CharT,Traits,Allocator>::basic_stringbuf (3) - std::basic_stringbuf<CharT,Traits,Allocator>::basic_stringbuf
- std::basic_stringbuf<CharT,Traits,Allocator>::operator= (3) - std::basic_stringbuf<CharT,Traits,Allocator>::operator=
- std::basic_stringbuf<CharT,Traits,Allocator>::overflow (3) - std::basic_stringbuf<CharT,Traits,Allocator>::overflow
- std::basic_stringbuf<CharT,Traits,Allocator>::pbackfail (3) - std::basic_stringbuf<CharT,Traits,Allocator>::pbackfail
- std::basic_stringbuf<CharT,Traits,Allocator>::underflow (3) - std::basic_stringbuf<CharT,Traits,Allocator>::underflow
- std::basic_stringbuf (3) - std::basic_stringbuf
- std::basic_string (3) - std::basic_string
- std::basic_string<CharT,Traits,Allocator>::append (3) - std::basic_string<CharT,Traits,Allocator>::append
- std::basic_string<CharT,Traits,Allocator>::assign (3) - std::basic_string<CharT,Traits,Allocator>::assign
- std::basic_string<CharT,Traits,Allocator>::at (3) - std::basic_string<CharT,Traits,Allocator>::at
- std::basic_string<CharT,Traits,Allocator>::back (3) - std::basic_string<CharT,Traits,Allocator>::back
- std::basic_string<CharT,Traits,Allocator>::basic_string (3) - std::basic_string<CharT,Traits,Allocator>::basic_string
- std::basic_string<CharT,Traits,Allocator>::begin, (3) - std::basic_string<CharT,Traits,Allocator>::begin,
- std::basic_string<CharT,Traits,Allocator>::begin,std::basic_string<CharT,Traits,Allocator>::cbegin (3) - std::basic_string<CharT,Traits,Allocator>::begin,std::basic_string<CharT,Traits,Allocator>::cbegin
- std::basic_string<CharT,Traits,Allocator>::c_str (3) - std::basic_string<CharT,Traits,Allocator>::c_str
- std::basic_string<CharT,Traits,Allocator>::capacity (3) - std::basic_string<CharT,Traits,Allocator>::capacity
- std::basic_string<CharT,Traits,Allocator>::clear (3) - std::basic_string<CharT,Traits,Allocator>::clear