26#ifndef QB_IO_PROT_TEXT_H_
27#define QB_IO_PROT_TEXT_H_
30namespace qb::protocol::text {
47template <
typename _IO_,
typename _StringTrait,
char _Sep = '\0'>
87 const auto &buffer = this->
_io.in();
88 const auto parsed = this->
shiftSize(size);
89 this->
_io.on(message{parsed, buffer.cbegin(), {buffer.cbegin(), parsed}});
107template <
typename _IO_,
typename _SizeHeader = u
int16_t>
145 this->
_io.on(message{size, this->
_io.in().cbegin() + this->
shiftSize()});
159template <
typename _IO_>
172template <
typename _IO_>
185template <
typename _IO_>
198template <
typename _IO_>
212template <
typename _IO_>
226template <
typename _IO_>
239template <
typename _IO_>
_IO_ & _io
Reference to the I/O component instance that this protocol is associated with.
Definition protocol.h:166
Protocol for messages delimited by a specific single byte character.
Definition base.h:48
std::size_t shiftSize(std::size_t const size) const noexcept
Definition base.h:81
Protocol for binary messages where the payload is preceded by a fixed-size header indicating its leng...
Definition text.h:108
void onMessage(std::size_t size) const noexcept
Process a received message.
Definition text.h:144
basic_binary(_IO_ &io) noexcept
Constructor with I/O reference.
Definition text.h:120
basic_binary()=delete
Default constructor (deleted)
Protocol for text messages delimited by a specific character, yielding a specified string type.
Definition text.h:48
basic_text()=delete
Default constructor (deleted)
void onMessage(std::size_t size) noexcept
Process a received message.
Definition text.h:86
basic_text(_IO_ &io) noexcept
Constructor with I/O reference.
Definition text.h:60
basic_text< _IO_, std::string, '\n'> command
Protocol for newline-terminated (\n) commands, yielding std::string.
Definition text.h:213
basic_text< _IO_, const std::string_view, '\n'> command_view
Protocol for newline-terminated (\n) commands, yielding std::string_view (zero-copy read).
Definition text.h:240
basic_binary< _IO_, uint32_t > binary32
Binary protocol with a 32-bit (uint32_t) size header.
Definition text.h:186
basic_binary< _IO_, uint16_t > binary16
Binary protocol with a 16-bit (uint16_t) size header.
Definition text.h:173
basic_binary< _IO_, uint8_t > binary8
Binary protocol with an 8-bit (uint8_t) size header.
Definition text.h:160
basic_text< _IO_, const std::string_view, '\0'> string_view
Protocol for NULL-terminated (\0) strings, yielding std::string_view (zero-copy read).
Definition text.h:227
basic_text< _IO_, std::string, '\0'> string
Protocol for NULL-terminated (\0) strings, yielding std::string.
Definition text.h:199
Base protocol implementations for message framing in the QB IO system.
Structure representing a binary message.
Definition text.h:130
const char * data
Pointer to the raw data.
Definition text.h:132
const std::size_t size
Message size.
Definition text.h:131
Structure representing a text message.
Definition text.h:71
_StringTrait text
The message as text.
Definition text.h:74
const std::size_t size
Message size without the delimiter.
Definition text.h:72
const char * data
Pointer to the raw data.
Definition text.h:73