tmp/tmph5ezyaz4/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#### General <a id="stringbuf.general">[[stringbuf.general]]</a>
|
| 2 |
+
|
| 3 |
+
``` cpp
|
| 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 |
+
basic_stringbuf() : basic_stringbuf(ios_base::in | ios_base::out) {}
|
| 18 |
+
explicit basic_stringbuf(ios_base::openmode which);
|
| 19 |
+
explicit basic_stringbuf(
|
| 20 |
+
const basic_string<charT, traits, Allocator>& s,
|
| 21 |
+
ios_base::openmode which = ios_base::in | ios_base::out);
|
| 22 |
+
explicit basic_stringbuf(const Allocator& a)
|
| 23 |
+
: basic_stringbuf(ios_base::in | ios_base::out, a) {}
|
| 24 |
+
basic_stringbuf(ios_base::openmode which, const Allocator& a);
|
| 25 |
+
explicit basic_stringbuf(
|
| 26 |
+
basic_string<charT, traits, Allocator>&& s,
|
| 27 |
+
ios_base::openmode which = ios_base::in | ios_base::out);
|
| 28 |
+
template<class SAlloc>
|
| 29 |
+
basic_stringbuf(
|
| 30 |
+
const basic_string<charT, traits, SAlloc>& s, const Allocator& a)
|
| 31 |
+
: basic_stringbuf(s, ios_base::in | ios_base::out, a) {}
|
| 32 |
+
template<class SAlloc>
|
| 33 |
+
basic_stringbuf(
|
| 34 |
+
const basic_string<charT, traits, SAlloc>& s,
|
| 35 |
+
ios_base::openmode which, const Allocator& a);
|
| 36 |
+
template<class SAlloc>
|
| 37 |
+
explicit basic_stringbuf(
|
| 38 |
+
const basic_string<charT, traits, SAlloc>& s,
|
| 39 |
+
ios_base::openmode which = ios_base::in | ios_base::out);
|
| 40 |
+
basic_stringbuf(const basic_stringbuf&) = delete;
|
| 41 |
+
basic_stringbuf(basic_stringbuf&& rhs);
|
| 42 |
+
basic_stringbuf(basic_stringbuf&& rhs, const Allocator& a);
|
| 43 |
+
|
| 44 |
+
// [stringbuf.assign], assignment and swap
|
| 45 |
+
basic_stringbuf& operator=(const basic_stringbuf&) = delete;
|
| 46 |
+
basic_stringbuf& operator=(basic_stringbuf&& rhs);
|
| 47 |
+
void swap(basic_stringbuf& rhs) noexcept(see below);
|
| 48 |
+
|
| 49 |
+
// [stringbuf.members], getters and setters
|
| 50 |
+
allocator_type get_allocator() const noexcept;
|
| 51 |
+
|
| 52 |
+
basic_string<charT, traits, Allocator> str() const &;
|
| 53 |
+
template<class SAlloc>
|
| 54 |
+
basic_string<charT,traits,SAlloc> str(const SAlloc& sa) const;
|
| 55 |
+
basic_string<charT, traits, Allocator> str() &&;
|
| 56 |
+
basic_string_view<charT, traits> view() const noexcept;
|
| 57 |
+
|
| 58 |
+
void str(const basic_string<charT, traits, Allocator>& s);
|
| 59 |
+
template<class SAlloc>
|
| 60 |
+
void str(const basic_string<charT, traits, SAlloc>& s);
|
| 61 |
+
void str(basic_string<charT, traits, Allocator>&& s);
|
| 62 |
+
|
| 63 |
+
protected:
|
| 64 |
+
// [stringbuf.virtuals], overridden virtual functions
|
| 65 |
+
int_type underflow() override;
|
| 66 |
+
int_type pbackfail(int_type c = traits::eof()) override;
|
| 67 |
+
int_type overflow (int_type c = traits::eof()) override;
|
| 68 |
+
basic_streambuf<charT, traits>* setbuf(charT*, streamsize) override;
|
| 69 |
+
|
| 70 |
+
pos_type seekoff(off_type off, ios_base::seekdir way,
|
| 71 |
+
ios_base::openmode which
|
| 72 |
+
= ios_base::in | ios_base::out) override;
|
| 73 |
+
pos_type seekpos(pos_type sp,
|
| 74 |
+
ios_base::openmode which
|
| 75 |
+
= ios_base::in | ios_base::out) override;
|
| 76 |
+
|
| 77 |
+
private:
|
| 78 |
+
ios_base::openmode mode; // exposition only
|
| 79 |
+
basic_string<charT, traits, Allocator> buf; // exposition only
|
| 80 |
+
void init_buf_ptrs(); // exposition only
|
| 81 |
+
};
|
| 82 |
+
}
|
| 83 |
+
```
|
| 84 |
+
|
| 85 |
+
The class `basic_stringbuf` is derived from `basic_streambuf` to
|
| 86 |
+
associate possibly the input sequence and possibly the output sequence
|
| 87 |
+
with a sequence of arbitrary *characters*. The sequence can be
|
| 88 |
+
initialized from, or made available as, an object of class
|
| 89 |
+
`basic_string`.
|
| 90 |
+
|
| 91 |
+
For the sake of exposition, the maintained data and internal pointer
|
| 92 |
+
initialization is presented here as:
|
| 93 |
+
|
| 94 |
+
- `ios_base::openmode mode`, has `in` set if the input sequence can be
|
| 95 |
+
read, and `out` set if the output sequence can be written.
|
| 96 |
+
- `basic_string<charT, traits, Allocator> buf` contains the underlying
|
| 97 |
+
character sequence.
|
| 98 |
+
- `init_buf_ptrs()` sets the base class’ get area [[streambuf.get.area]]
|
| 99 |
+
and put area [[streambuf.put.area]] pointers after initializing,
|
| 100 |
+
moving from, or assigning to `buf` accordingly.
|
| 101 |
+
|