NeoGraph 0.10.0
A C++17 Graph Agent Engine Library — LangGraph for C++
Loading...
Searching...
No Matches
sse_parser.h
Go to the documentation of this file.
1
22#pragma once
23
24#include <neograph/api.h>
25
26#include <string>
27#include <string_view>
28#include <vector>
29
30namespace neograph::async {
31
32struct SseEvent {
33 std::string event;
34 std::string data;
35 std::string id;
36};
37
38class NEOGRAPH_API SseEventParser {
39public:
42 void feed(std::string_view bytes);
43
46 std::vector<SseEvent> drain();
47
51 void reset() noexcept;
52
53private:
54 void consume_line(std::string_view line);
55 void finish_event();
56
57 std::string raw_;
58 std::string cur_data_;
59 std::string cur_event_;
60 std::string cur_id_;
61 bool cur_in_progress_ = false;
62 std::vector<SseEvent> pending_;
63};
64
65} // namespace neograph::async
NEOGRAPH_API export/import macro for shared-library builds.