cppannotations/annotations/yo/iostreams/istreamseek.yo
Frank B. Brokken 777b182edd Moved all files but 'excluded', 'sf', and 'sourcetar' to ./annotations
This allowed me to standardize the sourcetar and sf/* scripts: the base
    directory (containing ./git) is now empty, except for maintenance scripts,
    while the source files and build scripts of the annotations are stored in
    a subdirectory of their own.
2013-05-29 20:44:08 +02:00

37 lines
1.6 KiB
Text

Although not every tt(istream) object supports i(repositioning), some do. This
means that it is possible to read the same section of a stream
repeatedly. Repositioning is frequently used in emi(database applications)
where it must be possible to access the information in the database randomly.
The current position can be obtained and modified using the following members:
itemization(
ithtq(tellg)(ios::pos_type tellg())
(hi(pos_type)the stream's current (absolute) position where the
stream's next read-operation will take place is returned.)
ithtq(seekg)
(istream &seekg(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 the stream.)
)
It is OK to hi(seek beyond file boundaries) seek beyond the last file
position. Seeking before tt(ios::beg) raises the hi(failbit)tt(ios::failbit)
flag.
)
)