File: derivingfromstreambuf.yo

package info (click to toggle)
c%2B%2B-annotations 12.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 13,044 kB
  • sloc: cpp: 24,337; makefile: 1,517; ansic: 165; sh: 121; perl: 90
file content (16 lines) | stat: -rw-r--r-- 1,008 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
    When classes are derived from tt(streambuf) at least tt(underflow) should
be overridden by classes intending to read information from devices, and
tt(overflow) should be overridden by classes intending to write information to
devices. Several examples of classes derived from tt(streambuf) are provided
in chapter ref(CONCRETE).

    tt(Fstream) class type objects use a combined input/output buffer,
resulting from tt(istream) and tt(ostream) being virtually derived from
tt(ios), which class defines a tt(streambuf). To construct a class
supporting both input and output using separate buffers, the tt(streambuf)
itself may define two buffers. When tt(seekoff) is called for reading, a
tt(mode) parameter can be set to tt(ios::in), otherwise to tt(ios::out). Thus
the derived class knows whether it should access the tt(read) buffer or the
tt(write) buffer. Of course, tt(underflow) and tt(overflow) do not have to
inspect the mode flag as they by implication know on which buffer they should
operate.