![]() |
IRSOL
C++ code implementing socket server for interacting with Baumer camera.
|
Represents a serialized protocol message with header and payload. More...
#include <serialized_message.hpp>
Public Member Functions | |
SerializedMessage (const std::string &header, std::vector< irsol::types::byte_t > &&payload) | |
Constructs a SerializedMessage with a header and binary payload. | |
SerializedMessage (SerializedMessage &&) noexcept=default | |
Move constructor (defaulted). | |
SerializedMessage & | operator= (SerializedMessage &&) noexcept=default |
Move assignment operator (defaulted). | |
SerializedMessage (const SerializedMessage &)=delete | |
Deleted copy constructor to prevent copying. | |
SerializedMessage & | operator= (const SerializedMessage &)=delete |
Deleted copy assignment operator to prevent copying. | |
bool | hasHeader () const |
Checks whether the serialized message contains a non-empty header. | |
bool | hasPayload () const |
Checks whether the serialized message contains a non-empty payload. | |
size_t | payloadSize () const |
Returns the size of the payload in bytes. | |
std::string | toString () const |
Converts the serialized message to a string representation. | |
Public Attributes | |
std::string | header |
The textual header of the serialized message. | |
std::vector< irsol::types::byte_t > | payload {} |
The binary payload of the serialized message. | |
Represents a serialized protocol message with header and payload.
This structure stores the serialized form of an outgoing protocol message. It consists of:
std::string
.std::vector<irsol::types::byte_t>
.The class supports move semantics but disables copying to avoid expensive copies of potentially large payloads.
Utility member functions provide information about the presence of header and payload data, the payload size, and allow conversion to a string representation.
Definition at line 42 of file serialized_message.hpp.
irsol::protocol::internal::SerializedMessage::SerializedMessage | ( | const std::string & | header, |
std::vector< irsol::types::byte_t > && | payload | ||
) |
Constructs a SerializedMessage with a header and binary payload.
The constructor moves the payload into the member to avoid copies.
header | The message header string. |
payload | The binary payload vector to move. |
Definition at line 9 of file serialized_message.cpp.
|
defaultnoexcept |
Move constructor (defaulted).
|
delete |
Deleted copy constructor to prevent copying.
bool irsol::protocol::internal::SerializedMessage::hasHeader | ( | ) | const |
Checks whether the serialized message contains a non-empty header.
true
if the header string is not empty, false
otherwise. Definition at line 16 of file serialized_message.cpp.
bool irsol::protocol::internal::SerializedMessage::hasPayload | ( | ) | const |
Checks whether the serialized message contains a non-empty payload.
true
if the payload vector is not empty, false
otherwise. Definition at line 22 of file serialized_message.cpp.
|
delete |
Deleted copy assignment operator to prevent copying.
|
defaultnoexcept |
Move assignment operator (defaulted).
size_t irsol::protocol::internal::SerializedMessage::payloadSize | ( | ) | const |
Returns the size of the payload in bytes.
Definition at line 28 of file serialized_message.cpp.
std::string irsol::protocol::internal::SerializedMessage::toString | ( | ) | const |
Converts the serialized message to a string representation.
This method typically returns a human-readable form of the serialized message, possibly concatenating the header and a textual form of the payload.
Definition at line 33 of file serialized_message.cpp.
std::string irsol::protocol::internal::SerializedMessage::header |
The textual header of the serialized message.
This string typically contains the message type and metadata in a human-readable format.
Definition at line 49 of file serialized_message.hpp.
std::vector<irsol::types::byte_t> irsol::protocol::internal::SerializedMessage::payload {} |
The binary payload of the serialized message.
This vector contains the binary data part of the message, following the header.
Definition at line 56 of file serialized_message.hpp.