using packetbuf = basic_packetbuf< char >Alias to basic_packetbuf<char>.
template <class Ch, class Tr = std::char_traits<Ch>> class sys::basic_packetbuf
Stream buffer that can reads/writes data in packets with arbitrary header.
public virtual std::basic_streambuf< Ch, std::char_traits< Ch > >using ipacket_guard = basic_ipacket_guard< Ch, Tr >Incoming packet guard type.
set_ipacket(off_type pos1, off_type pos2, std::streamsize n) -> voidprotected
Set incoming packet offset to pos1, payload offset to pos2 and size to n.
set_opacket(off_type pos1) -> voidprotectedSet outgoing packet offset relative to pbase.
set_oheader(std::streamsize size) -> voidprotectedSet outgoing packet header size.
oheadersize() const -> std::streamsizeprotectedGet outgoing packet header size.
opacketsize() const -> std::streamsizeprotectedThe size of the outgoing packet in bytes.
opacketpos() const -> off_typeprotectedOffset of the first outgoing packet byte relative to pbase.
opacket_end() const -> char_type *protectedPointer to the end of the outgoing packet.
opacket_begin() const -> char_type *protectedPointer to the beginning of the outgoing packet.
ipacketpos() const -> off_typeprotectedOffset of the first incoming packet byte relative to eback.
ipayloadpos() const -> off_typeprotectedOffset of the first incoming packet payload byte relative to eback.
state() const -> state_typeprotectedPacket parsing state.
on_payload() -> voidprotectedvirtualThis function is called when payload becomes ready. Does nothing by default.
xgetheader(UNISTDX_UNUSED std::streamsize & header_size, std::streamsize & payload_size) -> boolprotectedvirtual
Read packet header and return header and payload size.
overwrite_header(std::streamsize) -> std::streamsizeprotectedvirtualOverwrite packet header when actual packet size is known. The argument is packet size.
put_header() -> voidprotectedvirtualWrite packet header into the put buffer. Does nothing by default. The method is called in begin_packet to write intiial packet header when actual packet size is not known.
seek_ipayloadpos(off_type off) -> voidSeeks get buffer position from the beginning of input packet payload.
ipayloadsize() const -> std::streamsizeReturns the size of the incoming packet payload.
ipayload_end() const -> const char_type *Returns the pointer to the end of incoming packet payload.
ipayload_end() -> char_type *Returns the pointer to the end of incoming packet payload.
ipayload_cur() const -> const char_type *Returns the pointer to the current byte of incoming packet payload.
ipayload_cur() -> char_type *Returns the pointer to the current byte of incoming packet payload.
ipayload_begin() const -> const char_type *Returns the pointer to the beginning of incoming packet payload.
ipayload_begin() -> char_type *Returns the pointer to the beginning of incoming packet payload.
ipacketsize() const -> std::streamsizeThe size of the incoming packet.
ipacket_end() const -> const char_type *Returns the pointer to the end of incoming packet.
ipacket_end() -> char_type *Returns the pointer to the end of incoming packet.
ipacket_begin() const -> const char_type *Returns the pointer to the beginning of incoming packet.
ipacket_begin() -> char_type *Returns the pointer to the beginning of incoming packet.
is_safe_to_compact() const -> boolReturns true if packet buffer can be compacted without ruining the state which might have been save by subclasses.
set_name(const char * rhs) -> voidSet packet buffer name for debugging.
ipayload_offset() const -> std::streamsizeGet pointer offset within the payload.
available() const -> std::streamsizeReturns the number of available bytes in get buffer.
remaining() const -> std::streamsizeReturns the number of remaining bytes in put buffer.
dirty() const -> boolReturns true, if put buffer is non-empty.
skip_packet() -> voidMove to the next input packet, if the payload of the current packet is ready.
read_packet() -> boolRead the packet and update packet parsing state.
cancel_packet() -> voidCancel writing a packet, resetting put buffer position.
end_packet() -> voidFinish writing the packet by updating its header with actual packet size.
begin_packet() -> voidStart writing a packet by appending an empty header.
handshake() -> boolvirtualPerform protocol-specific handshake. Does nothing by default.
~basic_packetbuf()virtualbasic_packetbuf()Guard object that preserves packet buffer state upon failure.
using streambuf_type = basic_packetbuf< Ch, Tr >Stream buffer type.
using char_type = ChCharacter type.
~basic_ipacket_guard()Destroy incoming packet guard, restore buffer state and skip remaining payload bytes (if any).
basic_ipacket_guard(streambuf_type * buf)explicit
Construct incoming packet guard for packet buffer buf, save buffer state and set get buffer pointers to limit reading only to payload part of the packet buffer.
template <class Ch, class Tr> append_payload(basic_packetbuf< Ch, Tr > & dest, basic_packetbuf< Ch, Tr > & src, std::streamsize off = 0) -> void
Append full payload of the packet from dest to src. Only payload is copied.