MCPcopy Create free account
hub / github.com/TheForceEngine/TheForceEngine / print_object

Function print_object

TheForceEngine/TFE_System/cJSON.c:1719–1830  ·  view source on GitHub ↗

Render an object to text. */

Source from the content-addressed store, hash-verified

1717
1718/* Render an object to text. */
1719static cJSON_bool print_object(const cJSON * const item, printbuffer * const output_buffer)
1720{
1721 unsigned char *output_pointer = NULL;
1722 size_t length = 0;
1723 cJSON *current_item = item->child;
1724
1725 if (output_buffer == NULL)
1726 {
1727 return false;
1728 }
1729
1730 /* Compose the output: */
1731 length = (size_t) (output_buffer->format ? 2 : 1); /* fmt: {\n */
1732 output_pointer = ensure(output_buffer, length + 1);
1733 if (output_pointer == NULL)
1734 {
1735 return false;
1736 }
1737
1738 *output_pointer++ = '{';
1739 output_buffer->depth++;
1740 if (output_buffer->format)
1741 {
1742 *output_pointer++ = '\n';
1743 }
1744 output_buffer->offset += length;
1745
1746 while (current_item)
1747 {
1748 if (output_buffer->format)
1749 {
1750 size_t i;
1751 output_pointer = ensure(output_buffer, output_buffer->depth);
1752 if (output_pointer == NULL)
1753 {
1754 return false;
1755 }
1756 for (i = 0; i < output_buffer->depth; i++)
1757 {
1758 *output_pointer++ = '\t';
1759 }
1760 output_buffer->offset += output_buffer->depth;
1761 }
1762
1763 /* print key */
1764 if (!print_string_ptr((unsigned char*)current_item->string, output_buffer))
1765 {
1766 return false;
1767 }
1768 update_offset(output_buffer);
1769
1770 length = (size_t) (output_buffer->format ? 2 : 1);
1771 output_pointer = ensure(output_buffer, length);
1772 if (output_pointer == NULL)
1773 {
1774 return false;
1775 }
1776 *output_pointer++ = ':';

Callers 1

print_valueFunction · 0.85

Calls 4

ensureFunction · 0.85
print_string_ptrFunction · 0.85
update_offsetFunction · 0.85
print_valueFunction · 0.85

Tested by

no test coverage detected