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
A collection of assert function wrappers.
Abstraction of socket data type.
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.
state_t m_state
Internal state of an object.
void chop()
Remove the delimiter from the end of the buffer.
CharInBuffer(size_t size_, const string &delimiter_)
Constructor.
const char * c_str() const
Get the constant character pointer to the buffer.
std::string m_delimiter
Delimiter. Multibyte delimiter is allowed.
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 state(state_t new_state_)
Go to the new state.
state_t
States: start, waiting, complete, error.
@ complete
matched end-of-record - full record
@ error
overflow or Socket I/O error
@ waiting
incomplete record is in the buffer
size_t length() const
Bytes in the buffer so far.
void reset()
Discard all accumulated characters and be ready to receive a new message.
size_t m_max_size
Maximum allowable size (delimiter included) before overflow occurs.
state_t state() const
Report the current state of the object.
void dump() const
Write the state of an object to the log file.