ITCHCPP 1.6.1
High-Performance NASDAQ TotalView-ITCH 5.0 Parser & Market-Data Platform
Loading...
Searching...
No Matches
soupbintcp.hpp
Go to the documentation of this file.
1#pragma once
2
13
14#include <cstddef>
15#include <cstdint>
16#include <functional>
17#include <span>
18#include <string>
19#include <string_view>
20#include <vector>
21
22#include "itch/parser.hpp"
24
25namespace itch::transport {
26
34enum class SoupBinPacketType : char {
35 debug = '+',
36 login_accepted = 'A',
37 login_rejected = 'J',
38 sequenced_data = 'S',
39 server_heartbeat = 'H',
40 end_of_session = 'Z',
41 login_request = 'L',
42 unsequenced_data = 'U',
43 client_heartbeat = 'R',
44 logout_request = 'O',
45};
46
58 public:
61 std::function<void(SoupBinPacketType type, std::span<const std::byte> payload)>;
62
67 explicit SoupBinDecoder(MessageCallback callback);
68
74 auto feed(std::span<const std::byte> bytes) -> void;
75
79 auto set_event_callback(EventCallback callback) -> void;
80
83 [[nodiscard]] auto tracker() noexcept -> SequenceTracker& { return m_tracker; }
86 [[nodiscard]] auto tracker() const noexcept -> const SequenceTracker& { return m_tracker; }
87
90 [[nodiscard]] auto current_session() const -> std::string_view { return m_session; }
91
94 [[nodiscard]] auto next_sequence() const noexcept -> std::uint64_t { return m_next_sequence; }
95
98 [[nodiscard]] auto messages_decoded() const noexcept -> std::uint64_t {
99 return m_messages_decoded;
100 }
101
102 private:
108 auto process_packet(SoupBinPacketType type, std::span<const std::byte> payload) -> void;
109
115 auto decode_application_message(std::span<const std::byte> payload) -> void;
116
117 Parser m_parser {};
118 MessageCallback m_callback;
119 EventCallback m_event_callback {};
120 SequenceTracker m_tracker {};
121 std::vector<std::byte> m_buffer {};
122 std::string m_session {};
123 std::uint64_t m_next_sequence {1};
124 std::uint64_t m_messages_decoded {0};
125};
126
127} // namespace itch::transport
A high-performance parser for the NASDAQ TotalView-ITCH 5.0 protocol.
Definition parser.hpp:78
Tracks per-session sequence numbers across a transport layer and surfaces gaps.
A stateful decoder for a SoupBinTCP byte stream.
auto set_event_callback(EventCallback callback) -> void
Installs the control-packet event callback (empty clears it).
auto tracker() noexcept -> SequenceTracker &
The embedded sequence tracker (install gap callbacks here).
auto next_sequence() const noexcept -> std::uint64_t
The next sequence number the decoder expects for a data packet.
auto messages_decoded() const noexcept -> std::uint64_t
Total sequenced/unsequenced data messages decoded.
auto current_session() const -> std::string_view
The session id learned from Login Accepted (empty until then).
auto tracker() const noexcept -> const SequenceTracker &
The embedded sequence tracker (install gap callbacks here).
std::function< void(SoupBinPacketType type, std::span< const std::byte > payload)> EventCallback
Invoked for each non-data control packet, with its raw payload.
auto feed(std::span< const std::byte > bytes) -> void
Feeds a chunk of the TCP byte stream, processing any complete packets it completes.
SoupBinPacketType
The SoupBinTCP packet types (the one-byte type that follows the 2-byte length prefix).
@ login_request
Client login request.
@ login_rejected
Reject reason code (1).
@ login_accepted
Session id (10) + starting sequence number (20, ASCII).
@ end_of_session
The server has finished the session.
@ server_heartbeat
Keep-alive from the server.
@ logout_request
Client logout request.
@ unsequenced_data
One unsequenced application message.
@ debug
Free-form debug text (either direction).
@ sequenced_data
One sequenced application (ITCH) message.
@ client_heartbeat
Keep-alive from the client.
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.