HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
Public Member Functions
v1::packet_buffer Class Reference

Public Member Functions

bool closed () const noexcept
 Connection is closed.
 
ssize_t nrBytes () const noexcept
 Total number of bytes in the buffer.
 
ssize_t nrpackets () const noexcept
 Total number of packets in the buffer.
 
void close () noexcept
 Close the connection on this side.
 
std::span< std::byte > getNewpacket (ssize_t nrBytes) noexcept
 Get a new packet to write a message into.
 
std::span< std::byte > getpacket (ssize_t nrBytes) noexcept
 Get a packet to write a stream of bytes into.
 
void write (ssize_t nrBytes, bool push=true) noexcept
 Write the data added to the packet.
 
std::span< std::byte const > peek (ssize_t nrBytes)
 Peek into the data without consuming.
 
std::string_view peekLine (ssize_t nrBytes=1024)
 Peek into the data a single text-line without consuming.
 
void read (ssize_t nrBytes) noexcept
 Consume the data from the buffer.
 

Member Function Documentation

◆ close()

void v1::packet_buffer::close ( )
inlinenoexcept

Close the connection on this side.

◆ closed()

bool v1::packet_buffer::closed ( ) const
inlinenoexcept

Connection is closed.

Returns
true when the connection has be closed.

◆ getNewpacket()

std::span< std::byte > v1::packet_buffer::getNewpacket ( ssize_t nrBytes)
inlinenoexcept

Get a new packet to write a message into.

Returns
a pointer to an byte array with at least nrBytes of data available.

◆ getpacket()

std::span< std::byte > v1::packet_buffer::getpacket ( ssize_t nrBytes)
inlinenoexcept

Get a packet to write a stream of bytes into.

Returns
a pointer to an byte array with at least nrBytes of data available.

◆ nrBytes()

ssize_t v1::packet_buffer::nrBytes ( ) const
inlinenoexcept

Total number of bytes in the buffer.

◆ nrpackets()

ssize_t v1::packet_buffer::nrpackets ( ) const
inlinenoexcept

Total number of packets in the buffer.

This contains the number of messages on a message based socket. On a stream based socket this number is not useful, but larger than zero when data is available.

◆ peek()

std::span< std::byte const > v1::packet_buffer::peek ( ssize_t nrBytes)
inline

Peek into the data without consuming.

Parameters
nrBytesthe minimum amount of data required.
Returns
empty if not enough bytes available; otherwise the data. The returned size may be larger than requested and this data may be consumed using read().

◆ peekLine()

std::string_view v1::packet_buffer::peekLine ( ssize_t nrBytes = 1024)
inline

Peek into the data a single text-line without consuming.

Throws parse_error when the line is longer than nrBytes.

Parameters
nrBytesmaximum line size
Returns
empty if there are no lines; otherwise a line of data. The line-feed or nul is included at the end of the string.

◆ read()

void v1::packet_buffer::read ( ssize_t nrBytes)
inlinenoexcept

Consume the data from the buffer.

This function will consume the data read using peek() and peekLine().

Parameters
nrBytesThe number of bytes to consume.

◆ write()

void v1::packet_buffer::write ( ssize_t nrBytes,
bool push = true )
inlinenoexcept

Write the data added to the packet.

This function will write the data added into the buffers returned by getNewpacket() and getpacket().

Parameters
nrBytesThe number of bytes written into the packet.
pushPush the data through the socket, bypass Nagel algorithm.

The documentation for this class was generated from the following file: