MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / basic_streambuf

Class basic_streambuf

3rd/asio-1.24.0/include/asio/basic_streambuf.hpp:110–360  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

108template <typename Allocator>
109#endif
110class basic_streambuf
111 : public std::streambuf,
112 private noncopyable
113{
114public:
115#if defined(GENERATING_DOCUMENTATION)
116 /// The type used to represent the input sequence as a list of buffers.
117 typedef implementation_defined const_buffers_type;
118
119 /// The type used to represent the output sequence as a list of buffers.
120 typedef implementation_defined mutable_buffers_type;
121#else
122 typedef ASIO_CONST_BUFFER const_buffers_type;
123 typedef ASIO_MUTABLE_BUFFER mutable_buffers_type;
124#endif
125
126 /// Construct a basic_streambuf object.
127 /**
128 * Constructs a streambuf with the specified maximum size. The initial size
129 * of the streambuf's input sequence is 0.
130 */
131 explicit basic_streambuf(
132 std::size_t maximum_size = (std::numeric_limits<std::size_t>::max)(),
133 const Allocator& allocator = Allocator())
134 : max_size_(maximum_size),
135 buffer_(allocator)
136 {
137 std::size_t pend = (std::min<std::size_t>)(max_size_, buffer_delta);
138 buffer_.resize((std::max<std::size_t>)(pend, 1));
139 setg(&buffer_[0], &buffer_[0], &buffer_[0]);
140 setp(&buffer_[0], &buffer_[0] + pend);
141 }
142
143 /// Get the size of the input sequence.
144 /**
145 * @returns The size of the input sequence. The value is equal to that
146 * calculated for @c s in the following code:
147 * @code
148 * size_t s = 0;
149 * const_buffers_type bufs = data();
150 * const_buffers_type::const_iterator i = bufs.begin();
151 * while (i != bufs.end())
152 * {
153 * const_buffer buf(*i++);
154 * s += buf.size();
155 * }
156 * @endcode
157 */
158 std::size_t size() const ASIO_NOEXCEPT
159 {
160 return pptr() - gptr();
161 }
162
163 /// Get the maximum size of the basic_streambuf.
164 /**
165 * @returns The allowed maximum of the sum of the sizes of the input sequence
166 * and output sequence.
167 */

Callers

nothing calls this directly

Calls 2

bufferFunction · 0.85
const_bufferFunction · 0.70

Tested by

no test coverage detected