OnixS C++ CME MDP Premium Market Data Handler 5.11.1
Users' manual and API documentation
Loading...
Searching...
No Matches
Packet Class Reference

#include <OnixS/CME/MDH/Packet.h>

Public Types

using Header = PacketHeader

Public Member Functions

 Packet () noexcept=default
 Packet (const void *data, PacketSize size)
 Packet (const void *data, PacketSize size, const NoVerify &noVerify) noexcept
 Packet (const Packet &other) noexcept=default
 ~Packet ()=default
 operator bool () const noexcept
const void * data () const noexcept
const Header * header () const noexcept
PacketSize size () const noexcept
SequenceNumber seqNumber () const noexcept
Messaging::Timestamp sendingTime () const noexcept
BinaryMessages messages () const noexcept
void reset () noexcept
void reset (const void *data, PacketSize size)
void reset (const void *data, PacketSize size, const NoVerify &noVerify) noexcept
Packet & operator= (const Packet &other) noexcept=default

Detailed Description

The packet does not manage the referenced storage. The caller must keep the buffer valid and unchanged while the packet or any message view obtained from it is used.

Definition at line 231 of file Packet.h.

Member Typedef Documentation

◆ Header

Defines the binary header type stored at the start of a packet.

Definition at line 235 of file Packet.h.

Constructor & Destructor Documentation

◆ Packet() [1/4]

Packet ( )
defaultnoexcept

Constructs a null packet that does not refer to a buffer.

◆ Packet() [2/4]

Packet ( const void * data,
PacketSize size )
inline

Constructs a packet view over a buffer and validates its minimum size.

Parameters
dataAddress of the packet buffer.
sizeBuffer size in bytes.
Exceptions
std::runtime_errorIf size is smaller than the packet header.
Note
data must be non-null and remain valid for as long as the packet view is used.

Definition at line 245 of file Packet.h.

◆ Packet() [3/4]

Packet ( const void * data,
PacketSize size,
const NoVerify & noVerify )
inlinenoexcept

Constructs a packet view without validating the buffer.

Parameters
dataAddress of the packet buffer.
sizeBuffer size in bytes.
noVerifyTag selecting the unchecked overload.
Note
The caller must ensure that the buffer contains a complete packet and remains valid while in use.

Definition at line 262 of file Packet.h.

◆ Packet() [4/4]

Packet ( const Packet & other)
defaultnoexcept

Copies a packet view without copying the referenced buffer.

Parameters
otherPacket view to copy.

◆ ~Packet()

~Packet ( )
default

Destroys the view without releasing the referenced buffer.

Member Function Documentation

◆ data()

const void * data ( ) const
inlinenoexcept

Returns the start of the packet bytes.

Returns
Address of the non-owned packet buffer.
Note
This packet must not be null.

Definition at line 289 of file Packet.h.

◆ header()

const Header * header ( ) const
inlinenoexcept

Returns the packet header.

Returns
Pointer to the header in the non-owned packet buffer.
Note
This packet must not be null.

Definition at line 301 of file Packet.h.

◆ messages()

BinaryMessages messages ( ) const
inlinenoexcept

Returns an iterable view of the packet's encoded messages.

Returns
Non-owning view spanning the bytes after the packet header through the end of the packet.
Note
This packet must not be null. Message boundaries are validated during iteration.

Definition at line 346 of file Packet.h.

◆ operator bool()

operator bool ( ) const
inlinenoexcept

Tests whether this view refers to a non-empty packet buffer.

Returns
true if the stored packet size is nonzero; otherwise false.

Definition at line 279 of file Packet.h.

◆ operator=()

Packet & operator= ( const Packet & other)
defaultnoexcept

Rebinds this view to the same buffer as another packet.

Parameters
otherPacket view to copy.
Returns
Reference to this packet view.

◆ reset() [1/3]

void reset ( )
inlinenoexcept

Resets this object to the null packet state.

Definition at line 354 of file Packet.h.

◆ reset() [2/3]

void reset ( const void * data,
PacketSize size )
inline

Rebinds this view to a buffer and validates its minimum size.

Parameters
dataAddress of the packet buffer.
sizeBuffer size in bytes.
Exceptions
std::runtime_errorIf data is null or size is smaller than the packet header.
Note
The buffer must remain valid and unchanged while the packet view is used.

Definition at line 365 of file Packet.h.

◆ reset() [3/3]

void reset ( const void * data,
PacketSize size,
const NoVerify & noVerify )
inlinenoexcept

Rebinds this view to a buffer without validating it.

Parameters
dataAddress of the packet buffer.
sizeBuffer size in bytes.
noVerifyTag selecting the unchecked overload.
Note
The caller must ensure that the buffer contains a complete packet and remains valid while in use.

Definition at line 382 of file Packet.h.

◆ sendingTime()

Messaging::Timestamp sendingTime ( ) const
inlinenoexcept

Returns the packet sending time.

Returns
Sending timestamp stored in the packet header.
Note
This packet must not be null.

Definition at line 334 of file Packet.h.

◆ seqNumber()

SequenceNumber seqNumber ( ) const
inlinenoexcept

Returns the packet sequence number.

Returns
Sequence number stored in the packet header.
Note
This packet must not be null.

Definition at line 322 of file Packet.h.

◆ size()

PacketSize size ( ) const
inlinenoexcept

Returns the packet size.

Returns
Size of the packet buffer in bytes, or zero for a null packet.

Definition at line 312 of file Packet.h.