mirror of
https://gitlab.com/fbb-git/cppannotations
synced 2024-11-16 07:48:44 +01:00
43df12533c
git-svn-id: https://cppannotations.svn.sourceforge.net/svnroot/cppannotations/trunk@581 f6dd340e-d3f9-0310-b409-bdd246841980
40 lines
1.8 KiB
Text
40 lines
1.8 KiB
Text
Although not every tt(ostream) object supports i(repositioning), they usually
|
|
do. This means that it is possible to rewrite a section of the stream which
|
|
was written earlier. Repositioning is frequently used in database applications
|
|
where it must be possible to access the information in the database at random.
|
|
|
|
The current position can be obtained and modified using the following members:
|
|
itemization(
|
|
ithtq(tellp)(ios::pos_type tellp())
|
|
(the current (absolute) position in the file where the next
|
|
write-operation to the stream will take place is returned.)
|
|
ithtq(seekp)
|
|
(ostream &seekp(ios::off_type step, ios::seekdir org))
|
|
(modifies a stream's actual position. The function expects an
|
|
ti(off_type) tt(step) representing the number of bytes the current stream
|
|
position is moved with respect to tt(org). The tt(step) value
|
|
may be negative, zero or positive.
|
|
|
|
The origin of the step, tt(org) is a value in the
|
|
hi(seekdir)tt(ios::seekdir) enumeration. Its values are:
|
|
itemization(
|
|
ithtq(beg)(ios::beg)
|
|
(the stepsize is computed relative to the beginning of the
|
|
stream. This value is used by default.
|
|
)
|
|
ithtq(cur)(ios::cur)
|
|
(the stepsize is computed relative to the current position of the
|
|
stream (as returned by tt(tellp)).
|
|
)
|
|
ithtq(end)(ios::end)
|
|
(the stepsize is interpreted relative to the current end position
|
|
of the stream.)
|
|
)
|
|
It is OK to
|
|
hi(write beyond end of file)hi(seek beyond file boundaries)
|
|
seek or write beyond the last file position. Writing bytes to a location
|
|
beyond endOfFile() will pad the intermediate bytes with i(ASCII-Z) values:
|
|
i(null-bytes).
|
|
Seeking before tt(ios::beg) raises the hi(fail)tt(ios::fail) flag.
|
|
)
|
|
)
|