MessagePacket Class
The MessagePacket class encapsulates a message and its transport header, along with various methods for managing and accessing the message data. More...
Header: | #include <Generic/MessageQueue.h> |
Public Functions
MessageTransportHeader & | GetHeader() |
const MessageTransportHeader & | GetHeader() const |
Message & | GetMessage() |
const Message & | GetMessage() const |
T & | GetMessage() |
const T & | GetMessage() const |
std::ostream & | GetPayloadOStream() |
const std::string_view | Payload() const |
const std::string_view | Payload() const |
void | PayloadAppend(const std::string &data) |
char * | PayloadData() const |
size_t | PayloadSize() const |
char * | RawData() const |
size_t | RawSize() const |
void | Reset() |
void | ResizeMessage(size_t messageSize = 0) |
void | ResizeRaw(size_t rawSize = 0) |
Detailed Description
The MessagePacket class encapsulates a message and its transport header, along with various methods for managing and accessing the message data.
MessagePacket provides methods to access and modify message header and payload, resize the message or raw data, and manage payload data through an output stream.
Member Function Documentation
MessageTransportHeader &MessagePacket::GetHeader()
Retrieves the MessageTransportHeader of the packet.
Returns a reference to the MessageTransportHeader of the packet.
const MessageTransportHeader &MessagePacket::GetHeader() const
Retrieves the MessageTransportHeader of the packet.
Returns a constant reference to the MessageTransportHeader of the packet.
Message &MessagePacket::GetMessage()
Retrieves the Message of the packet.
Returns a reference to the Message of the packet.
const Message &MessagePacket::GetMessage() const
Retrieves the Message of the packet.
Returns a constant reference to the Message of the packet.
T &MessagePacket::GetMessage()
const T &MessagePacket::GetMessage() const
std::ostream &MessagePacket::GetPayloadOStream()
Retrieves an output stream for appending data to the payload.
Streaming data to the ostream updates Message Payload Size to new payload size. Returns an output stream for appending data directly to the payload buffer
const std::string_view MessagePacket::Payload() const
Retrieves the payload as a string view.
Returns a string view of the payload.
const std::string_view MessagePacket::Payload() const
void MessagePacket::PayloadAppend(const std::string &data)
Appends data to the payload.
Updates Message Payload Size to new payload size. data The data to append to the payload.
char *MessagePacket::PayloadData() const
Retrieves the data of the payload.
Returns a pointer to the data of the payload.
size_t MessagePacket::PayloadSize() const
Retrieves the size of the payload.
Returns the size of the payload.
char *MessagePacket::RawData() const
size_t MessagePacket::RawSize() const
Retrieves the size of the raw data buffer. Data buffer holding MessageTransportHeader
+ Message
+ Payload
Returns the size of the raw data buffer.
void MessagePacket::Reset()
Resets the message packet to its initial state.
void MessagePacket::ResizeMessage(size_t messageSize = 0)
Resizes packet to fit custom message header and payload of message. Room for MessageTransportHeader is automatically allocated.
param messageSize equals Message header + payload
void MessagePacket::ResizeRaw(size_t rawSize = 0)
Resizes the raw data buffer to a specified size.
Data buffer for holding MessageTransportHeader
+ Message
+ Payload
Also updates Message Payload Size to new size left over from default headers MessageTransportHeader + Message
rawSize The new size for the raw data buffer.
Get started with CDP Studio today
Let us help you take your great ideas and turn them into the products your customer will love.