tmp/tmpxnzqy2d4/{from.md → to.md}
RENAMED
|
@@ -27,22 +27,23 @@ namespace std {
|
|
| 27 |
void freeze(bool freezefl = true);
|
| 28 |
char* str();
|
| 29 |
int pcount();
|
| 30 |
|
| 31 |
protected:
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
ios_base::openmode which
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
|
|
|
| 41 |
|
| 42 |
private:
|
| 43 |
-
|
| 44 |
static const strstate allocated; // exposition only
|
| 45 |
static const strstate constant; // exposition only
|
| 46 |
static const strstate dynamic; // exposition only
|
| 47 |
static const strstate frozen; // exposition only
|
| 48 |
strstate strmode; // exposition only
|
|
@@ -56,10 +57,12 @@ namespace std {
|
|
| 56 |
The class `strstreambuf` associates the input sequence, and possibly the
|
| 57 |
output sequence, with an object of some *character* array type, whose
|
| 58 |
elements store arbitrary values. The array object has several
|
| 59 |
attributes.
|
| 60 |
|
|
|
|
|
|
|
| 61 |
For the sake of exposition, these are represented as elements of a
|
| 62 |
bitmask type (indicated here as `T1`) called `strstate`. The elements
|
| 63 |
are:
|
| 64 |
|
| 65 |
- `allocated`, set when a dynamic array object has been allocated, and
|
|
@@ -69,20 +72,26 @@ are:
|
|
| 69 |
- `dynamic`, set when the array object is allocated (or reallocated) as
|
| 70 |
necessary to hold a character sequence that can change in length;
|
| 71 |
- `frozen`, set when the program has requested that the array object not
|
| 72 |
be altered, reallocated, or freed.
|
| 73 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
For the sake of exposition, the maintained data is presented here as:
|
| 75 |
|
| 76 |
- `strstate strmode`, the attributes of the array object associated with
|
| 77 |
the `strstreambuf` object;
|
| 78 |
- `int alsize`, the suggested minimum size for a dynamic array object;
|
| 79 |
- `void* (*palloc)(size_t)`, points to the function to call to allocate
|
| 80 |
a dynamic array object;
|
| 81 |
- `void (*pfree)(void*)`, points to the function to call to free a
|
| 82 |
dynamic array object.
|
| 83 |
|
|
|
|
|
|
|
| 84 |
Each object of class `strstreambuf` has a *seekable area*, delimited by
|
| 85 |
the pointers `seeklow` and `seekhigh`. If `gnext` is a null pointer, the
|
| 86 |
seekable area is undefined. Otherwise, `seeklow` equals `gbeg` and
|
| 87 |
`seekhigh` is either `pend`, if `pend` is not a null pointer, or `gend`.
|
| 88 |
|
|
@@ -128,32 +137,71 @@ strstreambuf(signed char* gnext_arg, streamsize n,
|
|
| 128 |
signed char* pbeg_arg = 0);
|
| 129 |
strstreambuf(unsigned char* gnext_arg, streamsize n,
|
| 130 |
unsigned char* pbeg_arg = 0);
|
| 131 |
```
|
| 132 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 133 |
``` cpp
|
| 134 |
setg(gnext_arg, gnext_arg, gnext_arg + N);
|
| 135 |
```
|
| 136 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 137 |
``` cpp
|
| 138 |
virtual ~strstreambuf();
|
| 139 |
```
|
| 140 |
|
| 141 |
*Effects:* Destroys an object of class `strstreambuf`. The function
|
| 142 |
frees the dynamically allocated array object only if
|
| 143 |
-
`strmode & allocated != 0` and
|
| 144 |
-
`strmode & frozen == 0`. ([[depr.strstreambuf.virtuals]] describes
|
| 145 |
-
a dynamically allocated array object is freed.)
|
| 146 |
|
| 147 |
#### Member functions <a id="depr.strstreambuf.members">[[depr.strstreambuf.members]]</a>
|
| 148 |
|
| 149 |
``` cpp
|
| 150 |
void freeze(bool freezefl = true);
|
| 151 |
```
|
| 152 |
|
| 153 |
-
*Effects:* If `strmode
|
| 154 |
-
|
| 155 |
|
| 156 |
- If `freezefl` is `true`, the function sets `frozen` in `strmode`.
|
| 157 |
- Otherwise, it clears `frozen` in `strmode`.
|
| 158 |
|
| 159 |
``` cpp
|
|
@@ -170,16 +218,16 @@ int pcount() const;
|
|
| 170 |
```
|
| 171 |
|
| 172 |
*Effects:* If the next pointer for the output sequence, `pnext`, is a
|
| 173 |
null pointer, returns zero. Otherwise, returns the current effective
|
| 174 |
length of the array object as the next pointer minus the beginning
|
| 175 |
-
pointer for the output sequence, `pnext
|
| 176 |
|
| 177 |
#### `strstreambuf` overridden virtual functions <a id="depr.strstreambuf.virtuals">[[depr.strstreambuf.virtuals]]</a>
|
| 178 |
|
| 179 |
``` cpp
|
| 180 |
-
int_type overflow(int_type c = EOF);
|
| 181 |
```
|
| 182 |
|
| 183 |
*Effects:* Appends the character designated by `c` to the output
|
| 184 |
sequence, if possible, in one of two ways:
|
| 185 |
|
|
@@ -197,36 +245,36 @@ available as a result of any call.
|
|
| 197 |
|
| 198 |
To make a write position available, the function reallocates (or
|
| 199 |
initially allocates) an array object with a sufficient number of
|
| 200 |
elements `n` to hold the current array object (if any), plus at least
|
| 201 |
one additional write position. How many additional write positions are
|
| 202 |
-
made available is otherwise unspecified. [^
|
| 203 |
pointer, the function calls `(*palloc)(n)` to allocate the new dynamic
|
| 204 |
array object. Otherwise, it evaluates the expression `new charT[n]`. In
|
| 205 |
either case, if the allocation fails, the function returns `EOF`.
|
| 206 |
Otherwise, it sets `allocated` in `strmode`.
|
| 207 |
|
| 208 |
To free a previously existing dynamic array object whose first element
|
| 209 |
address is `p`: If `pfree` is not a null pointer, the function calls
|
| 210 |
`(*pfree)(p)`. Otherwise, it evaluates the expression `delete[]p`.
|
| 211 |
|
| 212 |
-
If `strmode & dynamic == 0`, or if `strmode & frozen != 0`, the
|
| 213 |
-
cannot extend the array (reallocate it with greater length) to
|
| 214 |
-
write position available.
|
| 215 |
|
| 216 |
``` cpp
|
| 217 |
-
int_type pbackfail(int_type c = EOF);
|
| 218 |
```
|
| 219 |
|
| 220 |
Puts back the character designated by `c` to the input sequence, if
|
| 221 |
possible, in one of three ways:
|
| 222 |
|
| 223 |
- If `c != EOF`, if the input sequence has a putback position available,
|
| 224 |
and if `(char)c == gnext[-1]`, assigns `gnext - 1` to `gnext`. Returns
|
| 225 |
`c`.
|
| 226 |
- If `c != EOF`, if the input sequence has a putback position available,
|
| 227 |
-
and if `strmode
|
| 228 |
Returns `c`.
|
| 229 |
- If `c == EOF` and if the input sequence has a putback position
|
| 230 |
available, assigns `gnext - 1` to `gnext`. Returns a value other than
|
| 231 |
`EOF`.
|
| 232 |
|
|
@@ -235,11 +283,11 @@ Returns `EOF` to indicate failure.
|
|
| 235 |
*Remarks:* If the function can succeed in more than one of these ways,
|
| 236 |
it is unspecified which way is chosen. The function can alter the number
|
| 237 |
of putback positions available as a result of any call.
|
| 238 |
|
| 239 |
``` cpp
|
| 240 |
-
int_type underflow();
|
| 241 |
```
|
| 242 |
|
| 243 |
*Effects:* Reads a character from the *input sequence*, if possible,
|
| 244 |
without moving the stream position past it, as follows:
|
| 245 |
|
|
@@ -247,19 +295,19 @@ without moving the stream position past it, as follows:
|
|
| 247 |
signals success by returning `(unsigned char)*gnext`.
|
| 248 |
- Otherwise, if the current write next pointer `pnext` is not a null
|
| 249 |
pointer and is greater than the current read end pointer `gend`, makes
|
| 250 |
a *read position* available by assigning to `gend` a value greater
|
| 251 |
than `gnext` and no greater than `pnext`. Returns
|
| 252 |
-
`(unsigned char
|
| 253 |
|
| 254 |
Returns `EOF` to indicate failure.
|
| 255 |
|
| 256 |
*Remarks:* The function can alter the number of read positions available
|
| 257 |
as a result of any call.
|
| 258 |
|
| 259 |
``` cpp
|
| 260 |
-
pos_type seekoff(off_type off, seekdir way, openmode which = in | out);
|
| 261 |
```
|
| 262 |
|
| 263 |
*Effects:* Alters the stream position within one of the controlled
|
| 264 |
sequences, if possible, as indicated in
|
| 265 |
Table [[tab:future.seekoff.positioning]].
|
|
@@ -298,11 +346,11 @@ position, if possible. If the positioning operation fails, or if the
|
|
| 298 |
constructed object cannot represent the resultant stream position, the
|
| 299 |
return value is `pos_type(off_type(-1))`.
|
| 300 |
|
| 301 |
``` cpp
|
| 302 |
pos_type seekpos(pos_type sp, ios_base::openmode which
|
| 303 |
-
= ios_base::in | ios_base::out);
|
| 304 |
```
|
| 305 |
|
| 306 |
*Effects:* Alters the stream position within one of the controlled
|
| 307 |
sequences, if possible, to correspond to the stream position stored in
|
| 308 |
`sp` (as described below).
|
|
@@ -315,11 +363,11 @@ sequences, if possible, to correspond to the stream position stored in
|
|
| 315 |
For a sequence to be positioned, if its next pointer is a null pointer,
|
| 316 |
the positioning operation fails. Otherwise, the function determines
|
| 317 |
`newoff` from `sp.offset()`:
|
| 318 |
|
| 319 |
- If `newoff` is an invalid stream position, has a negative value, or
|
| 320 |
-
has a value greater than (`seekhigh
|
| 321 |
operation fails
|
| 322 |
- Otherwise, the function adds `newoff` to the beginning pointer `xbeg`
|
| 323 |
and stores the result in the next pointer `xnext`.
|
| 324 |
|
| 325 |
*Returns:* `pos_type(newoff)`, constructed from the resultant offset
|
|
@@ -327,11 +375,11 @@ the positioning operation fails. Otherwise, the function determines
|
|
| 327 |
position, if possible. If the positioning operation fails, or if the
|
| 328 |
constructed object cannot represent the resultant stream position, the
|
| 329 |
return value is `pos_type(off_type(-1))`.
|
| 330 |
|
| 331 |
``` cpp
|
| 332 |
-
streambuf<char>* setbuf(char* s, streamsize n);
|
| 333 |
```
|
| 334 |
|
| 335 |
*Effects:* Implementation defined, except that `setbuf(0, 0)` has no
|
| 336 |
effect.
|
| 337 |
|
|
@@ -369,19 +417,20 @@ explicit istrstream(const char* s);
|
|
| 369 |
explicit istrstream(char* s);
|
| 370 |
```
|
| 371 |
|
| 372 |
*Effects:* Constructs an object of class `istrstream`, initializing the
|
| 373 |
base class with `istream(&sb)` and initializing `sb` with
|
| 374 |
-
`strstreambuf(s,0)
|
| 375 |
|
| 376 |
``` cpp
|
| 377 |
istrstream(const char* s, streamsize n);
|
|
|
|
| 378 |
```
|
| 379 |
|
| 380 |
*Effects:* Constructs an object of class `istrstream`, initializing the
|
| 381 |
base class with `istream(&sb)` and initializing `sb` with
|
| 382 |
-
`strstreambuf(s,n)
|
| 383 |
whose length is `n` elements, and `n` shall be greater than zero.
|
| 384 |
|
| 385 |
#### Member functions <a id="depr.istrstream.members">[[depr.istrstream.members]]</a>
|
| 386 |
|
| 387 |
``` cpp
|
|
@@ -429,11 +478,11 @@ is presented here as:
|
|
| 429 |
ostrstream();
|
| 430 |
```
|
| 431 |
|
| 432 |
*Effects:* Constructs an object of class `ostrstream`, initializing the
|
| 433 |
base class with `ostream(&sb)` and initializing `sb` with
|
| 434 |
-
`strstreambuf()
|
| 435 |
|
| 436 |
``` cpp
|
| 437 |
ostrstream(char* s, int n, ios_base::openmode mode = ios_base::out);
|
| 438 |
```
|
| 439 |
|
|
@@ -444,11 +493,11 @@ constructors:
|
|
| 444 |
- If `(mode & app) == 0`, then `s` shall designate the first element of
|
| 445 |
an array of `n` elements. The constructor is `strstreambuf(s, n, s)`.
|
| 446 |
- If `(mode & app) != 0`, then `s` shall designate the first element of
|
| 447 |
an array of `n` elements that contains an NTBSwhose first element is
|
| 448 |
designated by `s`. The constructor is
|
| 449 |
-
`strstreambuf(s, n, s + std::strlen(s))`.[^
|
| 450 |
|
| 451 |
#### Member functions <a id="depr.ostrstream.members">[[depr.ostrstream.members]]</a>
|
| 452 |
|
| 453 |
``` cpp
|
| 454 |
strstreambuf* rdbuf() const;
|
|
@@ -480,14 +529,14 @@ int pcount() const;
|
|
| 480 |
namespace std {
|
| 481 |
class strstream
|
| 482 |
: public basic_iostream<char> {
|
| 483 |
public:
|
| 484 |
// Types
|
| 485 |
-
|
| 486 |
-
|
| 487 |
-
|
| 488 |
-
|
| 489 |
|
| 490 |
// constructors/destructor
|
| 491 |
strstream();
|
| 492 |
strstream(char* s, int n,
|
| 493 |
ios_base::openmode mode = ios_base::in|ios_base::out);
|
|
@@ -543,18 +592,18 @@ two constructors:
|
|
| 543 |
virtual ~strstream();
|
| 544 |
```
|
| 545 |
|
| 546 |
*Effects:* Destroys an object of class `strstream`.
|
| 547 |
|
| 548 |
-
``` cpp
|
| 549 |
-
strstreambuf* rdbuf() const;
|
| 550 |
-
```
|
| 551 |
-
|
| 552 |
-
*Returns:* `&sb`.
|
| 553 |
-
|
| 554 |
#### `strstream` operations <a id="depr.strstream.oper">[[depr.strstream.oper]]</a>
|
| 555 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 556 |
``` cpp
|
| 557 |
void freeze(bool freezefl = true);
|
| 558 |
```
|
| 559 |
|
| 560 |
*Effects:* Calls `rdbuf()->freeze(freezefl)`.
|
|
|
|
| 27 |
void freeze(bool freezefl = true);
|
| 28 |
char* str();
|
| 29 |
int pcount();
|
| 30 |
|
| 31 |
protected:
|
| 32 |
+
int_type overflow (int_type c = EOF) override;
|
| 33 |
+
int_type pbackfail(int_type c = EOF) override;
|
| 34 |
+
int_type underflow() override;
|
| 35 |
+
pos_type seekoff(off_type off, ios_base::seekdir way,
|
| 36 |
ios_base::openmode which
|
| 37 |
+
= ios_base::in | ios_base::out) override;
|
| 38 |
+
pos_type seekpos(pos_type sp,
|
| 39 |
+
ios_base::openmode which
|
| 40 |
+
= ios_base::in | ios_base::out) override;
|
| 41 |
+
streambuf* setbuf(char* s, streamsize n) override;
|
| 42 |
|
| 43 |
private:
|
| 44 |
+
using strstate = T1; // exposition only
|
| 45 |
static const strstate allocated; // exposition only
|
| 46 |
static const strstate constant; // exposition only
|
| 47 |
static const strstate dynamic; // exposition only
|
| 48 |
static const strstate frozen; // exposition only
|
| 49 |
strstate strmode; // exposition only
|
|
|
|
| 57 |
The class `strstreambuf` associates the input sequence, and possibly the
|
| 58 |
output sequence, with an object of some *character* array type, whose
|
| 59 |
elements store arbitrary values. The array object has several
|
| 60 |
attributes.
|
| 61 |
|
| 62 |
+
[*Note 1*:
|
| 63 |
+
|
| 64 |
For the sake of exposition, these are represented as elements of a
|
| 65 |
bitmask type (indicated here as `T1`) called `strstate`. The elements
|
| 66 |
are:
|
| 67 |
|
| 68 |
- `allocated`, set when a dynamic array object has been allocated, and
|
|
|
|
| 72 |
- `dynamic`, set when the array object is allocated (or reallocated) as
|
| 73 |
necessary to hold a character sequence that can change in length;
|
| 74 |
- `frozen`, set when the program has requested that the array object not
|
| 75 |
be altered, reallocated, or freed.
|
| 76 |
|
| 77 |
+
— *end note*]
|
| 78 |
+
|
| 79 |
+
[*Note 2*:
|
| 80 |
+
|
| 81 |
For the sake of exposition, the maintained data is presented here as:
|
| 82 |
|
| 83 |
- `strstate strmode`, the attributes of the array object associated with
|
| 84 |
the `strstreambuf` object;
|
| 85 |
- `int alsize`, the suggested minimum size for a dynamic array object;
|
| 86 |
- `void* (*palloc)(size_t)`, points to the function to call to allocate
|
| 87 |
a dynamic array object;
|
| 88 |
- `void (*pfree)(void*)`, points to the function to call to free a
|
| 89 |
dynamic array object.
|
| 90 |
|
| 91 |
+
— *end note*]
|
| 92 |
+
|
| 93 |
Each object of class `strstreambuf` has a *seekable area*, delimited by
|
| 94 |
the pointers `seeklow` and `seekhigh`. If `gnext` is a null pointer, the
|
| 95 |
seekable area is undefined. Otherwise, `seeklow` equals `gbeg` and
|
| 96 |
`seekhigh` is either `pend`, if `pend` is not a null pointer, or `gend`.
|
| 97 |
|
|
|
|
| 137 |
signed char* pbeg_arg = 0);
|
| 138 |
strstreambuf(unsigned char* gnext_arg, streamsize n,
|
| 139 |
unsigned char* pbeg_arg = 0);
|
| 140 |
```
|
| 141 |
|
| 142 |
+
*Effects:* Constructs an object of class `strstreambuf`, initializing
|
| 143 |
+
the base class with `streambuf()`. The postconditions of this function
|
| 144 |
+
are indicated in Table [[tab:future.strstreambuf2.effects]].
|
| 145 |
+
|
| 146 |
+
**Table: `strstreambuf(charT*, streamsize, charT*)` effects** <a id="tab:future.strstreambuf2.effects">[tab:future.strstreambuf2.effects]</a>
|
| 147 |
+
|
| 148 |
+
| Element | Value |
|
| 149 |
+
| --------- | -------------------- |
|
| 150 |
+
| `strmode` | 0 |
|
| 151 |
+
| `alsize` | an unspecified value |
|
| 152 |
+
| `palloc` | a null pointer |
|
| 153 |
+
| `pfree` | a null pointer |
|
| 154 |
+
|
| 155 |
+
|
| 156 |
+
`gnext_arg` shall point to the first element of an array object whose
|
| 157 |
+
number of elements `N` is determined as follows:
|
| 158 |
+
|
| 159 |
+
- If `n > 0`, `N` is `n`.
|
| 160 |
+
- If `n == 0`, `N` is `std::strlen(gnext_arg)`.
|
| 161 |
+
- If `n < 0`, `N` is `INT_MAX`.[^1]
|
| 162 |
+
|
| 163 |
+
If `pbeg_arg` is a null pointer, the function executes:
|
| 164 |
+
|
| 165 |
``` cpp
|
| 166 |
setg(gnext_arg, gnext_arg, gnext_arg + N);
|
| 167 |
```
|
| 168 |
|
| 169 |
+
Otherwise, the function executes:
|
| 170 |
+
|
| 171 |
+
``` cpp
|
| 172 |
+
setg(gnext_arg, gnext_arg, pbeg_arg);
|
| 173 |
+
setp(pbeg_arg, pbeg_arg + N);
|
| 174 |
+
```
|
| 175 |
+
|
| 176 |
+
``` cpp
|
| 177 |
+
strstreambuf(const char* gnext_arg, streamsize n);
|
| 178 |
+
strstreambuf(const signed char* gnext_arg, streamsize n);
|
| 179 |
+
strstreambuf(const unsigned char* gnext_arg, streamsize n);
|
| 180 |
+
```
|
| 181 |
+
|
| 182 |
+
*Effects:* Behaves the same as `strstreambuf((char*)gnext_arg,n)`,
|
| 183 |
+
except that the constructor also sets `constant` in `strmode`.
|
| 184 |
+
|
| 185 |
``` cpp
|
| 186 |
virtual ~strstreambuf();
|
| 187 |
```
|
| 188 |
|
| 189 |
*Effects:* Destroys an object of class `strstreambuf`. The function
|
| 190 |
frees the dynamically allocated array object only if
|
| 191 |
+
`(strmode & allocated) != 0` and
|
| 192 |
+
`(strmode & frozen) == 0`. ([[depr.strstreambuf.virtuals]] describes
|
| 193 |
+
how a dynamically allocated array object is freed.)
|
| 194 |
|
| 195 |
#### Member functions <a id="depr.strstreambuf.members">[[depr.strstreambuf.members]]</a>
|
| 196 |
|
| 197 |
``` cpp
|
| 198 |
void freeze(bool freezefl = true);
|
| 199 |
```
|
| 200 |
|
| 201 |
+
*Effects:* If `strmode & dynamic` is nonzero, alters the freeze status
|
| 202 |
+
of the dynamic array object as follows:
|
| 203 |
|
| 204 |
- If `freezefl` is `true`, the function sets `frozen` in `strmode`.
|
| 205 |
- Otherwise, it clears `frozen` in `strmode`.
|
| 206 |
|
| 207 |
``` cpp
|
|
|
|
| 218 |
```
|
| 219 |
|
| 220 |
*Effects:* If the next pointer for the output sequence, `pnext`, is a
|
| 221 |
null pointer, returns zero. Otherwise, returns the current effective
|
| 222 |
length of the array object as the next pointer minus the beginning
|
| 223 |
+
pointer for the output sequence, `pnext - pbeg`.
|
| 224 |
|
| 225 |
#### `strstreambuf` overridden virtual functions <a id="depr.strstreambuf.virtuals">[[depr.strstreambuf.virtuals]]</a>
|
| 226 |
|
| 227 |
``` cpp
|
| 228 |
+
int_type overflow(int_type c = EOF) override;
|
| 229 |
```
|
| 230 |
|
| 231 |
*Effects:* Appends the character designated by `c` to the output
|
| 232 |
sequence, if possible, in one of two ways:
|
| 233 |
|
|
|
|
| 245 |
|
| 246 |
To make a write position available, the function reallocates (or
|
| 247 |
initially allocates) an array object with a sufficient number of
|
| 248 |
elements `n` to hold the current array object (if any), plus at least
|
| 249 |
one additional write position. How many additional write positions are
|
| 250 |
+
made available is otherwise unspecified. [^2] If `palloc` is not a null
|
| 251 |
pointer, the function calls `(*palloc)(n)` to allocate the new dynamic
|
| 252 |
array object. Otherwise, it evaluates the expression `new charT[n]`. In
|
| 253 |
either case, if the allocation fails, the function returns `EOF`.
|
| 254 |
Otherwise, it sets `allocated` in `strmode`.
|
| 255 |
|
| 256 |
To free a previously existing dynamic array object whose first element
|
| 257 |
address is `p`: If `pfree` is not a null pointer, the function calls
|
| 258 |
`(*pfree)(p)`. Otherwise, it evaluates the expression `delete[]p`.
|
| 259 |
|
| 260 |
+
If `(strmode & dynamic) == 0`, or if `(strmode & frozen) != 0`, the
|
| 261 |
+
function cannot extend the array (reallocate it with greater length) to
|
| 262 |
+
make a write position available.
|
| 263 |
|
| 264 |
``` cpp
|
| 265 |
+
int_type pbackfail(int_type c = EOF) override;
|
| 266 |
```
|
| 267 |
|
| 268 |
Puts back the character designated by `c` to the input sequence, if
|
| 269 |
possible, in one of three ways:
|
| 270 |
|
| 271 |
- If `c != EOF`, if the input sequence has a putback position available,
|
| 272 |
and if `(char)c == gnext[-1]`, assigns `gnext - 1` to `gnext`. Returns
|
| 273 |
`c`.
|
| 274 |
- If `c != EOF`, if the input sequence has a putback position available,
|
| 275 |
+
and if `strmode & constant` is zero, assigns `c` to `*`\dcr`gnext`.
|
| 276 |
Returns `c`.
|
| 277 |
- If `c == EOF` and if the input sequence has a putback position
|
| 278 |
available, assigns `gnext - 1` to `gnext`. Returns a value other than
|
| 279 |
`EOF`.
|
| 280 |
|
|
|
|
| 283 |
*Remarks:* If the function can succeed in more than one of these ways,
|
| 284 |
it is unspecified which way is chosen. The function can alter the number
|
| 285 |
of putback positions available as a result of any call.
|
| 286 |
|
| 287 |
``` cpp
|
| 288 |
+
int_type underflow() override;
|
| 289 |
```
|
| 290 |
|
| 291 |
*Effects:* Reads a character from the *input sequence*, if possible,
|
| 292 |
without moving the stream position past it, as follows:
|
| 293 |
|
|
|
|
| 295 |
signals success by returning `(unsigned char)*gnext`.
|
| 296 |
- Otherwise, if the current write next pointer `pnext` is not a null
|
| 297 |
pointer and is greater than the current read end pointer `gend`, makes
|
| 298 |
a *read position* available by assigning to `gend` a value greater
|
| 299 |
than `gnext` and no greater than `pnext`. Returns
|
| 300 |
+
`(unsigned char)*gnext`.
|
| 301 |
|
| 302 |
Returns `EOF` to indicate failure.
|
| 303 |
|
| 304 |
*Remarks:* The function can alter the number of read positions available
|
| 305 |
as a result of any call.
|
| 306 |
|
| 307 |
``` cpp
|
| 308 |
+
pos_type seekoff(off_type off, seekdir way, openmode which = in | out) override;
|
| 309 |
```
|
| 310 |
|
| 311 |
*Effects:* Alters the stream position within one of the controlled
|
| 312 |
sequences, if possible, as indicated in
|
| 313 |
Table [[tab:future.seekoff.positioning]].
|
|
|
|
| 346 |
constructed object cannot represent the resultant stream position, the
|
| 347 |
return value is `pos_type(off_type(-1))`.
|
| 348 |
|
| 349 |
``` cpp
|
| 350 |
pos_type seekpos(pos_type sp, ios_base::openmode which
|
| 351 |
+
= ios_base::in | ios_base::out) override;
|
| 352 |
```
|
| 353 |
|
| 354 |
*Effects:* Alters the stream position within one of the controlled
|
| 355 |
sequences, if possible, to correspond to the stream position stored in
|
| 356 |
`sp` (as described below).
|
|
|
|
| 363 |
For a sequence to be positioned, if its next pointer is a null pointer,
|
| 364 |
the positioning operation fails. Otherwise, the function determines
|
| 365 |
`newoff` from `sp.offset()`:
|
| 366 |
|
| 367 |
- If `newoff` is an invalid stream position, has a negative value, or
|
| 368 |
+
has a value greater than (`seekhigh - seeklow`), the positioning
|
| 369 |
operation fails
|
| 370 |
- Otherwise, the function adds `newoff` to the beginning pointer `xbeg`
|
| 371 |
and stores the result in the next pointer `xnext`.
|
| 372 |
|
| 373 |
*Returns:* `pos_type(newoff)`, constructed from the resultant offset
|
|
|
|
| 375 |
position, if possible. If the positioning operation fails, or if the
|
| 376 |
constructed object cannot represent the resultant stream position, the
|
| 377 |
return value is `pos_type(off_type(-1))`.
|
| 378 |
|
| 379 |
``` cpp
|
| 380 |
+
streambuf<char>* setbuf(char* s, streamsize n) override;
|
| 381 |
```
|
| 382 |
|
| 383 |
*Effects:* Implementation defined, except that `setbuf(0, 0)` has no
|
| 384 |
effect.
|
| 385 |
|
|
|
|
| 417 |
explicit istrstream(char* s);
|
| 418 |
```
|
| 419 |
|
| 420 |
*Effects:* Constructs an object of class `istrstream`, initializing the
|
| 421 |
base class with `istream(&sb)` and initializing `sb` with
|
| 422 |
+
`strstreambuf(s,0)`. `s` shall designate the first element of an NTBS.
|
| 423 |
|
| 424 |
``` cpp
|
| 425 |
istrstream(const char* s, streamsize n);
|
| 426 |
+
istrstream(char* s, streamsize n);
|
| 427 |
```
|
| 428 |
|
| 429 |
*Effects:* Constructs an object of class `istrstream`, initializing the
|
| 430 |
base class with `istream(&sb)` and initializing `sb` with
|
| 431 |
+
`strstreambuf(s,n)`. `s` shall designate the first element of an array
|
| 432 |
whose length is `n` elements, and `n` shall be greater than zero.
|
| 433 |
|
| 434 |
#### Member functions <a id="depr.istrstream.members">[[depr.istrstream.members]]</a>
|
| 435 |
|
| 436 |
``` cpp
|
|
|
|
| 478 |
ostrstream();
|
| 479 |
```
|
| 480 |
|
| 481 |
*Effects:* Constructs an object of class `ostrstream`, initializing the
|
| 482 |
base class with `ostream(&sb)` and initializing `sb` with
|
| 483 |
+
`strstreambuf()`.
|
| 484 |
|
| 485 |
``` cpp
|
| 486 |
ostrstream(char* s, int n, ios_base::openmode mode = ios_base::out);
|
| 487 |
```
|
| 488 |
|
|
|
|
| 493 |
- If `(mode & app) == 0`, then `s` shall designate the first element of
|
| 494 |
an array of `n` elements. The constructor is `strstreambuf(s, n, s)`.
|
| 495 |
- If `(mode & app) != 0`, then `s` shall designate the first element of
|
| 496 |
an array of `n` elements that contains an NTBSwhose first element is
|
| 497 |
designated by `s`. The constructor is
|
| 498 |
+
`strstreambuf(s, n, s + std::strlen(s))`.[^3]
|
| 499 |
|
| 500 |
#### Member functions <a id="depr.ostrstream.members">[[depr.ostrstream.members]]</a>
|
| 501 |
|
| 502 |
``` cpp
|
| 503 |
strstreambuf* rdbuf() const;
|
|
|
|
| 529 |
namespace std {
|
| 530 |
class strstream
|
| 531 |
: public basic_iostream<char> {
|
| 532 |
public:
|
| 533 |
// Types
|
| 534 |
+
using char_type = char;
|
| 535 |
+
using int_type = char_traits<char>::int_type;
|
| 536 |
+
using pos_type = char_traits<char>::pos_type;
|
| 537 |
+
using off_type = char_traits<char>::off_type;
|
| 538 |
|
| 539 |
// constructors/destructor
|
| 540 |
strstream();
|
| 541 |
strstream(char* s, int n,
|
| 542 |
ios_base::openmode mode = ios_base::in|ios_base::out);
|
|
|
|
| 592 |
virtual ~strstream();
|
| 593 |
```
|
| 594 |
|
| 595 |
*Effects:* Destroys an object of class `strstream`.
|
| 596 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 597 |
#### `strstream` operations <a id="depr.strstream.oper">[[depr.strstream.oper]]</a>
|
| 598 |
|
| 599 |
+
``` cpp
|
| 600 |
+
strstreambuf* rdbuf() const;
|
| 601 |
+
```
|
| 602 |
+
|
| 603 |
+
*Returns:* `&sb`.
|
| 604 |
+
|
| 605 |
``` cpp
|
| 606 |
void freeze(bool freezefl = true);
|
| 607 |
```
|
| 608 |
|
| 609 |
*Effects:* Calls `rdbuf()->freeze(freezefl)`.
|