tmp/tmplohfrk6f/{from.md → to.md}
RENAMED
|
@@ -1,637 +0,0 @@
|
|
| 1 |
-
## `char*` streams <a id="depr.str.strstreams">[[depr.str.strstreams]]</a>
|
| 2 |
-
|
| 3 |
-
### Header `<strstream>` synopsis <a id="depr.strstream.syn">[[depr.strstream.syn]]</a>
|
| 4 |
-
|
| 5 |
-
The header `<strstream>` defines types that associate stream buffers
|
| 6 |
-
with character array objects and assist reading and writing such
|
| 7 |
-
objects.
|
| 8 |
-
|
| 9 |
-
``` cpp
|
| 10 |
-
namespace std {
|
| 11 |
-
class strstreambuf;
|
| 12 |
-
class istrstream;
|
| 13 |
-
class ostrstream;
|
| 14 |
-
class strstream;
|
| 15 |
-
}
|
| 16 |
-
```
|
| 17 |
-
|
| 18 |
-
### Class `strstreambuf` <a id="depr.strstreambuf">[[depr.strstreambuf]]</a>
|
| 19 |
-
|
| 20 |
-
#### General <a id="depr.strstreambuf.general">[[depr.strstreambuf.general]]</a>
|
| 21 |
-
|
| 22 |
-
``` cpp
|
| 23 |
-
namespace std {
|
| 24 |
-
class strstreambuf : public basic_streambuf<char> {
|
| 25 |
-
public:
|
| 26 |
-
strstreambuf() : strstreambuf(0) {}
|
| 27 |
-
explicit strstreambuf(streamsize alsize_arg);
|
| 28 |
-
strstreambuf(void* (*palloc_arg)(size_t), void (*pfree_arg)(void*));
|
| 29 |
-
strstreambuf(char* gnext_arg, streamsize n, char* pbeg_arg = nullptr);
|
| 30 |
-
strstreambuf(const char* gnext_arg, streamsize n);
|
| 31 |
-
|
| 32 |
-
strstreambuf(signed char* gnext_arg, streamsize n,
|
| 33 |
-
signed char* pbeg_arg = nullptr);
|
| 34 |
-
strstreambuf(const signed char* gnext_arg, streamsize n);
|
| 35 |
-
strstreambuf(unsigned char* gnext_arg, streamsize n,
|
| 36 |
-
unsigned char* pbeg_arg = nullptr);
|
| 37 |
-
strstreambuf(const unsigned char* gnext_arg, streamsize n);
|
| 38 |
-
|
| 39 |
-
virtual ~strstreambuf();
|
| 40 |
-
|
| 41 |
-
void freeze(bool freezefl = true);
|
| 42 |
-
char* str();
|
| 43 |
-
int pcount();
|
| 44 |
-
|
| 45 |
-
protected:
|
| 46 |
-
int_type overflow (int_type c = EOF) override;
|
| 47 |
-
int_type pbackfail(int_type c = EOF) override;
|
| 48 |
-
int_type underflow() override;
|
| 49 |
-
pos_type seekoff(off_type off, ios_base::seekdir way,
|
| 50 |
-
ios_base::openmode which = ios_base::in | ios_base::out) override;
|
| 51 |
-
pos_type seekpos(pos_type sp,
|
| 52 |
-
ios_base::openmode which = ios_base::in | ios_base::out) override;
|
| 53 |
-
streambuf* setbuf(char* s, streamsize n) override;
|
| 54 |
-
|
| 55 |
-
private:
|
| 56 |
-
using strstate = T1; // exposition only
|
| 57 |
-
static const strstate allocated; // exposition only
|
| 58 |
-
static const strstate constant; // exposition only
|
| 59 |
-
static const strstate dynamic; // exposition only
|
| 60 |
-
static const strstate frozen; // exposition only
|
| 61 |
-
strstate strmode; // exposition only
|
| 62 |
-
streamsize alsize; // exposition only
|
| 63 |
-
void* (*palloc)(size_t); // exposition only
|
| 64 |
-
void (*pfree)(void*); // exposition only
|
| 65 |
-
};
|
| 66 |
-
}
|
| 67 |
-
```
|
| 68 |
-
|
| 69 |
-
The class `strstreambuf` associates the input sequence, and possibly the
|
| 70 |
-
output sequence, with an object of some *character* array type, whose
|
| 71 |
-
elements store arbitrary values. The array object has several
|
| 72 |
-
attributes.
|
| 73 |
-
|
| 74 |
-
[*Note 1*:
|
| 75 |
-
|
| 76 |
-
For the sake of exposition, these are represented as elements of a
|
| 77 |
-
bitmask type (indicated here as `T1`) called `strstate`. The elements
|
| 78 |
-
are:
|
| 79 |
-
|
| 80 |
-
- `allocated`, set when a dynamic array object has been allocated, and
|
| 81 |
-
hence will be freed by the destructor for the `strstreambuf` object;
|
| 82 |
-
- `constant`, set when the array object has `const` elements, so the
|
| 83 |
-
output sequence cannot be written;
|
| 84 |
-
- `dynamic`, set when the array object is allocated (or reallocated) as
|
| 85 |
-
necessary to hold a character sequence that can change in length;
|
| 86 |
-
- `frozen`, set when the program has requested that the array object not
|
| 87 |
-
be altered, reallocated, or freed.
|
| 88 |
-
|
| 89 |
-
— *end note*]
|
| 90 |
-
|
| 91 |
-
[*Note 2*:
|
| 92 |
-
|
| 93 |
-
For the sake of exposition, the maintained data is presented here as:
|
| 94 |
-
|
| 95 |
-
- `strstate strmode`, the attributes of the array object associated with
|
| 96 |
-
the `strstreambuf` object;
|
| 97 |
-
- `int alsize`, the suggested minimum size for a dynamic array object;
|
| 98 |
-
- `void* (*palloc)(size_t)`, points to the function to call to allocate
|
| 99 |
-
a dynamic array object;
|
| 100 |
-
- `void (*pfree)(void*)`, points to the function to call to free a
|
| 101 |
-
dynamic array object.
|
| 102 |
-
|
| 103 |
-
— *end note*]
|
| 104 |
-
|
| 105 |
-
Each object of class `strstreambuf` has a *seekable area*, delimited by
|
| 106 |
-
the pointers `seeklow` and `seekhigh`. If `gnext` is a null pointer, the
|
| 107 |
-
seekable area is undefined. Otherwise, `seeklow` equals `gbeg` and
|
| 108 |
-
`seekhigh` is either `pend`, if `pend` is not a null pointer, or `gend`.
|
| 109 |
-
|
| 110 |
-
#### `strstreambuf` constructors <a id="depr.strstreambuf.cons">[[depr.strstreambuf.cons]]</a>
|
| 111 |
-
|
| 112 |
-
``` cpp
|
| 113 |
-
explicit strstreambuf(streamsize alsize_arg);
|
| 114 |
-
```
|
| 115 |
-
|
| 116 |
-
*Effects:* Initializes the base class with `streambuf()`. The
|
| 117 |
-
postconditions of this function are indicated in
|
| 118 |
-
[[depr.strstreambuf.cons.sz]].
|
| 119 |
-
|
| 120 |
-
**Table: `strstreambuf(streamsize)` effects** <a id="depr.strstreambuf.cons.sz">[depr.strstreambuf.cons.sz]</a>
|
| 121 |
-
|
| 122 |
-
| Element | Value |
|
| 123 |
-
| --------- | -------------- |
|
| 124 |
-
| `strmode` | `dynamic` |
|
| 125 |
-
| `alsize` | `alsize_arg` |
|
| 126 |
-
| `palloc` | a null pointer |
|
| 127 |
-
| `pfree` | a null pointer |
|
| 128 |
-
|
| 129 |
-
``` cpp
|
| 130 |
-
strstreambuf(void* (*palloc_arg)(size_t), void (*pfree_arg)(void*));
|
| 131 |
-
```
|
| 132 |
-
|
| 133 |
-
*Effects:* Initializes the base class with `streambuf()`. The
|
| 134 |
-
postconditions of this function are indicated in
|
| 135 |
-
[[depr.strstreambuf.cons.alloc]].
|
| 136 |
-
|
| 137 |
-
**Table: `strstreambuf(void* (*)(size_t), void (*)(void*))` effects** <a id="depr.strstreambuf.cons.alloc">[depr.strstreambuf.cons.alloc]</a>
|
| 138 |
-
|
| 139 |
-
| Element | Value |
|
| 140 |
-
| --------- | -------------------- |
|
| 141 |
-
| `strmode` | `dynamic` |
|
| 142 |
-
| `alsize` | an unspecified value |
|
| 143 |
-
| `palloc` | `palloc_arg` |
|
| 144 |
-
| `pfree` | `pfree_arg` |
|
| 145 |
-
|
| 146 |
-
``` cpp
|
| 147 |
-
strstreambuf(char* gnext_arg, streamsize n, char* pbeg_arg = nullptr);
|
| 148 |
-
strstreambuf(signed char* gnext_arg, streamsize n,
|
| 149 |
-
signed char* pbeg_arg = nullptr);
|
| 150 |
-
strstreambuf(unsigned char* gnext_arg, streamsize n,
|
| 151 |
-
unsigned char* pbeg_arg = nullptr);
|
| 152 |
-
```
|
| 153 |
-
|
| 154 |
-
*Effects:* Initializes the base class with `streambuf()`. The
|
| 155 |
-
postconditions of this function are indicated in
|
| 156 |
-
[[depr.strstreambuf.cons.ptr]].
|
| 157 |
-
|
| 158 |
-
**Table: `strstreambuf(charT*, streamsize, charT*)` effects** <a id="depr.strstreambuf.cons.ptr">[depr.strstreambuf.cons.ptr]</a>
|
| 159 |
-
|
| 160 |
-
| Element | Value |
|
| 161 |
-
| --------- | -------------------- |
|
| 162 |
-
| `strmode` | 0 |
|
| 163 |
-
| `alsize` | an unspecified value |
|
| 164 |
-
| `palloc` | a null pointer |
|
| 165 |
-
| `pfree` | a null pointer |
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
`gnext_arg` shall point to the first element of an array object whose
|
| 169 |
-
number of elements `N` is determined as follows:
|
| 170 |
-
|
| 171 |
-
- If `n > 0`, `N` is `n`.
|
| 172 |
-
- If `n == 0`, `N` is `std::strlen(gnext_arg)`.
|
| 173 |
-
- If `n < 0`, `N` is `INT_MAX`.[^1]
|
| 174 |
-
|
| 175 |
-
If `pbeg_arg` is a null pointer, the function executes:
|
| 176 |
-
|
| 177 |
-
``` cpp
|
| 178 |
-
setg(gnext_arg, gnext_arg, gnext_arg + N);
|
| 179 |
-
```
|
| 180 |
-
|
| 181 |
-
Otherwise, the function executes:
|
| 182 |
-
|
| 183 |
-
``` cpp
|
| 184 |
-
setg(gnext_arg, gnext_arg, pbeg_arg);
|
| 185 |
-
setp(pbeg_arg, pbeg_arg + N);
|
| 186 |
-
```
|
| 187 |
-
|
| 188 |
-
``` cpp
|
| 189 |
-
strstreambuf(const char* gnext_arg, streamsize n);
|
| 190 |
-
strstreambuf(const signed char* gnext_arg, streamsize n);
|
| 191 |
-
strstreambuf(const unsigned char* gnext_arg, streamsize n);
|
| 192 |
-
```
|
| 193 |
-
|
| 194 |
-
*Effects:* Behaves the same as `strstreambuf((char*)gnext_arg,n)`,
|
| 195 |
-
except that the constructor also sets `constant` in `strmode`.
|
| 196 |
-
|
| 197 |
-
``` cpp
|
| 198 |
-
virtual ~strstreambuf();
|
| 199 |
-
```
|
| 200 |
-
|
| 201 |
-
*Effects:* Destroys an object of class `strstreambuf`. The function
|
| 202 |
-
frees the dynamically allocated array object only if
|
| 203 |
-
`(strmode & allocated) != 0` and `(strmode & frozen) == 0`.
|
| 204 |
-
([[depr.strstreambuf.virtuals]] describes how a dynamically allocated
|
| 205 |
-
array object is freed.)
|
| 206 |
-
|
| 207 |
-
#### Member functions <a id="depr.strstreambuf.members">[[depr.strstreambuf.members]]</a>
|
| 208 |
-
|
| 209 |
-
``` cpp
|
| 210 |
-
void freeze(bool freezefl = true);
|
| 211 |
-
```
|
| 212 |
-
|
| 213 |
-
*Effects:* If `strmode & dynamic` is nonzero, alters the freeze status
|
| 214 |
-
of the dynamic array object as follows:
|
| 215 |
-
|
| 216 |
-
- If `freezefl` is `true`, the function sets `frozen` in `strmode`.
|
| 217 |
-
- Otherwise, it clears `frozen` in `strmode`.
|
| 218 |
-
|
| 219 |
-
``` cpp
|
| 220 |
-
char* str();
|
| 221 |
-
```
|
| 222 |
-
|
| 223 |
-
*Effects:* Calls `freeze()`, then returns the beginning pointer for the
|
| 224 |
-
input sequence, `gbeg`.
|
| 225 |
-
|
| 226 |
-
*Remarks:* The return value can be a null pointer.
|
| 227 |
-
|
| 228 |
-
``` cpp
|
| 229 |
-
int pcount() const;
|
| 230 |
-
```
|
| 231 |
-
|
| 232 |
-
*Effects:* If the next pointer for the output sequence, `pnext`, is a
|
| 233 |
-
null pointer, returns zero. Otherwise, returns the current effective
|
| 234 |
-
length of the array object as the next pointer minus the beginning
|
| 235 |
-
pointer for the output sequence, `pnext - pbeg`.
|
| 236 |
-
|
| 237 |
-
#### `strstreambuf` overridden virtual functions <a id="depr.strstreambuf.virtuals">[[depr.strstreambuf.virtuals]]</a>
|
| 238 |
-
|
| 239 |
-
``` cpp
|
| 240 |
-
int_type overflow(int_type c = EOF) override;
|
| 241 |
-
```
|
| 242 |
-
|
| 243 |
-
*Effects:* Appends the character designated by `c` to the output
|
| 244 |
-
sequence, if possible, in one of two ways:
|
| 245 |
-
|
| 246 |
-
- If `c != EOF` and if either the output sequence has a write position
|
| 247 |
-
available or the function makes a write position available (as
|
| 248 |
-
described below), assigns `c` to `*pnext++`. Returns
|
| 249 |
-
`(unsigned char)c`.
|
| 250 |
-
- If `c == EOF`, there is no character to append. Returns a value other
|
| 251 |
-
than `EOF`.
|
| 252 |
-
|
| 253 |
-
Returns `EOF` to indicate failure.
|
| 254 |
-
|
| 255 |
-
*Remarks:* The function can alter the number of write positions
|
| 256 |
-
available as a result of any call.
|
| 257 |
-
|
| 258 |
-
To make a write position available, the function reallocates (or
|
| 259 |
-
initially allocates) an array object with a sufficient number of
|
| 260 |
-
elements `n` to hold the current array object (if any), plus at least
|
| 261 |
-
one additional write position. How many additional write positions are
|
| 262 |
-
made available is otherwise unspecified. If `palloc` is not a null
|
| 263 |
-
pointer, the function calls `(*palloc)(n)` to allocate the new dynamic
|
| 264 |
-
array object. Otherwise, it evaluates the expression `new charT[n]`. In
|
| 265 |
-
either case, if the allocation fails, the function returns `EOF`.
|
| 266 |
-
Otherwise, it sets `allocated` in `strmode`.
|
| 267 |
-
|
| 268 |
-
To free a previously existing dynamic array object whose first element
|
| 269 |
-
address is `p`: If `pfree` is not a null pointer, the function calls
|
| 270 |
-
`(*pfree)(p)`. Otherwise, it evaluates the expression `delete[]p`.
|
| 271 |
-
|
| 272 |
-
If `(strmode & dynamic) == 0`, or if `(strmode & frozen) != 0`, the
|
| 273 |
-
function cannot extend the array (reallocate it with greater length) to
|
| 274 |
-
make a write position available.
|
| 275 |
-
|
| 276 |
-
*Recommended practice:* An implementation should consider `alsize` in
|
| 277 |
-
making the decision how many additional write positions to make
|
| 278 |
-
available.
|
| 279 |
-
|
| 280 |
-
``` cpp
|
| 281 |
-
int_type pbackfail(int_type c = EOF) override;
|
| 282 |
-
```
|
| 283 |
-
|
| 284 |
-
Puts back the character designated by `c` to the input sequence, if
|
| 285 |
-
possible, in one of three ways:
|
| 286 |
-
|
| 287 |
-
- If `c != EOF`, if the input sequence has a putback position available,
|
| 288 |
-
and if `(char)c == gnext[-1]`, assigns `gnext - 1` to `gnext`. Returns
|
| 289 |
-
`c`.
|
| 290 |
-
- If `c != EOF`, if the input sequence has a putback position available,
|
| 291 |
-
and if `strmode & constant` is zero, assigns `c` to `*–gnext`. Returns
|
| 292 |
-
`c`.
|
| 293 |
-
- If `c == EOF` and if the input sequence has a putback position
|
| 294 |
-
available, assigns `gnext - 1` to `gnext`. Returns a value other than
|
| 295 |
-
`EOF`.
|
| 296 |
-
|
| 297 |
-
Returns `EOF` to indicate failure.
|
| 298 |
-
|
| 299 |
-
*Remarks:* If the function can succeed in more than one of these ways,
|
| 300 |
-
it is unspecified which way is chosen. The function can alter the number
|
| 301 |
-
of putback positions available as a result of any call.
|
| 302 |
-
|
| 303 |
-
``` cpp
|
| 304 |
-
int_type underflow() override;
|
| 305 |
-
```
|
| 306 |
-
|
| 307 |
-
*Effects:* Reads a character from the *input sequence*, if possible,
|
| 308 |
-
without moving the stream position past it, as follows:
|
| 309 |
-
|
| 310 |
-
- If the input sequence has a read position available, the function
|
| 311 |
-
signals success by returning `(unsigned char)*gnext`.
|
| 312 |
-
- Otherwise, if the current write next pointer `pnext` is not a null
|
| 313 |
-
pointer and is greater than the current read end pointer `gend`, makes
|
| 314 |
-
a *read position* available by assigning to `gend` a value greater
|
| 315 |
-
than `gnext` and no greater than `pnext`. Returns
|
| 316 |
-
`(unsigned char)*gnext`.
|
| 317 |
-
|
| 318 |
-
Returns `EOF` to indicate failure.
|
| 319 |
-
|
| 320 |
-
*Remarks:* The function can alter the number of read positions available
|
| 321 |
-
as a result of any call.
|
| 322 |
-
|
| 323 |
-
``` cpp
|
| 324 |
-
pos_type seekoff(off_type off, seekdir way, openmode which = in | out) override;
|
| 325 |
-
```
|
| 326 |
-
|
| 327 |
-
*Effects:* Alters the stream position within one of the controlled
|
| 328 |
-
sequences, if possible, as indicated in
|
| 329 |
-
[[depr.strstreambuf.seekoff.pos]].
|
| 330 |
-
|
| 331 |
-
**Table: `seekoff` positioning** <a id="depr.strstreambuf.seekoff.pos">[depr.strstreambuf.seekoff.pos]</a>
|
| 332 |
-
|
| 333 |
-
| Conditions | Result |
|
| 334 |
-
| -------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------- |
|
| 335 |
-
| `(which & ios::in) != 0` | positions the input sequence |
|
| 336 |
-
| `(which & ios::out) != 0` | positions the output sequence |
|
| 337 |
-
| `(which & (ios::in | ios::out)) ==`<br> `(ios::in | ios::out)` and either<br> `way == ios::beg` or `way == ios::end` | positions both the input and the output sequences |
|
| 338 |
-
| Otherwise | the positioning operation fails. |
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
For a sequence to be positioned, if its next pointer is a null pointer,
|
| 342 |
-
the positioning operation fails. Otherwise, the function determines
|
| 343 |
-
`newoff` as indicated in [[depr.strstreambuf.seekoff.newoff]].
|
| 344 |
-
|
| 345 |
-
**Table: `newoff` values** <a id="depr.strstreambuf.seekoff.newoff">[depr.strstreambuf.seekoff.newoff]</a>
|
| 346 |
-
|
| 347 |
-
| Condition | `newoff` Value |
|
| 348 |
-
| ----------------- | -------------------------------------------------------------- |
|
| 349 |
-
| `way == ios::beg` | 0 |
|
| 350 |
-
| `way == ios::cur` | the next pointer minus the beginning pointer (`xnext - xbeg`). |
|
| 351 |
-
| `way == ios::end` | `seekhigh` minus the beginning pointer (`seekhigh - xbeg`). |
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
If `(newoff + off) < (seeklow - xbeg)` or
|
| 355 |
-
`(seekhigh - xbeg) < (newoff + off)`, the positioning operation fails.
|
| 356 |
-
Otherwise, the function assigns `xbeg + newoff + off` to the next
|
| 357 |
-
pointer `xnext`.
|
| 358 |
-
|
| 359 |
-
*Returns:* `pos_type(newoff)`, constructed from the resultant offset
|
| 360 |
-
`newoff` (of type `off_type`), that stores the resultant stream
|
| 361 |
-
position, if possible. If the positioning operation fails, or if the
|
| 362 |
-
constructed object cannot represent the resultant stream position, the
|
| 363 |
-
return value is `pos_type(off_type(-1))`.
|
| 364 |
-
|
| 365 |
-
``` cpp
|
| 366 |
-
pos_type seekpos(pos_type sp, ios_base::openmode which = ios_base::in | ios_base::out) override;
|
| 367 |
-
```
|
| 368 |
-
|
| 369 |
-
*Effects:* Alters the stream position within one of the controlled
|
| 370 |
-
sequences, if possible, to correspond to the stream position stored in
|
| 371 |
-
`sp` (as described below).
|
| 372 |
-
|
| 373 |
-
- If `(which & ios::in) != 0`, positions the input sequence.
|
| 374 |
-
- If `(which & ios::out) != 0`, positions the output sequence.
|
| 375 |
-
- If the function positions neither sequence, the positioning operation
|
| 376 |
-
fails.
|
| 377 |
-
|
| 378 |
-
For a sequence to be positioned, if its next pointer is a null pointer,
|
| 379 |
-
the positioning operation fails. Otherwise, the function determines
|
| 380 |
-
`newoff` from `sp.offset()`:
|
| 381 |
-
|
| 382 |
-
- If `newoff` is an invalid stream position, has a negative value, or
|
| 383 |
-
has a value greater than (`seekhigh - seeklow`), the positioning
|
| 384 |
-
operation fails
|
| 385 |
-
- Otherwise, the function adds `newoff` to the beginning pointer `xbeg`
|
| 386 |
-
and stores the result in the next pointer `xnext`.
|
| 387 |
-
|
| 388 |
-
*Returns:* `pos_type(newoff)`, constructed from the resultant offset
|
| 389 |
-
`newoff` (of type `off_type`), that stores the resultant stream
|
| 390 |
-
position, if possible. If the positioning operation fails, or if the
|
| 391 |
-
constructed object cannot represent the resultant stream position, the
|
| 392 |
-
return value is `pos_type(off_type(-1))`.
|
| 393 |
-
|
| 394 |
-
``` cpp
|
| 395 |
-
streambuf<char>* setbuf(char* s, streamsize n) override;
|
| 396 |
-
```
|
| 397 |
-
|
| 398 |
-
*Effects:* Behavior is *implementation-defined*, except that
|
| 399 |
-
`setbuf(0, 0)` has no effect.
|
| 400 |
-
|
| 401 |
-
### Class `istrstream` <a id="depr.istrstream">[[depr.istrstream]]</a>
|
| 402 |
-
|
| 403 |
-
#### General <a id="depr.istrstream.general">[[depr.istrstream.general]]</a>
|
| 404 |
-
|
| 405 |
-
``` cpp
|
| 406 |
-
namespace std {
|
| 407 |
-
class istrstream : public basic_istream<char> {
|
| 408 |
-
public:
|
| 409 |
-
explicit istrstream(const char* s);
|
| 410 |
-
explicit istrstream(char* s);
|
| 411 |
-
istrstream(const char* s, streamsize n);
|
| 412 |
-
istrstream(char* s, streamsize n);
|
| 413 |
-
virtual ~istrstream();
|
| 414 |
-
|
| 415 |
-
strstreambuf* rdbuf() const;
|
| 416 |
-
char* str();
|
| 417 |
-
private:
|
| 418 |
-
strstreambuf sb; // exposition only
|
| 419 |
-
};
|
| 420 |
-
}
|
| 421 |
-
```
|
| 422 |
-
|
| 423 |
-
The class `istrstream` supports the reading of objects of class
|
| 424 |
-
`strstreambuf`. It supplies a `strstreambuf` object to control the
|
| 425 |
-
associated array object. For the sake of exposition, the maintained data
|
| 426 |
-
is presented here as:
|
| 427 |
-
|
| 428 |
-
- `sb`, the `strstreambuf` object.
|
| 429 |
-
|
| 430 |
-
#### `istrstream` constructors <a id="depr.istrstream.cons">[[depr.istrstream.cons]]</a>
|
| 431 |
-
|
| 432 |
-
``` cpp
|
| 433 |
-
explicit istrstream(const char* s);
|
| 434 |
-
explicit istrstream(char* s);
|
| 435 |
-
```
|
| 436 |
-
|
| 437 |
-
*Effects:* Initializes the base class with `istream(&sb)` and `sb` with
|
| 438 |
-
`strstreambuf(s, 0)`. `s` shall designate the first element of an NTBS.
|
| 439 |
-
|
| 440 |
-
``` cpp
|
| 441 |
-
istrstream(const char* s, streamsize n);
|
| 442 |
-
istrstream(char* s, streamsize n);
|
| 443 |
-
```
|
| 444 |
-
|
| 445 |
-
*Effects:* Initializes the base class with `istream(&sb)` and `sb` with
|
| 446 |
-
`strstreambuf(s, n)`. `s` shall designate the first element of an array
|
| 447 |
-
whose length is `n` elements, and `n` shall be greater than zero.
|
| 448 |
-
|
| 449 |
-
#### Member functions <a id="depr.istrstream.members">[[depr.istrstream.members]]</a>
|
| 450 |
-
|
| 451 |
-
``` cpp
|
| 452 |
-
strstreambuf* rdbuf() const;
|
| 453 |
-
```
|
| 454 |
-
|
| 455 |
-
*Returns:* `const_cast<strstreambuf*>(&sb)`.
|
| 456 |
-
|
| 457 |
-
``` cpp
|
| 458 |
-
char* str();
|
| 459 |
-
```
|
| 460 |
-
|
| 461 |
-
*Returns:* `rdbuf()->str()`.
|
| 462 |
-
|
| 463 |
-
### Class `ostrstream` <a id="depr.ostrstream">[[depr.ostrstream]]</a>
|
| 464 |
-
|
| 465 |
-
#### General <a id="depr.ostrstream.general">[[depr.ostrstream.general]]</a>
|
| 466 |
-
|
| 467 |
-
``` cpp
|
| 468 |
-
namespace std {
|
| 469 |
-
class ostrstream : public basic_ostream<char> {
|
| 470 |
-
public:
|
| 471 |
-
ostrstream();
|
| 472 |
-
ostrstream(char* s, int n, ios_base::openmode mode = ios_base::out);
|
| 473 |
-
virtual ~ostrstream();
|
| 474 |
-
|
| 475 |
-
strstreambuf* rdbuf() const;
|
| 476 |
-
void freeze(bool freezefl = true);
|
| 477 |
-
char* str();
|
| 478 |
-
int pcount() const;
|
| 479 |
-
private:
|
| 480 |
-
strstreambuf sb; // exposition only
|
| 481 |
-
};
|
| 482 |
-
}
|
| 483 |
-
```
|
| 484 |
-
|
| 485 |
-
The class `ostrstream` supports the writing of objects of class
|
| 486 |
-
`strstreambuf`. It supplies a `strstreambuf` object to control the
|
| 487 |
-
associated array object. For the sake of exposition, the maintained data
|
| 488 |
-
is presented here as:
|
| 489 |
-
|
| 490 |
-
- `sb`, the `strstreambuf` object.
|
| 491 |
-
|
| 492 |
-
#### `ostrstream` constructors <a id="depr.ostrstream.cons">[[depr.ostrstream.cons]]</a>
|
| 493 |
-
|
| 494 |
-
``` cpp
|
| 495 |
-
ostrstream();
|
| 496 |
-
```
|
| 497 |
-
|
| 498 |
-
*Effects:* Initializes the base class with `ostream(&sb)` and `sb` with
|
| 499 |
-
`strstreambuf()`.
|
| 500 |
-
|
| 501 |
-
``` cpp
|
| 502 |
-
ostrstream(char* s, int n, ios_base::openmode mode = ios_base::out);
|
| 503 |
-
```
|
| 504 |
-
|
| 505 |
-
*Effects:* Initializes the base class with `ostream(&sb)`, and `sb` with
|
| 506 |
-
one of two constructors:
|
| 507 |
-
|
| 508 |
-
- If `(mode & app) == 0`, then `s` shall designate the first element of
|
| 509 |
-
an array of `n` elements. The constructor is `strstreambuf(s, n, s)`.
|
| 510 |
-
- If `(mode & app) != 0`, then `s` shall designate the first element of
|
| 511 |
-
an array of `n` elements that contains an NTBS whose first element is
|
| 512 |
-
designated by `s`. The constructor is
|
| 513 |
-
`strstreambuf(s, n, s + std::strlen(s))`.[^2]
|
| 514 |
-
|
| 515 |
-
#### Member functions <a id="depr.ostrstream.members">[[depr.ostrstream.members]]</a>
|
| 516 |
-
|
| 517 |
-
``` cpp
|
| 518 |
-
strstreambuf* rdbuf() const;
|
| 519 |
-
```
|
| 520 |
-
|
| 521 |
-
*Returns:* `(strstreambuf*)&sb`.
|
| 522 |
-
|
| 523 |
-
``` cpp
|
| 524 |
-
void freeze(bool freezefl = true);
|
| 525 |
-
```
|
| 526 |
-
|
| 527 |
-
*Effects:* Calls `rdbuf()->freeze(freezefl)`.
|
| 528 |
-
|
| 529 |
-
``` cpp
|
| 530 |
-
char* str();
|
| 531 |
-
```
|
| 532 |
-
|
| 533 |
-
*Returns:* `rdbuf()->str()`.
|
| 534 |
-
|
| 535 |
-
``` cpp
|
| 536 |
-
int pcount() const;
|
| 537 |
-
```
|
| 538 |
-
|
| 539 |
-
*Returns:* `rdbuf()->pcount()`.
|
| 540 |
-
|
| 541 |
-
### Class `strstream` <a id="depr.strstream">[[depr.strstream]]</a>
|
| 542 |
-
|
| 543 |
-
#### General <a id="depr.strstream.general">[[depr.strstream.general]]</a>
|
| 544 |
-
|
| 545 |
-
``` cpp
|
| 546 |
-
namespace std {
|
| 547 |
-
class strstream
|
| 548 |
-
: public basic_iostream<char> {
|
| 549 |
-
public:
|
| 550 |
-
// types
|
| 551 |
-
using char_type = char;
|
| 552 |
-
using int_type = char_traits<char>::int_type;
|
| 553 |
-
using pos_type = char_traits<char>::pos_type;
|
| 554 |
-
using off_type = char_traits<char>::off_type;
|
| 555 |
-
|
| 556 |
-
// constructors/destructor
|
| 557 |
-
strstream();
|
| 558 |
-
strstream(char* s, int n,
|
| 559 |
-
ios_base::openmode mode = ios_base::in|ios_base::out);
|
| 560 |
-
virtual ~strstream();
|
| 561 |
-
|
| 562 |
-
// members
|
| 563 |
-
strstreambuf* rdbuf() const;
|
| 564 |
-
void freeze(bool freezefl = true);
|
| 565 |
-
int pcount() const;
|
| 566 |
-
char* str();
|
| 567 |
-
|
| 568 |
-
private:
|
| 569 |
-
strstreambuf sb; // exposition only
|
| 570 |
-
};
|
| 571 |
-
}
|
| 572 |
-
```
|
| 573 |
-
|
| 574 |
-
The class `strstream` supports reading and writing from objects of class
|
| 575 |
-
`strstreambuf`. It supplies a `strstreambuf` object to control the
|
| 576 |
-
associated array object. For the sake of exposition, the maintained data
|
| 577 |
-
is presented here as:
|
| 578 |
-
|
| 579 |
-
- `sb`, the `strstreambuf` object.
|
| 580 |
-
|
| 581 |
-
#### `strstream` constructors <a id="depr.strstream.cons">[[depr.strstream.cons]]</a>
|
| 582 |
-
|
| 583 |
-
``` cpp
|
| 584 |
-
strstream();
|
| 585 |
-
```
|
| 586 |
-
|
| 587 |
-
*Effects:* Initializes the base class with `iostream(&sb)`.
|
| 588 |
-
|
| 589 |
-
``` cpp
|
| 590 |
-
strstream(char* s, int n,
|
| 591 |
-
ios_base::openmode mode = ios_base::in|ios_base::out);
|
| 592 |
-
```
|
| 593 |
-
|
| 594 |
-
*Effects:* Initializes the base class with `iostream(&sb)`, and `sb`
|
| 595 |
-
with one of the two constructors:
|
| 596 |
-
|
| 597 |
-
- If `(mode & app) == 0`, then `s` shall designate the first element of
|
| 598 |
-
an array of `n` elements. The constructor is `strstreambuf(s,n,s)`.
|
| 599 |
-
- If `(mode & app) != 0`, then `s` shall designate the first element of
|
| 600 |
-
an array of `n` elements that contains an NTBS whose first element is
|
| 601 |
-
designated by `s`. The constructor is
|
| 602 |
-
`strstreambuf(s,n,s + std::strlen(s))`.
|
| 603 |
-
|
| 604 |
-
#### `strstream` destructor <a id="depr.strstream.dest">[[depr.strstream.dest]]</a>
|
| 605 |
-
|
| 606 |
-
``` cpp
|
| 607 |
-
virtual ~strstream();
|
| 608 |
-
```
|
| 609 |
-
|
| 610 |
-
*Effects:* Destroys an object of class `strstream`.
|
| 611 |
-
|
| 612 |
-
#### `strstream` operations <a id="depr.strstream.oper">[[depr.strstream.oper]]</a>
|
| 613 |
-
|
| 614 |
-
``` cpp
|
| 615 |
-
strstreambuf* rdbuf() const;
|
| 616 |
-
```
|
| 617 |
-
|
| 618 |
-
*Returns:* `const_cast<strstreambuf*>(&sb)`.
|
| 619 |
-
|
| 620 |
-
``` cpp
|
| 621 |
-
void freeze(bool freezefl = true);
|
| 622 |
-
```
|
| 623 |
-
|
| 624 |
-
*Effects:* Calls `rdbuf()->freeze(freezefl)`.
|
| 625 |
-
|
| 626 |
-
``` cpp
|
| 627 |
-
char* str();
|
| 628 |
-
```
|
| 629 |
-
|
| 630 |
-
*Returns:* `rdbuf()->str()`.
|
| 631 |
-
|
| 632 |
-
``` cpp
|
| 633 |
-
int pcount() const;
|
| 634 |
-
```
|
| 635 |
-
|
| 636 |
-
*Returns:* `rdbuf()->pcount()`.
|
| 637 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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