#include <BufferedIO.h>
Inheritance diagram for oasys::BufferedInput:
Definition at line 51 of file BufferedIO.h.
Public Member Functions | |
BufferedInput (IOClient *client, const char *logbase="/BufferedInput") | |
~BufferedInput () | |
int | read_line (const char *nl, char **buf, int timeout=-1) |
Read in a line of input, newline characters included. | |
int | read_bytes (size_t len, char **buf, int timeout=-1) |
Read len bytes. | |
int | read_some_bytes (char **buf, int timeout=-1) |
Read some bytes. | |
char | get_char (int timeout=-1) |
Read in a single character from the protocol stream. | |
bool | eof () |
Returns true if at the end of file. | |
Private Member Functions | |
int | internal_read (size_t len=0, int timeout_ms=-1) |
Read in len bytes into the buffer. | |
int | find_nl (const char *nl) |
| |
Private Attributes | |
IOClient * | client_ |
StreamBuffer | buf_ |
bool | seen_eof_ |
Static Private Attributes | |
static const size_t | READ_AHEAD = 256 |
static const size_t | MAX_LINE = 4096 |
Amount to read when buffer is full. |
oasys::BufferedInput::BufferedInput | ( | IOClient * | client, | |
const char * | logbase = "/BufferedInput" | |||
) |
Definition at line 54 of file BufferedIO.cc.
oasys::BufferedInput::~BufferedInput | ( | ) |
Definition at line 61 of file BufferedIO.cc.
int oasys::BufferedInput::read_line | ( | const char * | nl, | |
char ** | buf, | |||
int | timeout = -1 | |||
) |
Read in a line of input, newline characters included.
nl | character string that defines a newline | |
buf | output parameter containing a pointer to the buffer with the line, valid until next call to read_line | |
timeout | timeout value for read |
Definition at line 65 of file BufferedIO.cc.
References buf_, oasys::StreamBuffer::consume(), errno, find_nl(), oasys::StreamBuffer::fullbytes(), internal_read(), log_debug, READ_AHEAD, and oasys::StreamBuffer::start().
Referenced by oasys::SMTP::process_cmd(), and oasys::SMTP::process_response().
int oasys::BufferedInput::read_bytes | ( | size_t | len, | |
char ** | buf, | |||
int | timeout = -1 | |||
) |
Read len bytes.
Blocking until specified amount of bytes is read.
len | length to read | |
buf | output parameter containing a pointer to the buffer with the line, valid until next call to read_line | |
timeout | timeout value for read |
Definition at line 92 of file BufferedIO.cc.
References ASSERT, buf_, oasys::StreamBuffer::consume(), errno, oasys::StreamBuffer::fullbytes(), internal_read(), log_debug, and oasys::StreamBuffer::start().
int oasys::BufferedInput::read_some_bytes | ( | char ** | buf, | |
int | timeout = -1 | |||
) |
Read some bytes.
buf | output parameter containing a pointer to the buffer with the line, valid until next call to read_line | |
timeout | timeout value for read |
Definition at line 128 of file BufferedIO.cc.
References ASSERT, buf_, oasys::StreamBuffer::consume(), oasys::StreamBuffer::end(), errno, oasys::StreamBuffer::fullbytes(), internal_read(), log_debug, oasys::LOG_ERR, oasys::Logger::logf(), oasys::StreamBuffer::start(), and oasys::StreamBuffer::tailbytes().
char oasys::BufferedInput::get_char | ( | int | timeout = -1 |
) |
Read in a single character from the protocol stream.
Returns 0 if at the end of the stream or error.
Definition at line 163 of file BufferedIO.cc.
References ASSERT, buf_, oasys::StreamBuffer::consume(), errno, oasys::StreamBuffer::fullbytes(), internal_read(), oasys::LOG_ERR, oasys::Logger::logf(), oasys::StreamBuffer::start(), and oasys::StreamBuffer::tailbytes().
bool oasys::BufferedInput::eof | ( | ) |
Returns true if at the end of file.
Definition at line 186 of file BufferedIO.cc.
References buf_, oasys::StreamBuffer::fullbytes(), and seen_eof_.
int oasys::BufferedInput::internal_read | ( | size_t | len = 0 , |
|
int | timeout_ms = -1 | |||
) | [private] |
Read in len bytes into the buffer.
If there are enough bytes already present in buf_, no call to read will occur.
len | The amount to read | |
timeout_ms | Timeout to the read call. UNIMPLEMENTED |
Definition at line 192 of file BufferedIO.cc.
References ASSERT, buf_, client_, oasys::StreamBuffer::end(), errno, oasys::StreamBuffer::fill(), oasys::StreamBuffer::fullbytes(), oasys::IOTIMEOUT, log_debug, oasys::LOG_ERR, oasys::Logger::logf(), oasys::IOClient::read(), oasys::StreamBuffer::reserve(), seen_eof_, oasys::StreamBuffer::start(), oasys::StreamBuffer::tailbytes(), and oasys::IOClient::timeout_read().
Referenced by get_char(), read_bytes(), read_line(), and read_some_bytes().
int oasys::BufferedInput::find_nl | ( | const char * | nl | ) | [private] |
Definition at line 252 of file BufferedIO.cc.
References buf_, oasys::StreamBuffer::fullbytes(), and oasys::StreamBuffer::start().
Referenced by read_line().
IOClient* oasys::BufferedInput::client_ [private] |
StreamBuffer oasys::BufferedInput::buf_ [private] |
Definition at line 124 of file BufferedIO.h.
Referenced by eof(), find_nl(), get_char(), internal_read(), read_bytes(), read_line(), and read_some_bytes().
bool oasys::BufferedInput::seen_eof_ [private] |
const size_t oasys::BufferedInput::READ_AHEAD = 256 [static, private] |
const size_t oasys::BufferedInput::MAX_LINE = 4096 [static, private] |