Protocol for messages where the payload is preceded by a fixed-size header indicating its length.
More...
|
| size_as_header ()=delete |
| Default constructor.
|
| size_as_header (_IO_ &io) noexcept |
| Constructor with I/O reference.
|
std::size_t | shiftSize () const noexcept |
| Returns the size of the header.
|
std::size_t | getMessageSize () noexcept final |
| Determines the size of the next complete message.
|
void | reset () noexcept final |
| Resets the protocol state.
|
virtual | ~IProtocol ()=default |
| Virtual destructor.
|
bool | ok () const noexcept |
| Checks if the protocol is in a valid operational state.
|
void | not_ok () noexcept |
| Marks the protocol as being in an invalid or non-operational state.
|
void | set_should_flush (bool should_flush) noexcept |
| Sets the flag indicating whether the protocol should flush the input buffer after processing a message.
|
bool | should_flush () const noexcept |
| Gets the flag indicating whether the protocol should flush the input buffer after processing a message.
|
template<typename _IO_, typename _Size = uint16_t>
class qb::protocol::base::size_as_header< _IO_, _Size >
Protocol for messages where the payload is preceded by a fixed-size header indicating its length.
This class implements a protocol where each message payload is prefixed by an integer header (e.g., uint8_t, uint16_t, uint32_t) that specifies the size of the upcoming payload. It handles network byte order conversion (e.g., ntohs, ntohl) for 16-bit and 32-bit headers. It inherits from qb::io::async::AProtocol.
- Template Parameters
-
_IO_ | The I/O component type that will use this protocol. It needs to provide an in() method for input buffer access. |
_Size | The integer type of the size header (e.g., uint16_t, uint32_t). Defaults to uint16_t. |