MCPcopy Create free account
hub / github.com/Icinga/icinga2 / EncodeValueGenerator

Method EncodeValueGenerator

lib/base/json.cpp:130–141  ·  view source on GitHub ↗

* 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

Source from the content-addressed store, hash-verified

128 * to flush the output stream safely when it has not acquired any object lock on the parent containers.
129 */
130void 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.

Callers

nothing calls this directly

Calls 2

FlushIfSafeMethod · 0.80
NextMethod · 0.45

Tested by

no test coverage detected