#include <BufferedIO.h>
Definition at line 111 of file BufferedIO.h.
Public Member Functions | |
BufferedOutput (IOClient *client, const char *logbase="/BufferedOutput") | |
int | write (const char *bp, size_t len=0) |
Write len bytes from bp. | |
void | clear_buf () |
Clears the buffer contents without writing. | |
int | format_buf (const char *format,...) |
Fills the buffer via printf style args, returning the length or -1 if there's an error. | |
int | vformat_buf (const char *format, va_list args) |
int | flush () |
Writes the full buffer, potentially in multiple calls to write. | |
void | set_flush_limit (size_t limit) |
If the buffer reaches size > limit, then the buffer is automatically flushed. | |
int | printf (const char *format,...) |
Do format_buf() and flush() in one call. | |
Private Attributes | |
IOClient * | client_ |
StreamBuffer | buf_ |
size_t | flush_limit_ |
Static Private Attributes | |
static const size_t | DEFAULT_FLUSH_LIMIT = 256 |
oasys::BufferedOutput::BufferedOutput | ( | IOClient * | client, | |
const char * | logbase = "/BufferedOutput" | |||
) |
Definition at line 263 of file BufferedIO.cc.
int oasys::BufferedOutput::write | ( | const char * | bp, | |
size_t | len = 0 | |||
) |
Write len bytes from bp.
Output may be buffered. If len is zero, calls strlen() to determine the length
Definition at line 272 of file BufferedIO.cc.
References buf_, oasys::StreamBuffer::end(), oasys::StreamBuffer::fill(), flush(), flush_limit_, oasys::StreamBuffer::fullbytes(), and oasys::StreamBuffer::reserve().
Referenced by oasys::SMTP::client_session().
void oasys::BufferedOutput::clear_buf | ( | ) |
Clears the buffer contents without writing.
Definition at line 290 of file BufferedIO.cc.
References buf_, and oasys::StreamBuffer::clear().
int oasys::BufferedOutput::format_buf | ( | const char * | format, | |
... | ||||
) |
Fills the buffer via printf style args, returning the length or -1 if there's an error.
Definition at line 319 of file BufferedIO.cc.
References vformat_buf().
Referenced by oasys::SMTP::send_response().
int oasys::BufferedOutput::vformat_buf | ( | const char * | format, | |
va_list | args | |||
) |
Definition at line 296 of file BufferedIO.cc.
References ASSERT, buf_, oasys::StreamBuffer::end(), oasys::StreamBuffer::fill(), flush(), flush_limit_, oasys::StreamBuffer::fullbytes(), oasys::StreamBuffer::reserve(), oasys::StreamBuffer::tailbytes(), and vsnprintf().
Referenced by format_buf(), and printf().
int oasys::BufferedOutput::flush | ( | ) |
Writes the full buffer, potentially in multiple calls to write.
Definition at line 343 of file BufferedIO.cc.
References buf_, client_, oasys::StreamBuffer::consume(), errno, oasys::StreamBuffer::fullbytes(), log_debug, log_err, oasys::StreamBuffer::start(), and oasys::IOClient::write().
Referenced by oasys::SMTP::client_session(), printf(), vformat_buf(), and write().
void oasys::BufferedOutput::set_flush_limit | ( | size_t | limit | ) |
If the buffer reaches size > limit, then the buffer is automatically flushed.
If the limit is 0, then it never auto-flushes.
Definition at line 382 of file BufferedIO.cc.
References flush_limit_.
int oasys::BufferedOutput::printf | ( | const char * | format, | |
... | ||||
) |
Do format_buf() and flush() in one call.
Definition at line 330 of file BufferedIO.cc.
References flush(), and vformat_buf().
Referenced by oasys::SMTP::client_session(), and oasys::SMTP::send_response().
IOClient* oasys::BufferedOutput::client_ [private] |
StreamBuffer oasys::BufferedOutput::buf_ [private] |
Definition at line 155 of file BufferedIO.h.
Referenced by clear_buf(), flush(), vformat_buf(), and write().
size_t oasys::BufferedOutput::flush_limit_ [private] |
Definition at line 157 of file BufferedIO.h.
Referenced by set_flush_limit(), vformat_buf(), and write().
const size_t oasys::BufferedOutput::DEFAULT_FLUSH_LIMIT = 256 [static, private] |
Definition at line 159 of file BufferedIO.h.