Lines Matching refs:item
99 CJSON_PUBLIC(char *) cJSON_GetStringValue(const cJSON *const item) in cJSON_GetStringValue() argument
101 if (!cJSON_IsString(item)) return NULL; in cJSON_GetStringValue()
103 return item->valuestring; in cJSON_GetStringValue()
106 CJSON_PUBLIC(double) cJSON_GetNumberValue(const cJSON *const item) in cJSON_GetNumberValue() argument
108 if (!cJSON_IsNumber(item)) return (double)NAN; in cJSON_GetNumberValue()
110 return item->valuedouble; in cJSON_GetNumberValue()
217 CJSON_PUBLIC(void) cJSON_Delete(cJSON *item) in cJSON_Delete() argument
220 while (item != NULL) { in cJSON_Delete()
221 next = item->next; in cJSON_Delete()
222 if (!(item->type & cJSON_IsReference) && (item->child != NULL)) cJSON_Delete(item->child); in cJSON_Delete()
223 …if (!(item->type & cJSON_IsReference) && (item->valuestring != NULL)) global_hooks.deallocate(item… in cJSON_Delete()
224 …if (!(item->type & cJSON_StringIsConst) && (item->string != NULL)) global_hooks.deallocate(item->s… in cJSON_Delete()
225 global_hooks.deallocate(item); in cJSON_Delete()
226 item = next; in cJSON_Delete()
258 static cJSON_bool parse_number(cJSON *const item, parse_buffer *const input_buffer) in parse_number() argument
304 item->valuedouble = number; in parse_number()
308 item->valueint = INT_MAX; in parse_number()
310 item->valueint = INT_MIN; in parse_number()
312 item->valueint = (int)number; in parse_number()
315 item->type = cJSON_Number; in parse_number()
445 static cJSON_bool print_number(const cJSON *const item, printbuffer *const output_buffer) in print_number() argument
448 double d = item->valuedouble; in print_number()
460 } else if (d == (double)item->valueint) { in print_number()
461 …ntf((char *)number_buffer, sizeof(number_buffer) / sizeof(number_buffer[0]), "%d", item->valueint); in print_number()
624 static cJSON_bool parse_string(cJSON *const item, parse_buffer *const input_buffer) in parse_string() argument
708 item->type = cJSON_String; in parse_string()
709 item->valuestring = (char *)output; in parse_string()
828 static cJSON_bool print_string(const cJSON *const item, printbuffer *const p) in print_string() argument
830 return print_string_ptr((unsigned char *)item->valuestring, p); in print_string()
834 static cJSON_bool parse_value(cJSON *const item, parse_buffer *const input_buffer);
835 static cJSON_bool print_value(const cJSON *const item, printbuffer *const output_buffer);
836 static cJSON_bool parse_array(cJSON *const item, parse_buffer *const input_buffer);
837 static cJSON_bool print_array(const cJSON *const item, printbuffer *const output_buffer);
838 static cJSON_bool parse_object(cJSON *const item, parse_buffer *const input_buffer);
839 static cJSON_bool print_object(const cJSON *const item, printbuffer *const output_buffer);
883 cJSON *item = NULL; in cJSON_ParseWithLengthOpts() local
896 item = cJSON_New_Item(&global_hooks); in cJSON_ParseWithLengthOpts()
897 if (item == NULL) /* memory fail */ in cJSON_ParseWithLengthOpts()
902 if (!parse_value(item, buffer_skip_whitespace(skip_utf8_bom(&buffer)))) { in cJSON_ParseWithLengthOpts()
914 return item; in cJSON_ParseWithLengthOpts()
917 if (item != NULL) cJSON_Delete(item); in cJSON_ParseWithLengthOpts()
951 static unsigned char *print(const cJSON *const item, cJSON_bool format, const internal_hooks *const… in print() argument
967 if (!print_value(item, buffer)) goto fail; in print()
997 CJSON_PUBLIC(char *) cJSON_Print(const cJSON *item) in cJSON_Print() argument
999 return (char *)print(item, true, &global_hooks); in cJSON_Print()
1002 CJSON_PUBLIC(char *) cJSON_PrintUnformatted(const cJSON *item) in cJSON_PrintUnformatted() argument
1004 return (char *)print(item, false, &global_hooks); in cJSON_PrintUnformatted()
1007 CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON_bool fmt) in cJSON_PrintBuffered() argument
1024 if (!print_value(item, &p)) { in cJSON_PrintBuffered()
1032 CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const… in cJSON_PrintPreallocated() argument
1047 return print_value(item, &p); in cJSON_PrintPreallocated()
1051 static cJSON_bool parse_value(cJSON *const item, parse_buffer *const input_buffer) in parse_value() argument
1058 item->type = cJSON_NULL; in parse_value()
1064 item->type = cJSON_False; in parse_value()
1070 item->type = cJSON_True; in parse_value()
1071 item->valueint = 1; in parse_value()
1076 …buffer, 0) && (buffer_at_offset(input_buffer)[0] == '\"')) return parse_string(item, input_buffer); in parse_value()
1078 …] >= '0') && (buffer_at_offset(input_buffer)[0] <= '9')))) return parse_number(item, input_buffer); in parse_value()
1080 …t_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '[')) return parse_array(item, input_buffer); in parse_value()
1082 …_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '{')) return parse_object(item, input_buffer); in parse_value()
1088 static cJSON_bool print_value(const cJSON *const item, printbuffer *const output_buffer) in print_value() argument
1092 if ((item == NULL) || (output_buffer == NULL)) return false; in print_value()
1094 switch (item->type & 0xFF) { in print_value()
1114 return print_number(item, output_buffer); in print_value()
1118 if (item->valuestring == NULL) return false; in print_value()
1120 raw_length = strlen(item->valuestring) + sizeof(""); in print_value()
1123 memcpy(output, item->valuestring, raw_length); in print_value()
1128 return print_string(item, output_buffer); in print_value()
1131 return print_array(item, output_buffer); in print_value()
1134 return print_object(item, output_buffer); in print_value()
1142 static cJSON_bool parse_array(cJSON *const item, parse_buffer *const input_buffer) in parse_array() argument
1201 item->type = cJSON_Array; in parse_array()
1202 item->child = head; in parse_array()
1215 static cJSON_bool print_array(const cJSON *const item, printbuffer *const output_buffer) in print_array() argument
1219 cJSON *current_element = item->child; in print_array()
1257 static cJSON_bool parse_object(cJSON *const item, parse_buffer *const input_buffer) in parse_object() argument
1322 item->type = cJSON_Object; in parse_object()
1323 item->child = head; in parse_object()
1335 static cJSON_bool print_object(const cJSON *const item, printbuffer *const output_buffer) in print_object() argument
1339 cJSON *current_item = item->child; in print_object()
1479 static void suffix_object(cJSON *prev, cJSON *item) in suffix_object() argument
1481 prev->next = item; in suffix_object()
1482 item->prev = prev; in suffix_object()
1486 static cJSON *create_reference(const cJSON *item, const internal_hooks *const hooks) in create_reference() argument
1489 if (item == NULL) return NULL; in create_reference()
1494 memcpy(reference, item, sizeof(cJSON)); in create_reference()
1501 static cJSON_bool add_item_to_array(cJSON *array, cJSON *item) in add_item_to_array() argument
1505 if ((item == NULL) || (array == NULL) || (array == item)) return false; in add_item_to_array()
1513 array->child = item; in add_item_to_array()
1514 item->prev = item; in add_item_to_array()
1515 item->next = NULL; in add_item_to_array()
1519 suffix_object(child->prev, item); in add_item_to_array()
1520 array->child->prev = item; in add_item_to_array()
1528 CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToArray(cJSON *array, cJSON *item) in cJSON_AddItemToArray() argument
1530 return add_item_to_array(array, item); in cJSON_AddItemToArray()
1548 …tem_to_object(cJSON *const object, const char *const string, cJSON *const item, const internal_hoo… in add_item_to_object() argument
1553 if ((object == NULL) || (string == NULL) || (item == NULL) || (object == item)) return false; in add_item_to_object()
1557 new_type = item->type | cJSON_StringIsConst; in add_item_to_object()
1562 new_type = item->type & ~cJSON_StringIsConst; in add_item_to_object()
1565 …if (!(item->type & cJSON_StringIsConst) && (item->string != NULL)) hooks->deallocate(item->string); in add_item_to_object()
1567 item->string = new_key; in add_item_to_object()
1568 item->type = new_type; in add_item_to_object()
1570 return add_item_to_array(object, item); in add_item_to_object()
1573 CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item) in cJSON_AddItemToObject() argument
1575 return add_item_to_object(object, string, item, &global_hooks, false); in cJSON_AddItemToObject()
1579 CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item) in cJSON_AddItemToObjectCS() argument
1581 return add_item_to_object(object, string, item, &global_hooks, true); in cJSON_AddItemToObjectCS()
1584 CJSON_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item) in cJSON_AddItemReferenceToArray() argument
1588 return add_item_to_array(array, create_reference(item, &global_hooks)); in cJSON_AddItemReferenceToArray()
1591 …N_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item) in cJSON_AddItemReferenceToObject() argument
1595 …return add_item_to_object(object, string, create_reference(item, &global_hooks), &global_hooks, fa… in cJSON_AddItemReferenceToObject()
1679 CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON *const item) in cJSON_DetachItemViaPointer() argument
1681 if ((parent == NULL) || (item == NULL)) return NULL; in cJSON_DetachItemViaPointer()
1683 if (item != parent->child) { in cJSON_DetachItemViaPointer()
1685 item->prev->next = item->next; in cJSON_DetachItemViaPointer()
1687 if (item->next != NULL) { in cJSON_DetachItemViaPointer()
1689 item->next->prev = item->prev; in cJSON_DetachItemViaPointer()
1692 if (item == parent->child) { in cJSON_DetachItemViaPointer()
1694 parent->child = item->next; in cJSON_DetachItemViaPointer()
1695 } else if (item->next == NULL) { in cJSON_DetachItemViaPointer()
1697 parent->child->prev = item->prev; in cJSON_DetachItemViaPointer()
1701 item->prev = NULL; in cJSON_DetachItemViaPointer()
1702 item->next = NULL; in cJSON_DetachItemViaPointer()
1704 return item; in cJSON_DetachItemViaPointer()
1764 CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON *const parent, cJSON *const item, cJSON … in cJSON_ReplaceItemViaPointer() argument
1766 if ((parent == NULL) || (replacement == NULL) || (item == NULL)) return false; in cJSON_ReplaceItemViaPointer()
1768 if (replacement == item) return true; in cJSON_ReplaceItemViaPointer()
1770 replacement->next = item->next; in cJSON_ReplaceItemViaPointer()
1771 replacement->prev = item->prev; in cJSON_ReplaceItemViaPointer()
1774 if (parent->child == item) { in cJSON_ReplaceItemViaPointer()
1785 item->next = NULL; in cJSON_ReplaceItemViaPointer()
1786 item->prev = NULL; in cJSON_ReplaceItemViaPointer()
1787 cJSON_Delete(item); in cJSON_ReplaceItemViaPointer()
1826 cJSON *item = cJSON_New_Item(&global_hooks); in cJSON_CreateNull() local
1827 if (item) item->type = cJSON_NULL; in cJSON_CreateNull()
1829 return item; in cJSON_CreateNull()
1834 cJSON *item = cJSON_New_Item(&global_hooks); in cJSON_CreateTrue() local
1835 if (item) item->type = cJSON_True; in cJSON_CreateTrue()
1837 return item; in cJSON_CreateTrue()
1842 cJSON *item = cJSON_New_Item(&global_hooks); in cJSON_CreateFalse() local
1843 if (item) item->type = cJSON_False; in cJSON_CreateFalse()
1845 return item; in cJSON_CreateFalse()
1850 cJSON *item = cJSON_New_Item(&global_hooks); in cJSON_CreateBool() local
1851 if (item) item->type = boolean ? cJSON_True : cJSON_False; in cJSON_CreateBool()
1853 return item; in cJSON_CreateBool()
1858 cJSON *item = cJSON_New_Item(&global_hooks); in cJSON_CreateNumber() local
1859 if (item) { in cJSON_CreateNumber()
1860 item->type = cJSON_Number; in cJSON_CreateNumber()
1861 item->valuedouble = num; in cJSON_CreateNumber()
1865 item->valueint = INT_MAX; in cJSON_CreateNumber()
1867 item->valueint = INT_MIN; in cJSON_CreateNumber()
1869 item->valueint = (int)num; in cJSON_CreateNumber()
1873 return item; in cJSON_CreateNumber()
1878 cJSON *item = cJSON_New_Item(&global_hooks); in cJSON_CreateString() local
1879 if (item) { in cJSON_CreateString()
1880 item->type = cJSON_String; in cJSON_CreateString()
1881 item->valuestring = (char *)cJSON_strdup((const unsigned char *)string, &global_hooks); in cJSON_CreateString()
1882 if (!item->valuestring) { in cJSON_CreateString()
1883 cJSON_Delete(item); in cJSON_CreateString()
1888 return item; in cJSON_CreateString()
1893 cJSON *item = cJSON_New_Item(&global_hooks); in cJSON_CreateStringReference() local
1894 if (item != NULL) { in cJSON_CreateStringReference()
1895 item->type = cJSON_String | cJSON_IsReference; in cJSON_CreateStringReference()
1896 item->valuestring = (char *)cast_away_const(string); in cJSON_CreateStringReference()
1899 return item; in cJSON_CreateStringReference()
1904 cJSON *item = cJSON_New_Item(&global_hooks); in cJSON_CreateObjectReference() local
1905 if (item != NULL) { in cJSON_CreateObjectReference()
1906 item->type = cJSON_Object | cJSON_IsReference; in cJSON_CreateObjectReference()
1907 item->child = (cJSON *)cast_away_const(child); in cJSON_CreateObjectReference()
1910 return item; in cJSON_CreateObjectReference()
1915 cJSON *item = cJSON_New_Item(&global_hooks); in cJSON_CreateArrayReference() local
1916 if (item != NULL) { in cJSON_CreateArrayReference()
1917 item->type = cJSON_Array | cJSON_IsReference; in cJSON_CreateArrayReference()
1918 item->child = (cJSON *)cast_away_const(child); in cJSON_CreateArrayReference()
1921 return item; in cJSON_CreateArrayReference()
1926 cJSON *item = cJSON_New_Item(&global_hooks); in cJSON_CreateRaw() local
1927 if (item) { in cJSON_CreateRaw()
1928 item->type = cJSON_Raw; in cJSON_CreateRaw()
1929 item->valuestring = (char *)cJSON_strdup((const unsigned char *)raw, &global_hooks); in cJSON_CreateRaw()
1930 if (!item->valuestring) { in cJSON_CreateRaw()
1931 cJSON_Delete(item); in cJSON_CreateRaw()
1936 return item; in cJSON_CreateRaw()
1941 cJSON *item = cJSON_New_Item(&global_hooks); in cJSON_CreateArray() local
1942 if (item) item->type = cJSON_Array; in cJSON_CreateArray()
1944 return item; in cJSON_CreateArray()
1949 cJSON *item = cJSON_New_Item(&global_hooks); in cJSON_CreateObject() local
1950 if (item) item->type = cJSON_Object; in cJSON_CreateObject()
1952 return item; in cJSON_CreateObject()
2077 CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse) in cJSON_Duplicate() argument
2085 if (!item) goto fail; in cJSON_Duplicate()
2090 newitem->type = item->type & (~cJSON_IsReference); in cJSON_Duplicate()
2091 newitem->valueint = item->valueint; in cJSON_Duplicate()
2092 newitem->valuedouble = item->valuedouble; in cJSON_Duplicate()
2093 if (item->valuestring) { in cJSON_Duplicate()
2094 newitem->valuestring = (char *)cJSON_strdup((unsigned char *)item->valuestring, &global_hooks); in cJSON_Duplicate()
2097 if (item->string) { in cJSON_Duplicate()
2098 …newitem->string = (item->type & cJSON_StringIsConst) ? item->string : (char *)cJSON_strdup((unsign… in cJSON_Duplicate()
2104 child = item->child; in cJSON_Duplicate()
2216 CJSON_PUBLIC(cJSON_bool) cJSON_IsInvalid(const cJSON *const item) in cJSON_IsInvalid() argument
2218 if (item == NULL) return false; in cJSON_IsInvalid()
2220 return (item->type & 0xFF) == cJSON_Invalid; in cJSON_IsInvalid()
2223 CJSON_PUBLIC(cJSON_bool) cJSON_IsFalse(const cJSON *const item) in cJSON_IsFalse() argument
2225 if (item == NULL) return false; in cJSON_IsFalse()
2227 return (item->type & 0xFF) == cJSON_False; in cJSON_IsFalse()
2230 CJSON_PUBLIC(cJSON_bool) cJSON_IsTrue(const cJSON *const item) in cJSON_IsTrue() argument
2232 if (item == NULL) return false; in cJSON_IsTrue()
2234 return (item->type & 0xff) == cJSON_True; in cJSON_IsTrue()
2237 CJSON_PUBLIC(cJSON_bool) cJSON_IsBool(const cJSON *const item) in cJSON_IsBool() argument
2239 if (item == NULL) return false; in cJSON_IsBool()
2241 return (item->type & (cJSON_True | cJSON_False)) != 0; in cJSON_IsBool()
2243 CJSON_PUBLIC(cJSON_bool) cJSON_IsNull(const cJSON *const item) in cJSON_IsNull() argument
2245 if (item == NULL) return false; in cJSON_IsNull()
2247 return (item->type & 0xFF) == cJSON_NULL; in cJSON_IsNull()
2250 CJSON_PUBLIC(cJSON_bool) cJSON_IsNumber(const cJSON *const item) in cJSON_IsNumber() argument
2252 if (item == NULL) return false; in cJSON_IsNumber()
2254 return (item->type & 0xFF) == cJSON_Number; in cJSON_IsNumber()
2257 CJSON_PUBLIC(cJSON_bool) cJSON_IsString(const cJSON *const item) in cJSON_IsString() argument
2259 if (item == NULL) return false; in cJSON_IsString()
2261 return (item->type & 0xFF) == cJSON_String; in cJSON_IsString()
2264 CJSON_PUBLIC(cJSON_bool) cJSON_IsArray(const cJSON *const item) in cJSON_IsArray() argument
2266 if (item == NULL) return false; in cJSON_IsArray()
2268 return (item->type & 0xFF) == cJSON_Array; in cJSON_IsArray()
2271 CJSON_PUBLIC(cJSON_bool) cJSON_IsObject(const cJSON *const item) in cJSON_IsObject() argument
2273 if (item == NULL) return false; in cJSON_IsObject()
2275 return (item->type & 0xFF) == cJSON_Object; in cJSON_IsObject()
2278 CJSON_PUBLIC(cJSON_bool) cJSON_IsRaw(const cJSON *const item) in cJSON_IsRaw() argument
2280 if (item == NULL) return false; in cJSON_IsRaw()
2282 return (item->type & 0xFF) == cJSON_Raw; in cJSON_IsRaw()