110 lines
3.7 KiB
Markdown
110 lines
3.7 KiB
Markdown
[streambuf.reqts]
|
||
|
||
# 31 Input/output library [[input.output]](./#input.output)
|
||
|
||
## 31.6 Stream buffers [[stream.buffers]](stream.buffers#streambuf.reqts)
|
||
|
||
### 31.6.2 Stream buffer requirements [streambuf.reqts]
|
||
|
||
[1](#1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2891)
|
||
|
||
Stream buffers can impose various constraints on the sequences they control[.](#1.sentence-1)
|
||
|
||
Some constraints are:
|
||
|
||
- [(1.1)](#1.1)
|
||
|
||
The controlled input sequence can be not readable[.](#1.1.sentence-1)
|
||
|
||
- [(1.2)](#1.2)
|
||
|
||
The controlled output sequence can be not writable[.](#1.2.sentence-1)
|
||
|
||
- [(1.3)](#1.3)
|
||
|
||
The controlled sequences can be associated with the contents of other
|
||
representations for character sequences, such as external files[.](#1.3.sentence-1)
|
||
|
||
- [(1.4)](#1.4)
|
||
|
||
The controlled sequences can support operations*directly* to or from associated sequences[.](#1.4.sentence-1)
|
||
|
||
- [(1.5)](#1.5)
|
||
|
||
The controlled sequences can impose limitations on how the program can
|
||
read characters from a sequence,
|
||
write characters to a sequence,
|
||
put characters back into an input sequence, or
|
||
alter the stream position[.](#1.5.sentence-1)
|
||
|
||
[2](#2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2914)
|
||
|
||
Each sequence is characterized by three pointers which, if non-null,
|
||
all point into the samecharT array object[.](#2.sentence-1)
|
||
|
||
The array object represents, at any moment,
|
||
a (sub)sequence of characters from the sequence[.](#2.sentence-2)
|
||
|
||
Operations performed on a sequence alter the values stored in these pointers,
|
||
perform reads and writes directly to or from associated sequences, and
|
||
alter âthe stream positionâ and conversion state as needed to
|
||
maintain this subsequence relationship[.](#2.sentence-3)
|
||
|
||
The three pointers are:
|
||
|
||
- [(2.1)](#2.1)
|
||
|
||
the[*beginning pointer*](#def:beginning_pointer),
|
||
or lowest element address in the array
|
||
(called xbeg here);
|
||
|
||
- [(2.2)](#2.2)
|
||
|
||
the[*next pointer*](#def:next_pointer),
|
||
or next element address that is a current
|
||
candidate for reading or writing (called xnext here);
|
||
|
||
- [(2.3)](#2.3)
|
||
|
||
the[*end pointer*](#def:end_pointer),
|
||
or first element address beyond the end of
|
||
the array (called xend here)[.](#2.sentence-4)
|
||
|
||
[3](#3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2944)
|
||
|
||
The following semantic constraints shall always apply for any set of
|
||
three pointers for a sequence, using the pointer names given immediately above:
|
||
|
||
- [(3.1)](#3.1)
|
||
|
||
If xnext is not a null pointer, thenxbeg and xend shall also be non-null pointers
|
||
into the samecharT array, as described above; otherwise, xbeg andxend shall also be null[.](#3.1.sentence-1)
|
||
|
||
- [(3.2)](#3.2)
|
||
|
||
If xnext is not a null pointer andxnext < xend for an output sequence, then a[*write position*](#def:write_position) is available[.](#3.2.sentence-1)
|
||
In this case,*xnext shall be assignable as the
|
||
next element to write
|
||
(to put, or to store a character value, into the sequence)[.](#3.2.sentence-2)
|
||
|
||
- [(3.3)](#3.3)
|
||
|
||
If xnext is not a null pointer andxbeg < xnext for an input sequence,
|
||
then a[*putback position*](#def:putback_position) is available[.](#3.3.sentence-1)
|
||
In this case,xnext[-1] shall have a defined value and is the next (preceding) element
|
||
to store a character that is put back into the input sequence[.](#3.3.sentence-2)
|
||
|
||
- [(3.4)](#3.4)
|
||
|
||
If xnext is not a null pointer andxnext < xend for an input sequence,
|
||
then a[*read position*](#def:read_position) is available[.](#3.4.sentence-1)
|
||
In this case,*xnext shall have a defined value
|
||
and is the next element to read
|
||
(to get, or to obtain a character value, from the sequence)[.](#3.4.sentence-2)
|