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

Function print_value

TheForceEngine/TFE_System/cJSON.c:1372–1443  ·  view source on GitHub ↗

Render a value to text. */

Source from the content-addressed store, hash-verified

1370
1371/* Render a value to text. */
1372static cJSON_bool print_value(const cJSON * const item, printbuffer * const output_buffer)
1373{
1374 unsigned char *output = NULL;
1375
1376 if ((item == NULL) || (output_buffer == NULL))
1377 {
1378 return false;
1379 }
1380
1381 switch ((item->type) & 0xFF)
1382 {
1383 case cJSON_NULL:
1384 output = ensure(output_buffer, 5);
1385 if (output == NULL)
1386 {
1387 return false;
1388 }
1389 strcpy((char*)output, "null");
1390 return true;
1391
1392 case cJSON_False:
1393 output = ensure(output_buffer, 6);
1394 if (output == NULL)
1395 {
1396 return false;
1397 }
1398 strcpy((char*)output, "false");
1399 return true;
1400
1401 case cJSON_True:
1402 output = ensure(output_buffer, 5);
1403 if (output == NULL)
1404 {
1405 return false;
1406 }
1407 strcpy((char*)output, "true");
1408 return true;
1409
1410 case cJSON_Number:
1411 return print_number(item, output_buffer);
1412
1413 case cJSON_Raw:
1414 {
1415 size_t raw_length = 0;
1416 if (item->valuestring == NULL)
1417 {
1418 return false;
1419 }
1420
1421 raw_length = strlen(item->valuestring) + sizeof("");
1422 output = ensure(output_buffer, raw_length);
1423 if (output == NULL)
1424 {
1425 return false;
1426 }
1427 memcpy(output, item->valuestring, raw_length);
1428 return true;
1429 }

Callers 5

printFunction · 0.85
cJSON_PrintBufferedFunction · 0.85
cJSON_PrintPreallocatedFunction · 0.85
print_arrayFunction · 0.85
print_objectFunction · 0.85

Calls 5

ensureFunction · 0.85
print_numberFunction · 0.85
print_stringFunction · 0.85
print_arrayFunction · 0.85
print_objectFunction · 0.85

Tested by

no test coverage detected