Go to the documentation of this file.
12 #ifndef CHAR_IN_BUFFER_H
13 #define CHAR_IN_BUFFER_H
21 #include <sys/types.h>
63 operator void* ()
const;
124 using namespace ASSA;
128 operator
void* ()
const
130 return (m_state == complete
std::string m_delimiter
Delimiter. Multibyte delimiter is allowed.
CharInBuffer is a bucket for the character-based streams/messages.
static const char * state_name(state_t state_)
Report the state name.
std::string m_buffer
Buffer to store the bytes received.
size_t m_max_size
Maximum allowable size (delimiter included) before overflow occurs.
@ complete
matched end-of-record - full record
@ waiting
incomplete record is in the buffer
CharInBuffer(size_t size_, const string &delimiter_)
Constructor.
void state(state_t new_state_)
Go to the new state.
state_t state() const
Report the current state of the object.
friend ASSA::Socket & operator>>(ASSA::Socket &, ASSA::CharInBuffer &)
Read bytes from Socket stream until either record delimiter is detected, or EOF occured,...
size_t size() const
Bytes in the buffer so far.
void reset()
Discard all accumulated characters and be ready to receive a new message.
size_t length() const
Bytes in the buffer so far.
@ error
overflow or Socket I/O error
state_t m_state
Internal state of an object.
const char * c_str() const
Get the constant character pointer to the buffer.
void chop()
Remove the delimiter from the end of the buffer.
void dump() const
Write the state of an object to the log file.