blob: 1907dedd09e9013b27063be80b5e0010bbec2335 [file] [log] [blame]
#include <stdplus/fd/fmt.hpp>
#include <stdplus/fd/ops.hpp>
namespace stdplus
{
namespace fd
{
FormatBuffer::FormatBuffer(Fd& fd, size_t max) : fd(fd), max(max) {}
FormatBuffer::~FormatBuffer() noexcept(false)
{
flush();
}
void FormatBuffer::flush()
{
if (buf.size() > 0)
{
writeExact(fd, buf);
buf.clear();
}
}
void FormatBuffer::writeIfNeeded()
{
if (buf.size() >= max)
{
flush();
}
}
} // namespace fd
} // namespace stdplus