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

Method EndContainer

lib/base/json.cpp:263–274  ·  view source on GitHub ↗

* Ends a JSON container (object or array) by writing the closing character and adjusting the * indentation level if pretty-printing is enabled. * * @param closeChar The character that closes the container (either '}' for objects or ']' for arrays). * @param isContainerEmpty Whether the container is empty, used to determine if a newline should be written. */

Source from the content-addressed store, hash-verified

261 * @param isContainerEmpty Whether the container is empty, used to determine if a newline should be written.
262 */
263void JsonEncoder::EndContainer(char closeChar, bool isContainerEmpty)
264{
265 if (m_Pretty) {
266 ASSERT(m_Indent >= m_IndentSize); // Ensure we don't underflow the indent size.
267 m_Indent -= m_IndentSize;
268 if (!isContainerEmpty) {
269 Write("\n");
270 m_Writer->write_characters(m_IndentStr.c_str(), m_Indent);
271 }
272 }
273 m_Writer->write_character(closeChar);
274}
275
276/**
277 * Writes a separator (comma) and an indentation string if pretty-printing is enabled.

Callers

nothing calls this directly

Calls 2

write_charactersMethod · 0.80
write_characterMethod · 0.45

Tested by

no test coverage detected