ITCHCPP 1.6.1
High-Performance NASDAQ TotalView-ITCH 5.0 Parser & Market-Data Platform
Loading...
Searching...
No Matches
moldudp64.hpp
Go to the documentation of this file.
1#pragma once
2
12
13#include <array>
14#include <cstddef>
15#include <cstdint>
16#include <optional>
17#include <span>
18#include <string_view>
19
20#include "itch/parser.hpp"
22
23namespace itch::transport {
24
35 std::array<char, 10> session {};
36 std::uint64_t sequence_number {0};
37 std::uint16_t message_count {0};
38
40 static constexpr std::uint16_t END_OF_SESSION = 0xFFFF;
41
44 [[nodiscard]] auto session_view() const -> std::string_view {
45 std::size_t length = session.size();
46 while (length > 0 && (session[length - 1] == ' ' || session[length - 1] == '\0')) {
47 --length;
48 }
49 return std::string_view {session.data(), length};
50 }
51
54 [[nodiscard]] auto is_heartbeat() const noexcept -> bool { return message_count == 0; }
55
58 [[nodiscard]] auto is_end_of_session() const noexcept -> bool {
60 }
61};
62
72 public:
74 static constexpr std::size_t HEADER_SIZE = 20;
75
79 explicit MoldUdp64Decoder(MessageCallback callback);
80
86 auto decode_packet(std::span<const std::byte> packet) -> std::optional<MoldUdp64Header>;
87
90 [[nodiscard]] auto tracker() noexcept -> SequenceTracker& { return m_tracker; }
93 [[nodiscard]] auto tracker() const noexcept -> const SequenceTracker& { return m_tracker; }
94
97 [[nodiscard]] auto packets_decoded() const noexcept -> std::uint64_t {
98 return m_packets_decoded;
99 }
100
103 [[nodiscard]] auto messages_decoded() const noexcept -> std::uint64_t {
104 return m_messages_decoded;
105 }
106
107 private:
108 Parser m_parser {};
109 MessageCallback m_callback;
110 SequenceTracker m_tracker {};
111 std::uint64_t m_packets_decoded {0};
112 std::uint64_t m_messages_decoded {0};
113};
114
115} // namespace itch::transport
A high-performance parser for the NASDAQ TotalView-ITCH 5.0 protocol.
Definition parser.hpp:78
Decodes MoldUDP64 datagrams and forwards the contained ITCH messages.
Definition moldudp64.hpp:71
static constexpr std::size_t HEADER_SIZE
The on-wire size of the MoldUDP64 packet header, in bytes.
Definition moldudp64.hpp:74
auto decode_packet(std::span< const std::byte > packet) -> std::optional< MoldUdp64Header >
Decodes a single MoldUDP64 datagram.
Definition moldudp64.cpp:23
auto tracker() const noexcept -> const SequenceTracker &
The embedded sequence tracker (install gap callbacks here).
Definition moldudp64.hpp:93
auto tracker() noexcept -> SequenceTracker &
The embedded sequence tracker (install gap callbacks here).
Definition moldudp64.hpp:90
auto packets_decoded() const noexcept -> std::uint64_t
Total number of datagrams passed to decode_packet.
Definition moldudp64.hpp:97
auto messages_decoded() const noexcept -> std::uint64_t
Total number of ITCH messages decoded from all datagrams.
Tracks per-session sequence numbers across a transport layer and surfaces gaps.
std::function< void(const Message &)> MessageCallback
The signature for the callback function used in streaming parse methods.
Definition parser.hpp:40
Public parsing interface for NASDAQ TotalView-ITCH 5.0 feeds, plus the low-level byte-unpacking utili...
Per-session sequence-gap detection shared by the MoldUDP64 and SoupBinTCP transport decoders.
The fixed 20-byte header that prefixes every MoldUDP64 downstream packet.
Definition moldudp64.hpp:34
auto is_end_of_session() const noexcept -> bool
End-of-session is signalled by the sentinel message_count.
Definition moldudp64.hpp:58
std::uint64_t sequence_number
Sequence of the first message block.
Definition moldudp64.hpp:36
std::array< char, 10 > session
Session id, space padded.
Definition moldudp64.hpp:35
static constexpr std::uint16_t END_OF_SESSION
Sentinel message_count indicating an end-of-session packet.
Definition moldudp64.hpp:40
auto session_view() const -> std::string_view
The session id as a view with trailing padding removed.
Definition moldudp64.hpp:44
auto is_heartbeat() const noexcept -> bool
A heartbeat carries no message blocks (message_count == 0).
Definition moldudp64.hpp:54
std::uint16_t message_count
Number of message blocks in the packet.
Definition moldudp64.hpp:37