ITCHCPP 1.6.0
High-Performance NASDAQ TotalView-ITCH 5.0 Parser & Market-Data Platform
Loading...
Searching...
No Matches
itch::overlay::MessageView Class Reference

A zero-copy typed view over one raw ITCH frame. More...

#include <overlay.hpp>

+ Inheritance diagram for itch::overlay::MessageView:

Public Member Functions

constexpr MessageView () noexcept=default
 Constructs an empty view with no underlying frame.
 
 MessageView (const std::byte *data, std::size_t size) noexcept
 Constructs a view over a raw ITCH message frame.
 
auto type () const noexcept -> char
 The one-byte message type.
 
auto stock_locate () const noexcept -> std::uint16_t
 The locate code identifying the security.
 
auto tracking_number () const noexcept -> std::uint16_t
 The Nasdaq internal tracking number.
 
auto timestamp () const noexcept -> std::uint64_t
 The message timestamp (nanoseconds past midnight).
 
auto size () const noexcept -> std::size_t
 The raw frame size in bytes.
 
auto data () const noexcept -> const std::byte *
 Pointer to the raw frame (the type byte).
 
template<typename FieldType >
auto read (std::size_t offset) const noexcept -> FieldType
 Reads an arbitrary integral field at a byte offset, big-endian.
 

Protected Attributes

const std::byte * m_data {nullptr}
 
std::size_t m_size {0}
 

Detailed Description

A zero-copy typed view over one raw ITCH frame.

In contrast to the eager Parser, which decodes every field of a message into a host-order struct, an overlay view holds only a pointer to the frame in the original buffer and converts each field from network byte order lazily, on the access. For callers that touch only a few fields per message (for example a filter that reads just the stock and price), this avoids decoding the fields they never look at. The view is non-owning: it is valid only while the underlying buffer lives.

Definition at line 88 of file overlay.hpp.

Constructor & Destructor Documentation

◆ MessageView() [1/2]

constexpr itch::overlay::MessageView::MessageView ( )
constexprdefaultnoexcept

Constructs an empty view with no underlying frame.

◆ MessageView() [2/2]

itch::overlay::MessageView::MessageView ( const std::byte *  data,
std::size_t  size 
)
inlineexplicitnoexcept

Constructs a view over a raw ITCH message frame.

Parameters
dataPointer to the start of the frame (the type byte).
sizeSize of the frame in bytes.

Definition at line 97 of file overlay.hpp.

References data().

Member Function Documentation

◆ type()

auto itch::overlay::MessageView::type ( ) const -> char
inlinenoexcept

The one-byte message type.

Returns
The one-byte message type.

Definition at line 102 of file overlay.hpp.

References m_data.

◆ stock_locate()

auto itch::overlay::MessageView::stock_locate ( ) const -> std::uint16_t
inlinenoexcept

The locate code identifying the security.

Returns
The locate code identifying the security.

Definition at line 108 of file overlay.hpp.

References m_data, and itch::overlay::detail::STOCK_LOCATE_OFFSET.

◆ tracking_number()

auto itch::overlay::MessageView::tracking_number ( ) const -> std::uint16_t
inlinenoexcept

The Nasdaq internal tracking number.

Returns
The Nasdaq internal tracking number.

Definition at line 114 of file overlay.hpp.

References m_data, and itch::overlay::detail::TRACKING_NUMBER_OFFSET.

◆ timestamp()

auto itch::overlay::MessageView::timestamp ( ) const -> std::uint64_t
inlinenoexcept

The message timestamp (nanoseconds past midnight).

Returns
The message timestamp (nanoseconds past midnight).

Definition at line 120 of file overlay.hpp.

References m_data, itch::overlay::detail::read_timestamp(), and itch::overlay::detail::TIMESTAMP_OFFSET.

◆ size()

auto itch::overlay::MessageView::size ( ) const -> std::size_t
inlinenoexcept

The raw frame size in bytes.

Returns
The raw frame size in bytes.

Definition at line 126 of file overlay.hpp.

References m_size.

◆ data()

auto itch::overlay::MessageView::data ( ) const -> const std::byte*
inlinenoexcept

Pointer to the raw frame (the type byte).

Returns
Pointer to the raw frame (the type byte).

Definition at line 130 of file overlay.hpp.

References m_data.

Referenced by MessageView().

◆ read()

template<typename FieldType >
auto itch::overlay::MessageView::read ( std::size_t  offset) const -> FieldType
inlinenoexcept

Reads an arbitrary integral field at a byte offset, big-endian.

Template Parameters
FieldTypeThe type of the field to read.
Parameters
offsetByte offset of the field within the frame.
Returns
The field value, converted from big-endian if it is a multi-byte integral type.

Definition at line 139 of file overlay.hpp.

References m_data.

Member Data Documentation

◆ m_data

const std::byte* itch::overlay::MessageView::m_data {nullptr}
protected

◆ m_size

std::size_t itch::overlay::MessageView::m_size {0}
protected

Definition at line 145 of file overlay.hpp.

Referenced by size().


The documentation for this class was generated from the following file: