tmp/tmpvtpsplw2/{from.md → to.md}
RENAMED
|
@@ -4,49 +4,48 @@
|
|
| 4 |
namespace std {
|
| 5 |
template <class charT, class traits = char_traits<charT>,
|
| 6 |
class Allocator = allocator<charT>>
|
| 7 |
class basic_stringbuf : public basic_streambuf<charT, traits> {
|
| 8 |
public:
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
|
| 16 |
-
// [stringbuf.cons]
|
| 17 |
-
explicit basic_stringbuf(
|
| 18 |
-
|
| 19 |
-
explicit basic_stringbuf
|
| 20 |
-
|
| 21 |
ios_base::openmode which = ios_base::in | ios_base::out);
|
| 22 |
basic_stringbuf(const basic_stringbuf& rhs) = delete;
|
| 23 |
basic_stringbuf(basic_stringbuf&& rhs);
|
| 24 |
|
| 25 |
-
// [stringbuf.assign]
|
| 26 |
basic_stringbuf& operator=(const basic_stringbuf& rhs) = delete;
|
| 27 |
basic_stringbuf& operator=(basic_stringbuf&& rhs);
|
| 28 |
void swap(basic_stringbuf& rhs);
|
| 29 |
|
| 30 |
-
// [stringbuf.members]
|
| 31 |
basic_string<charT, traits, Allocator> str() const;
|
| 32 |
void str(const basic_string<charT, traits, Allocator>& s);
|
| 33 |
|
| 34 |
protected:
|
| 35 |
-
// [stringbuf.virtuals]
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
|
| 41 |
-
|
| 42 |
-
virtual pos_type seekoff(off_type off, ios_base::seekdir way,
|
| 43 |
ios_base::openmode which
|
| 44 |
-
|
| 45 |
-
|
| 46 |
ios_base::openmode which
|
| 47 |
-
|
| 48 |
|
| 49 |
private:
|
| 50 |
ios_base::openmode mode; // exposition only
|
| 51 |
};
|
| 52 |
|
|
@@ -68,22 +67,23 @@ For the sake of exposition, the maintained data is presented here as:
|
|
| 68 |
read, and `out` set if the output sequence can be written.
|
| 69 |
|
| 70 |
#### `basic_stringbuf` constructors <a id="stringbuf.cons">[[stringbuf.cons]]</a>
|
| 71 |
|
| 72 |
``` cpp
|
| 73 |
-
explicit basic_stringbuf(
|
| 74 |
-
|
| 75 |
```
|
| 76 |
|
| 77 |
*Effects:* Constructs an object of class `basic_stringbuf`, initializing
|
| 78 |
the base class with `basic_streambuf()` ([[streambuf.cons]]), and
|
| 79 |
initializing `mode` with `which`.
|
| 80 |
|
| 81 |
-
`str() == ""`.
|
| 82 |
|
| 83 |
``` cpp
|
| 84 |
-
explicit basic_stringbuf(
|
|
|
|
| 85 |
ios_base::openmode which = ios_base::in | ios_base::out);
|
| 86 |
```
|
| 87 |
|
| 88 |
*Effects:* Constructs an object of class `basic_stringbuf`, initializing
|
| 89 |
the base class with `basic_streambuf()` ([[streambuf.cons]]), and
|
|
@@ -138,11 +138,11 @@ void swap(basic_stringbuf& rhs);
|
|
| 138 |
template <class charT, class traits, class Allocator>
|
| 139 |
void swap(basic_stringbuf<charT, traits, Allocator>& x,
|
| 140 |
basic_stringbuf<charT, traits, Allocator>& y);
|
| 141 |
```
|
| 142 |
|
| 143 |
-
*Effects:* `x.swap(y)`.
|
| 144 |
|
| 145 |
#### Member functions <a id="stringbuf.members">[[stringbuf.members]]</a>
|
| 146 |
|
| 147 |
``` cpp
|
| 148 |
basic_string<charT, traits, Allocator> str() const;
|
|
@@ -151,11 +151,11 @@ basic_string<charT,traits,Allocator> str() const;
|
|
| 151 |
*Returns:* A `basic_string` object whose content is equal to the
|
| 152 |
`basic_stringbuf` underlying character sequence. If the
|
| 153 |
`basic_stringbuf` was created only in input mode, the resultant
|
| 154 |
`basic_string` contains the character sequence in the range \[`eback()`,
|
| 155 |
`egptr()`). If the `basic_stringbuf` was created with
|
| 156 |
-
`which & ios_base::out` being
|
| 157 |
contains the character sequence in the range \[`pbase()`, `high_mark`),
|
| 158 |
where `high_mark` represents the position one past the highest
|
| 159 |
initialized character in the buffer. Characters can be initialized by
|
| 160 |
writing to the stream, by constructing the `basic_stringbuf` with a
|
| 161 |
`basic_string`, or by calling the `str(basic_string)` member function.
|
|
@@ -172,31 +172,31 @@ void str(const basic_string<charT,traits,Allocator>& s);
|
|
| 172 |
|
| 173 |
*Effects:* Copies the content of `s` into the `basic_stringbuf`
|
| 174 |
underlying character sequence and initializes the input and output
|
| 175 |
sequences according to `mode`.
|
| 176 |
|
| 177 |
-
*Postconditions:* If `mode & ios_base::out` is
|
| 178 |
-
the first underlying character and `epptr()` `>= pbase() + s.size()`
|
| 179 |
-
holds; in addition, if `mode & ios_base::ate` is
|
| 180 |
`pptr() == pbase() + s.size()` holds, otherwise `pptr() == pbase()` is
|
| 181 |
-
true. If `mode & ios_base::in` is
|
| 182 |
-
underlying character, and both `gptr() == eback()` and
|
| 183 |
`egptr() == eback() + s.size()` hold.
|
| 184 |
|
| 185 |
#### Overridden virtual functions <a id="stringbuf.virtuals">[[stringbuf.virtuals]]</a>
|
| 186 |
|
| 187 |
``` cpp
|
| 188 |
-
int_type underflow();
|
| 189 |
```
|
| 190 |
|
| 191 |
*Returns:* If the input sequence has a read position available, returns
|
| 192 |
`traits::to_int_type(*gptr())`. Otherwise, returns `traits::eof()`. Any
|
| 193 |
character in the underlying buffer which has been initialized is
|
| 194 |
considered to be part of the input sequence.
|
| 195 |
|
| 196 |
``` cpp
|
| 197 |
-
int_type pbackfail(int_type c = traits::eof());
|
| 198 |
```
|
| 199 |
|
| 200 |
*Effects:* Puts back the character designated by `c` to the input
|
| 201 |
sequence, if possible, in one of three ways:
|
| 202 |
|
|
@@ -215,11 +215,11 @@ sequence, if possible, in one of three ways:
|
|
| 215 |
|
| 216 |
*Remarks:* If the function can succeed in more than one of these ways,
|
| 217 |
it is unspecified which way is chosen.
|
| 218 |
|
| 219 |
``` cpp
|
| 220 |
-
int_type overflow(int_type c = traits::eof());
|
| 221 |
```
|
| 222 |
|
| 223 |
*Effects:* Appends the character designated by `c` to the output
|
| 224 |
sequence, if possible, in one of two ways:
|
| 225 |
|
|
@@ -245,11 +245,11 @@ plus at least one additional write position. If
|
|
| 245 |
`egptr()` to point just past the new write position.
|
| 246 |
|
| 247 |
``` cpp
|
| 248 |
pos_type seekoff(off_type off, ios_base::seekdir way,
|
| 249 |
ios_base::openmode which
|
| 250 |
-
= ios_base::in | ios_base::out);
|
| 251 |
```
|
| 252 |
|
| 253 |
*Effects:* Alters the stream position within one of the controlled
|
| 254 |
sequences, if possible, as indicated in
|
| 255 |
Table [[tab:iostreams.seekoff.positioning]].
|
|
@@ -277,23 +277,24 @@ as indicated in Table [[tab:iostreams.newoff.values]].
|
|
| 277 |
| `way == ios_base::cur` | the next pointer minus the beginning pointer (`xnext - xbeg`). |
|
| 278 |
| `way == ios_base::end` | the high mark pointer minus the beginning pointer (`high_mark - xbeg`). |
|
| 279 |
|
| 280 |
|
| 281 |
If `(newoff + off) < 0`, or if `newoff + off` refers to an uninitialized
|
| 282 |
-
character (
|
| 283 |
-
|
| 284 |
-
|
| 285 |
|
| 286 |
*Returns:* `pos_type(newoff)`, constructed from the resultant offset
|
| 287 |
`newoff` (of type `off_type`), that stores the resultant stream
|
| 288 |
position, if possible. If the positioning operation fails, or if the
|
| 289 |
constructed object cannot represent the resultant stream position, the
|
| 290 |
return value is `pos_type(off_type(-1))`.
|
| 291 |
|
| 292 |
``` cpp
|
| 293 |
-
pos_type seekpos(pos_type sp,
|
| 294 |
-
|
|
|
|
| 295 |
```
|
| 296 |
|
| 297 |
*Effects:* Equivalent to `seekoff(off_type(sp), ios_base::beg, which)`.
|
| 298 |
|
| 299 |
*Returns:* `sp` to indicate success, or `pos_type(off_type(-1))` to
|
|
|
|
| 4 |
namespace std {
|
| 5 |
template <class charT, class traits = char_traits<charT>,
|
| 6 |
class Allocator = allocator<charT>>
|
| 7 |
class basic_stringbuf : public basic_streambuf<charT, traits> {
|
| 8 |
public:
|
| 9 |
+
using char_type = charT;
|
| 10 |
+
using int_type = typename traits::int_type;
|
| 11 |
+
using pos_type = typename traits::pos_type;
|
| 12 |
+
using off_type = typename traits::off_type;
|
| 13 |
+
using traits_type = traits;
|
| 14 |
+
using allocator_type = Allocator;
|
| 15 |
|
| 16 |
+
// [stringbuf.cons], constructors
|
| 17 |
+
explicit basic_stringbuf(
|
| 18 |
+
ios_base::openmode which = ios_base::in | ios_base::out);
|
| 19 |
+
explicit basic_stringbuf(
|
| 20 |
+
const basic_string<charT, traits, Allocator>& str,
|
| 21 |
ios_base::openmode which = ios_base::in | ios_base::out);
|
| 22 |
basic_stringbuf(const basic_stringbuf& rhs) = delete;
|
| 23 |
basic_stringbuf(basic_stringbuf&& rhs);
|
| 24 |
|
| 25 |
+
// [stringbuf.assign], assign and swap
|
| 26 |
basic_stringbuf& operator=(const basic_stringbuf& rhs) = delete;
|
| 27 |
basic_stringbuf& operator=(basic_stringbuf&& rhs);
|
| 28 |
void swap(basic_stringbuf& rhs);
|
| 29 |
|
| 30 |
+
// [stringbuf.members], get and set
|
| 31 |
basic_string<charT, traits, Allocator> str() const;
|
| 32 |
void str(const basic_string<charT, traits, Allocator>& s);
|
| 33 |
|
| 34 |
protected:
|
| 35 |
+
// [stringbuf.virtuals], overridden virtual functions
|
| 36 |
+
int_type underflow() override;
|
| 37 |
+
int_type pbackfail(int_type c = traits::eof()) override;
|
| 38 |
+
int_type overflow (int_type c = traits::eof()) override;
|
| 39 |
+
basic_streambuf<charT, traits>* setbuf(charT*, streamsize) override;
|
| 40 |
|
| 41 |
+
pos_type seekoff(off_type off, ios_base::seekdir way,
|
|
|
|
| 42 |
ios_base::openmode which
|
| 43 |
+
= ios_base::in | ios_base::out) override;
|
| 44 |
+
pos_type seekpos(pos_type sp,
|
| 45 |
ios_base::openmode which
|
| 46 |
+
= ios_base::in | ios_base::out) override;
|
| 47 |
|
| 48 |
private:
|
| 49 |
ios_base::openmode mode; // exposition only
|
| 50 |
};
|
| 51 |
|
|
|
|
| 67 |
read, and `out` set if the output sequence can be written.
|
| 68 |
|
| 69 |
#### `basic_stringbuf` constructors <a id="stringbuf.cons">[[stringbuf.cons]]</a>
|
| 70 |
|
| 71 |
``` cpp
|
| 72 |
+
explicit basic_stringbuf(
|
| 73 |
+
ios_base::openmode which = ios_base::in | ios_base::out);
|
| 74 |
```
|
| 75 |
|
| 76 |
*Effects:* Constructs an object of class `basic_stringbuf`, initializing
|
| 77 |
the base class with `basic_streambuf()` ([[streambuf.cons]]), and
|
| 78 |
initializing `mode` with `which`.
|
| 79 |
|
| 80 |
+
*Postconditions:* `str() == ""`.
|
| 81 |
|
| 82 |
``` cpp
|
| 83 |
+
explicit basic_stringbuf(
|
| 84 |
+
const basic_string<charT, traits, Allocator>& s,
|
| 85 |
ios_base::openmode which = ios_base::in | ios_base::out);
|
| 86 |
```
|
| 87 |
|
| 88 |
*Effects:* Constructs an object of class `basic_stringbuf`, initializing
|
| 89 |
the base class with `basic_streambuf()` ([[streambuf.cons]]), and
|
|
|
|
| 138 |
template <class charT, class traits, class Allocator>
|
| 139 |
void swap(basic_stringbuf<charT, traits, Allocator>& x,
|
| 140 |
basic_stringbuf<charT, traits, Allocator>& y);
|
| 141 |
```
|
| 142 |
|
| 143 |
+
*Effects:* As if by `x.swap(y)`.
|
| 144 |
|
| 145 |
#### Member functions <a id="stringbuf.members">[[stringbuf.members]]</a>
|
| 146 |
|
| 147 |
``` cpp
|
| 148 |
basic_string<charT, traits, Allocator> str() const;
|
|
|
|
| 151 |
*Returns:* A `basic_string` object whose content is equal to the
|
| 152 |
`basic_stringbuf` underlying character sequence. If the
|
| 153 |
`basic_stringbuf` was created only in input mode, the resultant
|
| 154 |
`basic_string` contains the character sequence in the range \[`eback()`,
|
| 155 |
`egptr()`). If the `basic_stringbuf` was created with
|
| 156 |
+
`which & ios_base::out` being nonzero then the resultant `basic_string`
|
| 157 |
contains the character sequence in the range \[`pbase()`, `high_mark`),
|
| 158 |
where `high_mark` represents the position one past the highest
|
| 159 |
initialized character in the buffer. Characters can be initialized by
|
| 160 |
writing to the stream, by constructing the `basic_stringbuf` with a
|
| 161 |
`basic_string`, or by calling the `str(basic_string)` member function.
|
|
|
|
| 172 |
|
| 173 |
*Effects:* Copies the content of `s` into the `basic_stringbuf`
|
| 174 |
underlying character sequence and initializes the input and output
|
| 175 |
sequences according to `mode`.
|
| 176 |
|
| 177 |
+
*Postconditions:* If `mode & ios_base::out` is nonzero, `pbase()` points
|
| 178 |
+
to the first underlying character and `epptr()` `>= pbase() + s.size()`
|
| 179 |
+
holds; in addition, if `mode & ios_base::ate` is nonzero,
|
| 180 |
`pptr() == pbase() + s.size()` holds, otherwise `pptr() == pbase()` is
|
| 181 |
+
`true`. If `mode & ios_base::in` is nonzero, `eback()` points to the
|
| 182 |
+
first underlying character, and both `gptr() == eback()` and
|
| 183 |
`egptr() == eback() + s.size()` hold.
|
| 184 |
|
| 185 |
#### Overridden virtual functions <a id="stringbuf.virtuals">[[stringbuf.virtuals]]</a>
|
| 186 |
|
| 187 |
``` cpp
|
| 188 |
+
int_type underflow() override;
|
| 189 |
```
|
| 190 |
|
| 191 |
*Returns:* If the input sequence has a read position available, returns
|
| 192 |
`traits::to_int_type(*gptr())`. Otherwise, returns `traits::eof()`. Any
|
| 193 |
character in the underlying buffer which has been initialized is
|
| 194 |
considered to be part of the input sequence.
|
| 195 |
|
| 196 |
``` cpp
|
| 197 |
+
int_type pbackfail(int_type c = traits::eof()) override;
|
| 198 |
```
|
| 199 |
|
| 200 |
*Effects:* Puts back the character designated by `c` to the input
|
| 201 |
sequence, if possible, in one of three ways:
|
| 202 |
|
|
|
|
| 215 |
|
| 216 |
*Remarks:* If the function can succeed in more than one of these ways,
|
| 217 |
it is unspecified which way is chosen.
|
| 218 |
|
| 219 |
``` cpp
|
| 220 |
+
int_type overflow(int_type c = traits::eof()) override;
|
| 221 |
```
|
| 222 |
|
| 223 |
*Effects:* Appends the character designated by `c` to the output
|
| 224 |
sequence, if possible, in one of two ways:
|
| 225 |
|
|
|
|
| 245 |
`egptr()` to point just past the new write position.
|
| 246 |
|
| 247 |
``` cpp
|
| 248 |
pos_type seekoff(off_type off, ios_base::seekdir way,
|
| 249 |
ios_base::openmode which
|
| 250 |
+
= ios_base::in | ios_base::out) override;
|
| 251 |
```
|
| 252 |
|
| 253 |
*Effects:* Alters the stream position within one of the controlled
|
| 254 |
sequences, if possible, as indicated in
|
| 255 |
Table [[tab:iostreams.seekoff.positioning]].
|
|
|
|
| 277 |
| `way == ios_base::cur` | the next pointer minus the beginning pointer (`xnext - xbeg`). |
|
| 278 |
| `way == ios_base::end` | the high mark pointer minus the beginning pointer (`high_mark - xbeg`). |
|
| 279 |
|
| 280 |
|
| 281 |
If `(newoff + off) < 0`, or if `newoff + off` refers to an uninitialized
|
| 282 |
+
character ([[stringbuf.members]]), the positioning operation fails.
|
| 283 |
+
Otherwise, the function assigns `xbeg + newoff + off` to the next
|
| 284 |
+
pointer `xnext`.
|
| 285 |
|
| 286 |
*Returns:* `pos_type(newoff)`, constructed from the resultant offset
|
| 287 |
`newoff` (of type `off_type`), that stores the resultant stream
|
| 288 |
position, if possible. If the positioning operation fails, or if the
|
| 289 |
constructed object cannot represent the resultant stream position, the
|
| 290 |
return value is `pos_type(off_type(-1))`.
|
| 291 |
|
| 292 |
``` cpp
|
| 293 |
+
pos_type seekpos(pos_type sp,
|
| 294 |
+
ios_base::openmode which
|
| 295 |
+
= ios_base::in | ios_base::out) override;
|
| 296 |
```
|
| 297 |
|
| 298 |
*Effects:* Equivalent to `seekoff(off_type(sp), ios_base::beg, which)`.
|
| 299 |
|
| 300 |
*Returns:* `sp` to indicate success, or `pos_type(off_type(-1))` to
|