Sourcemeta Core 0.0.0
Loading...
Searching...
No Matches
jsonl.h
1#ifndef SOURCEMETA_CORE_JSONL_H_
2#define SOURCEMETA_CORE_JSONL_H_
3
4#ifndef SOURCEMETA_CORE_JSONL_EXPORT
5#include <sourcemeta/core/jsonl_export.h>
6#endif
7
8#include <sourcemeta/core/json.h>
9
10// NOLINTBEGIN(misc-include-cleaner)
11#include <sourcemeta/core/jsonl_iterator.h>
12// NOLINTEND(misc-include-cleaner)
13
14#include <cstdint> // std::uint8_t
15#include <istream> // std::basic_istream
16#include <memory> // std::unique_ptr
17
58
59namespace sourcemeta::core {
60
63class SOURCEMETA_CORE_JSONL_EXPORT JSONL {
64public:
66 enum class Mode : std::uint8_t {
68 Raw,
71 };
72
116 JSONL(std::basic_istream<JSON::Char, JSON::CharTraits> &input,
118 ~JSONL();
119
120 JSONL(const JSONL &) = delete;
121 auto operator=(const JSONL &) -> JSONL & = delete;
122 JSONL(JSONL &&) = delete;
123 auto operator=(JSONL &&) -> JSONL & = delete;
124
125 using const_iterator = ConstJSONLIterator;
126 auto begin() -> const_iterator;
127 auto end() -> const_iterator;
128 auto cbegin() -> const_iterator;
129 auto cend() -> const_iterator;
130
131private:
132// Exporting symbols that depends on the standard C++ library is considered
133// safe.
134// https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-2-c4275?view=msvc-170&redirectedfrom=MSDN
135#if defined(_MSC_VER)
136#pragma warning(push)
137#pragma warning(disable : 4251)
138#endif
139 std::basic_istream<JSON::Char, JSON::CharTraits> *stream_;
140 JSONLFraming framing_;
141 struct Internal;
142 std::unique_ptr<Internal> internal_;
143#if defined(_MSC_VER)
144#pragma warning(pop)
145#endif
146};
147
148} // namespace sourcemeta::core
149
150#endif
@ GZIP
The gzip coding per RFC 9110 ยง8.4.1.3.
Definition http.h:57
Mode
The mode of operation for the JSONL parser.
Definition jsonl.h:66
@ Raw
The input stream contains raw JSONL text.
Definition jsonl.h:68
JSONL(std::basic_istream< JSON::Char, JSON::CharTraits > &input, Mode mode=Mode::Raw, JSONLFraming framing=JSONLFraming::LineFeed)
Definition jsonl_iterator.h:31
JSONLFraming
Definition jsonl_iterator.h:20
@ LineFeed
Every value is terminated by a line feed, as in JSON Lines and NDJSON.
Definition jsonl_iterator.h:22