• Skip to main content
  • Skip to header right navigation
  • Skip to site footer
CDP Studio logo

CDP Studio

The no-code and full-code software development tool for distributed control systems and HMI

  • Doc
  • Why CDP
    • Software developers
    • Automation engineers
    • Managers
  • Products
    • Automation Designer
    • HMI Designer
    • Maritime HMIs
  • Services
  • Use cases
  • Pricing
  • Try CDP

CDP Studio Documentation

  • Framework - CDP Core
  • MessagePacket
  • 5.0.0

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 <MessagePacket>
  • List of all members, including inherited members

Public Functions

MessageTransportHeader &GetHeader()
const MessageTransportHeader &GetHeader() const
Message &GetMessage()
const Message &GetMessage() const
T &GetMessage()
const T &GetMessage() const
std::ostream &GetPayloadOStream()
void Init()
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
size_t RawCapacity() const
char *RawData() const
size_t RawSize() const
void ReserveRaw(size_t rawSize = 0)
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

void MessagePacket::Init()

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.

size_t MessagePacket::RawCapacity() const

Retrieves the number of bytes of the raw data buffer available before memory reallocation Returns the capasity of the raw data buffer.

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::ReserveRaw(size_t rawSize = 0)

Reserves the raw data buffer to a specified size.

Reserving makes following writes via PayloadAppend() or stream to GetPayloadOStream() faster.

rawSize The new reserved (internally allocated) size for 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.

The content of this document is confidential information not to be published without the consent of CDP Technologies AS.

CDP Technologies AS, www.cdpstudio.com

Get started with CDP Studio today

Let us help you take your great ideas and turn them into the products your customer will love.

Try CDP Studio for free
Why CDP Studio?

CDP Technologies AS
Hundsværgata 8,
P.O. Box 144
6001 Ålesund, Norway

Tel: +47 990 80 900
E-mail: info@cdptech.com

Company

About CDP

Contact us

Services

Partners

Blog

Developers

Get started

User manuals

Support

Document download

Release notes

My account

Follow CDP

  • LinkedIn
  • YouTube
  • GitHub

© Copyright 2025 CDP Technologies. Privacy and cookie policy.

Return to top