Writes one JSON document per line (JSON Lines / NDJSON).
More...
#include <sinks.hpp>
|
| | jsonl_writer (std::ostream &out) |
| | Write to out, which must outlive the writer.
|
| |
| void | write_line (std::string_view json) |
| | Write one document as a line.
|
| |
| template<json_result T> |
| void | operator() (std::uint64_t, const T &item) |
| | Sink call: write the item's to_json().
|
| |
| std::size_t | lines () const noexcept |
| | Lines written so far.
|
| |
Writes one JSON document per line (JSON Lines / NDJSON).
Use it as the sink of for_each_batch(); results need to_json().
gen.for_each_name(request, {.count = 1000}, 7, out);
Writes one JSON document per line (JSON Lines / NDJSON).
Definition at line 300 of file sinks.hpp.
◆ jsonl_writer()
| dasmig::core::jsonl_writer::jsonl_writer |
( |
std::ostream & |
out | ) |
|
|
inlineexplicit |
Write to out, which must outlive the writer.
- Parameters
-
Definition at line 305 of file sinks.hpp.
◆ lines()
| std::size_t dasmig::core::jsonl_writer::lines |
( |
| ) |
const |
|
inlinenoexcept |
Lines written so far.
- Returns
- The count.
Definition at line 331 of file sinks.hpp.
◆ operator()()
template<json_result T>
| void dasmig::core::jsonl_writer::operator() |
( |
std::uint64_t |
, |
|
|
const T & |
item |
|
) |
| |
|
inline |
Sink call: write the item's to_json().
- Parameters
-
Definition at line 324 of file sinks.hpp.
◆ write_line()
| void dasmig::core::jsonl_writer::write_line |
( |
std::string_view |
json | ) |
|
|
inline |
Write one document as a line.
- Parameters
-
| json | Compact JSON; it must not contain a line break. |
- Exceptions
-
| std::invalid_argument | If json contains a line break. |
Definition at line 310 of file sinks.hpp.
The documentation for this class was generated from the following file: