7 #pragma warning(disable : 4365 4987)
17template<
class TStream, std::
size_t BufferSize = 4096ul>
35 std::streamsize
xsputn(
const CharType* source, std::streamsize size)
override {
42 const std::ptrdiff_t spaceLeft = epptr() - pptr();
43 if (size < spaceLeft) {
44 std::memcpy(pptr(), source,
static_cast<std::size_t
>(size));
45 pbump(
static_cast<IntType>(size));
53 return static_cast<std::streamsize
>(
stream->write(source,
static_cast<std::size_t
>(size)));
58 if (value == TraitsType::eof()) {
65 return (
sync() ? TraitsType::eof() : value);
69 const std::ptrdiff_t diff = pptr() - pbase();
71 const std::size_t bytesToWrite =
static_cast<std::size_t
>(diff);
72 const std::size_t bytesWritten =
stream->write(
buffer.data(), bytesToWrite);
73 pbump(
static_cast<IntType>(-diff));
74 return (bytesToWrite == bytesWritten ? 0 : -1);
Definition: CharOutputStreamBuf.h:18
~CharOutputStreamBuf()
Definition: CharOutputStreamBuf.h:31
std::streambuf::char_type CharType
Definition: CharOutputStreamBuf.h:22
std::streambuf::traits_type TraitsType
Definition: CharOutputStreamBuf.h:24
IntType overflow(IntType value) override
Definition: CharOutputStreamBuf.h:56
CharOutputStreamBuf(TStream *stream_)
Definition: CharOutputStreamBuf.h:27
std::array< char, BufferSize > buffer
Definition: CharOutputStreamBuf.h:81
std::streambuf::pos_type PosType
Definition: CharOutputStreamBuf.h:20
IntType sync() override
Definition: CharOutputStreamBuf.h:68
std::streambuf::int_type IntType
Definition: CharOutputStreamBuf.h:23
std::streamsize xsputn(const CharType *source, std::streamsize size) override
Definition: CharOutputStreamBuf.h:35
std::streambuf::off_type OffType
Definition: CharOutputStreamBuf.h:21
TStream * stream
Definition: CharOutputStreamBuf.h:80