* Encodes a ValueGenerator object into JSON and writes it to the output stream. * * This will iterate through the generator, encoding each value it produces until it is exhausted. * * @param generator The ValueGenerator object to be serialized into JSON. * @param yc The optional yield context for asynchronous operations. If provided, it allows the encoder * to flush the output stream safely
| 128 | * to flush the output stream safely when it has not acquired any object lock on the parent containers. |
| 129 | */ |
| 130 | void JsonEncoder::EncodeValueGenerator(const Generator::Ptr& generator, boost::asio::yield_context* yc) |
| 131 | { |
| 132 | BeginContainer('['); |
| 133 | bool isEmpty = true; |
| 134 | while (auto result = generator->Next()) { |
| 135 | WriteSeparatorAndIndentStrIfNeeded(!isEmpty); |
| 136 | isEmpty = false; |
| 137 | Encode(*result, yc); |
| 138 | m_Flusher.FlushIfSafe(yc); |
| 139 | } |
| 140 | EndContainer(']', isEmpty); |
| 141 | } |
| 142 | |
| 143 | /** |
| 144 | * Encodes an Icinga 2 object (Namespace or Dictionary) into JSON and writes it to @c m_Writer. |
nothing calls this directly
no test coverage detected