Lines Matching refs:item

106 CJSON_PUBLIC(char *) cJSON_GetStringValue(cJSON *item)   in cJSON_GetStringValue()  argument
108 if (!cJSON_IsString(item)) in cJSON_GetStringValue()
113 return item->valuestring; in cJSON_GetStringValue()
116 CJSON_PUBLIC(double) cJSON_GetNumberValue(cJSON *item) in cJSON_GetNumberValue() argument
118 if (!cJSON_IsNumber(item)) in cJSON_GetNumberValue()
123 return item->valuedouble; in cJSON_GetNumberValue()
260 CJSON_PUBLIC(void) cJSON_Delete(cJSON *item) in cJSON_Delete() argument
263 while (item != NULL) in cJSON_Delete()
265 next = item->next; in cJSON_Delete()
266 if (!(item->type & cJSON_IsReference) && (item->child != NULL)) in cJSON_Delete()
268 cJSON_Delete(item->child); in cJSON_Delete()
270 if (!(item->type & cJSON_IsReference) && (item->valuestring != NULL)) in cJSON_Delete()
272 global_hooks.deallocate(item->valuestring); in cJSON_Delete()
274 if (!(item->type & cJSON_StringIsConst) && (item->string != NULL)) in cJSON_Delete()
276 global_hooks.deallocate(item->string); in cJSON_Delete()
278 global_hooks.deallocate(item); in cJSON_Delete()
279 item = next; in cJSON_Delete()
312 static cJSON_bool parse_number(cJSON * const item, parse_buffer * const input_buffer) in parse_number() argument
366 item->valuedouble = number; in parse_number()
371 item->valueint = LLONG_MAX; in parse_number()
375 item->valueint = LLONG_MIN; in parse_number()
379 item->valueint = (int64_t)number; in parse_number()
382 item->type = cJSON_Number; in parse_number()
554 static cJSON_bool print_number(const cJSON * const item, printbuffer * const output_buffer) in print_number() argument
557 double d = item->valuedouble; in print_number()
778 static cJSON_bool parse_string(cJSON * const item, parse_buffer * const input_buffer) in parse_string() argument
884 item->type = cJSON_String; in parse_string()
885 item->valuestring = (char*)output; in parse_string()
1029 static cJSON_bool print_string(const cJSON * const item, printbuffer * const p) in print_string() argument
1031 return print_string_ptr((unsigned char*)item->valuestring, p); in print_string()
1035 static cJSON_bool parse_value(cJSON * const item, parse_buffer * const input_buffer);
1036 static cJSON_bool print_value(const cJSON * const item, printbuffer * const output_buffer);
1037 static cJSON_bool parse_array(cJSON * const item, parse_buffer * const input_buffer);
1038 static cJSON_bool print_array(const cJSON * const item, printbuffer * const output_buffer);
1039 static cJSON_bool parse_object(cJSON * const item, parse_buffer * const input_buffer);
1040 static cJSON_bool print_object(const cJSON * const item, printbuffer * const output_buffer);
1103 cJSON *item = NULL; in cJSON_ParseWithLengthOpts() local
1119 item = cJSON_New_Item(&global_hooks); in cJSON_ParseWithLengthOpts()
1120 if (item == NULL) /* memory fail */ in cJSON_ParseWithLengthOpts()
1125 if (!parse_value(item, buffer_skip_whitespace(skip_utf8_bom(&buffer)))) in cJSON_ParseWithLengthOpts()
1145 return item; in cJSON_ParseWithLengthOpts()
1148 if (item != NULL) in cJSON_ParseWithLengthOpts()
1150 cJSON_Delete(item); in cJSON_ParseWithLengthOpts()
1192 static unsigned char *print(const cJSON * const item, cJSON_bool format, const internal_hooks * con… in print() argument
1211 if (!print_value(item, buffer)) in print()
1257 CJSON_PUBLIC(char *) cJSON_Print(const cJSON *item) in cJSON_Print() argument
1259 return (char*)print(item, true, &global_hooks); in cJSON_Print()
1262 CJSON_PUBLIC(char *) cJSON_PrintUnformatted(const cJSON *item) in cJSON_PrintUnformatted() argument
1264 return (char*)print(item, false, &global_hooks); in cJSON_PrintUnformatted()
1267 CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON_bool fmt) in cJSON_PrintBuffered() argument
1288 if (!print_value(item, &p)) in cJSON_PrintBuffered()
1297 CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const… in cJSON_PrintPreallocated() argument
1313 return print_value(item, &p); in cJSON_PrintPreallocated()
1317 static cJSON_bool parse_value(cJSON * const item, parse_buffer * const input_buffer) in parse_value() argument
1328 item->type = cJSON_NULL; in parse_value()
1335 item->type = cJSON_False; in parse_value()
1342 item->type = cJSON_True; in parse_value()
1343 item->valueint = 1; in parse_value()
1350 return parse_string(item, input_buffer); in parse_value()
1355 return parse_number(item, input_buffer); in parse_value()
1360 return parse_array(item, input_buffer); in parse_value()
1365 return parse_object(item, input_buffer); in parse_value()
1372 static cJSON_bool print_value(const cJSON * const item, printbuffer * const output_buffer) in print_value() argument
1376 if ((item == NULL) || (output_buffer == NULL)) in print_value()
1381 switch ((item->type) & 0xFF) in print_value()
1411 return print_number(item, output_buffer); in print_value()
1416 if (item->valuestring == NULL) in print_value()
1421 raw_length = strlen(item->valuestring) + sizeof(""); in print_value()
1427 memcpy(output, item->valuestring, raw_length); in print_value()
1432 return print_string(item, output_buffer); in print_value()
1435 return print_array(item, output_buffer); in print_value()
1438 return print_object(item, output_buffer); in print_value()
1446 static cJSON_bool parse_array(cJSON * const item, parse_buffer * const input_buffer) in parse_array() argument
1523 item->type = cJSON_Array; in parse_array()
1524 item->child = head; in parse_array()
1540 static cJSON_bool print_array(const cJSON * const item, printbuffer * const output_buffer) in print_array() argument
1544 cJSON *current_element = item->child; in print_array()
1602 static cJSON_bool parse_object(cJSON * const item, parse_buffer * const input_buffer) in parse_object() argument
1695 item->type = cJSON_Object; in parse_object()
1696 item->child = head; in parse_object()
1711 static cJSON_bool print_object(const cJSON * const item, printbuffer * const output_buffer) in print_object() argument
1715 cJSON *current_item = item->child; in print_object()
1925 static void suffix_object(cJSON *prev, cJSON *item) in suffix_object() argument
1927 prev->next = item; in suffix_object()
1928 item->prev = prev; in suffix_object()
1932 static cJSON *create_reference(const cJSON *item, const internal_hooks * const hooks) in create_reference() argument
1935 if (item == NULL) in create_reference()
1946 memcpy(reference, item, sizeof(cJSON)); in create_reference()
1953 static cJSON_bool add_item_to_array(cJSON *array, cJSON *item) in add_item_to_array() argument
1957 if ((item == NULL) || (array == NULL) || (array == item)) in add_item_to_array()
1969 array->child = item; in add_item_to_array()
1970 item->prev = item; in add_item_to_array()
1971 item->next = NULL; in add_item_to_array()
1978 suffix_object(child->prev, item); in add_item_to_array()
1979 array->child->prev = item; in add_item_to_array()
1987 suffix_object(child, item); in add_item_to_array()
1988 array->child->prev = item; in add_item_to_array()
1996 CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToArray(cJSON *array, cJSON *item) in cJSON_AddItemToArray() argument
1998 return add_item_to_array(array, item); in cJSON_AddItemToArray()
2017 …_to_object(cJSON * const object, const char * const string, cJSON * const item, const internal_hoo… in add_item_to_object() argument
2022 if ((object == NULL) || (string == NULL) || (item == NULL) || (object == item)) in add_item_to_object()
2030 new_type = item->type | cJSON_StringIsConst; in add_item_to_object()
2040 new_type = item->type & ~cJSON_StringIsConst; in add_item_to_object()
2043 if (!(item->type & cJSON_StringIsConst) && (item->string != NULL)) in add_item_to_object()
2045 hooks->deallocate(item->string); in add_item_to_object()
2048 item->string = new_key; in add_item_to_object()
2049 item->type = new_type; in add_item_to_object()
2051 return add_item_to_array(object, item); in add_item_to_object()
2054 CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item) in cJSON_AddItemToObject() argument
2056 return add_item_to_object(object, string, item, &global_hooks, false); in cJSON_AddItemToObject()
2060 CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item) in cJSON_AddItemToObjectCS() argument
2062 return add_item_to_object(object, string, item, &global_hooks, true); in cJSON_AddItemToObjectCS()
2065 CJSON_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item) in cJSON_AddItemReferenceToArray() argument
2072 return add_item_to_array(array, create_reference(item, &global_hooks)); in cJSON_AddItemReferenceToArray()
2075 …N_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item) in cJSON_AddItemReferenceToObject() argument
2082 …return add_item_to_object(object, string, create_reference(item, &global_hooks), &global_hooks, fa… in cJSON_AddItemReferenceToObject()
2193 CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * const item) in cJSON_DetachItemViaPointer() argument
2195 if ((parent == NULL) || (item == NULL)) in cJSON_DetachItemViaPointer()
2200 if (item != parent->child) in cJSON_DetachItemViaPointer()
2203 item->prev->next = item->next; in cJSON_DetachItemViaPointer()
2205 if (item->next != NULL) in cJSON_DetachItemViaPointer()
2208 item->next->prev = item->prev; in cJSON_DetachItemViaPointer()
2211 if (item == parent->child) in cJSON_DetachItemViaPointer()
2214 parent->child = item->next; in cJSON_DetachItemViaPointer()
2217 item->prev = NULL; in cJSON_DetachItemViaPointer()
2218 item->next = NULL; in cJSON_DetachItemViaPointer()
2220 return item; in cJSON_DetachItemViaPointer()
2292 CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSO… in cJSON_ReplaceItemViaPointer() argument
2294 if ((parent == NULL) || (replacement == NULL) || (item == NULL)) in cJSON_ReplaceItemViaPointer()
2299 if (replacement == item) in cJSON_ReplaceItemViaPointer()
2304 replacement->next = item->next; in cJSON_ReplaceItemViaPointer()
2305 replacement->prev = item->prev; in cJSON_ReplaceItemViaPointer()
2311 if (parent->child == item) in cJSON_ReplaceItemViaPointer()
2326 item->next = NULL; in cJSON_ReplaceItemViaPointer()
2327 item->prev = NULL; in cJSON_ReplaceItemViaPointer()
2328 cJSON_Delete(item); in cJSON_ReplaceItemViaPointer()
2374 cJSON *item = cJSON_New_Item(&global_hooks); in cJSON_CreateNull() local
2375 if(item) in cJSON_CreateNull()
2377 item->type = cJSON_NULL; in cJSON_CreateNull()
2380 return item; in cJSON_CreateNull()
2385 cJSON *item = cJSON_New_Item(&global_hooks); in cJSON_CreateTrue() local
2386 if(item) in cJSON_CreateTrue()
2388 item->type = cJSON_True; in cJSON_CreateTrue()
2391 return item; in cJSON_CreateTrue()
2396 cJSON *item = cJSON_New_Item(&global_hooks); in cJSON_CreateFalse() local
2397 if(item) in cJSON_CreateFalse()
2399 item->type = cJSON_False; in cJSON_CreateFalse()
2402 return item; in cJSON_CreateFalse()
2407 cJSON *item = cJSON_New_Item(&global_hooks); in cJSON_CreateBool() local
2408 if(item) in cJSON_CreateBool()
2410 item->type = boolean ? cJSON_True : cJSON_False; in cJSON_CreateBool()
2413 return item; in cJSON_CreateBool()
2418 cJSON *item = cJSON_New_Item(&global_hooks); in cJSON_CreateNumber() local
2419 if(item) in cJSON_CreateNumber()
2421 item->type = cJSON_Number; in cJSON_CreateNumber()
2422 item->valuedouble = num; in cJSON_CreateNumber()
2427 item->valueint = LLONG_MAX; in cJSON_CreateNumber()
2431 item->valueint = LLONG_MIN; in cJSON_CreateNumber()
2435 item->valueint = (int64_t)num; in cJSON_CreateNumber()
2439 return item; in cJSON_CreateNumber()
2444 cJSON *item = cJSON_New_Item(&global_hooks); in cJSON_CreateString() local
2445 if(item) in cJSON_CreateString()
2447 item->type = cJSON_String; in cJSON_CreateString()
2448 item->valuestring = (char*)cJSON_strdup((const unsigned char*)string, &global_hooks); in cJSON_CreateString()
2449 if(!item->valuestring) in cJSON_CreateString()
2451 cJSON_Delete(item); in cJSON_CreateString()
2456 return item; in cJSON_CreateString()
2461 cJSON *item = cJSON_New_Item(&global_hooks); in cJSON_CreateStringReference() local
2462 if (item != NULL) in cJSON_CreateStringReference()
2464 item->type = cJSON_String | cJSON_IsReference; in cJSON_CreateStringReference()
2465 item->valuestring = (char*)cast_away_const(string); in cJSON_CreateStringReference()
2468 return item; in cJSON_CreateStringReference()
2473 cJSON *item = cJSON_New_Item(&global_hooks); in cJSON_CreateObjectReference() local
2474 if (item != NULL) { in cJSON_CreateObjectReference()
2475 item->type = cJSON_Object | cJSON_IsReference; in cJSON_CreateObjectReference()
2476 item->child = (cJSON*)cast_away_const(child); in cJSON_CreateObjectReference()
2479 return item; in cJSON_CreateObjectReference()
2483 cJSON *item = cJSON_New_Item(&global_hooks); in cJSON_CreateArrayReference() local
2484 if (item != NULL) { in cJSON_CreateArrayReference()
2485 item->type = cJSON_Array | cJSON_IsReference; in cJSON_CreateArrayReference()
2486 item->child = (cJSON*)cast_away_const(child); in cJSON_CreateArrayReference()
2489 return item; in cJSON_CreateArrayReference()
2494 cJSON *item = cJSON_New_Item(&global_hooks); in cJSON_CreateRaw() local
2495 if(item) in cJSON_CreateRaw()
2497 item->type = cJSON_Raw; in cJSON_CreateRaw()
2498 item->valuestring = (char*)cJSON_strdup((const unsigned char*)raw, &global_hooks); in cJSON_CreateRaw()
2499 if(!item->valuestring) in cJSON_CreateRaw()
2501 cJSON_Delete(item); in cJSON_CreateRaw()
2506 return item; in cJSON_CreateRaw()
2511 cJSON *item = cJSON_New_Item(&global_hooks); in cJSON_CreateArray() local
2512 if(item) in cJSON_CreateArray()
2514 item->type=cJSON_Array; in cJSON_CreateArray()
2517 return item; in cJSON_CreateArray()
2522 cJSON *item = cJSON_New_Item(&global_hooks); in cJSON_CreateObject() local
2523 if (item) in cJSON_CreateObject()
2525 item->type = cJSON_Object; in cJSON_CreateObject()
2528 return item; in cJSON_CreateObject()
2676 CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse) in cJSON_Duplicate() argument
2684 if (!item) in cJSON_Duplicate()
2695 newitem->type = item->type & (~cJSON_IsReference); in cJSON_Duplicate()
2696 newitem->valueint = item->valueint; in cJSON_Duplicate()
2697 newitem->valuedouble = item->valuedouble; in cJSON_Duplicate()
2698 if (item->valuestring) in cJSON_Duplicate()
2700 … newitem->valuestring = (char*)cJSON_strdup((unsigned char*)item->valuestring, &global_hooks); in cJSON_Duplicate()
2706 if (item->string) in cJSON_Duplicate()
2708 …newitem->string = (item->type&cJSON_StringIsConst) ? item->string : (char*)cJSON_strdup((unsigned … in cJSON_Duplicate()
2720 child = item->child; in cJSON_Duplicate()
2852 CJSON_PUBLIC(cJSON_bool) cJSON_IsInvalid(const cJSON * const item) in cJSON_IsInvalid() argument
2854 if (item == NULL) in cJSON_IsInvalid()
2859 return (item->type & 0xFF) == cJSON_Invalid; in cJSON_IsInvalid()
2862 CJSON_PUBLIC(cJSON_bool) cJSON_IsFalse(const cJSON * const item) in cJSON_IsFalse() argument
2864 if (item == NULL) in cJSON_IsFalse()
2869 return (item->type & 0xFF) == cJSON_False; in cJSON_IsFalse()
2872 CJSON_PUBLIC(cJSON_bool) cJSON_IsTrue(const cJSON * const item) in cJSON_IsTrue() argument
2874 if (item == NULL) in cJSON_IsTrue()
2879 return (item->type & 0xff) == cJSON_True; in cJSON_IsTrue()
2883 CJSON_PUBLIC(cJSON_bool) cJSON_IsBool(const cJSON * const item) in cJSON_IsBool() argument
2885 if (item == NULL) in cJSON_IsBool()
2890 return (item->type & (cJSON_True | cJSON_False)) != 0; in cJSON_IsBool()
2892 CJSON_PUBLIC(cJSON_bool) cJSON_IsNull(const cJSON * const item) in cJSON_IsNull() argument
2894 if (item == NULL) in cJSON_IsNull()
2899 return (item->type & 0xFF) == cJSON_NULL; in cJSON_IsNull()
2902 CJSON_PUBLIC(cJSON_bool) cJSON_IsNumber(const cJSON * const item) in cJSON_IsNumber() argument
2904 if (item == NULL) in cJSON_IsNumber()
2909 return (item->type & 0xFF) == cJSON_Number; in cJSON_IsNumber()
2912 CJSON_PUBLIC(cJSON_bool) cJSON_IsString(const cJSON * const item) in cJSON_IsString() argument
2914 if (item == NULL) in cJSON_IsString()
2919 return (item->type & 0xFF) == cJSON_String; in cJSON_IsString()
2922 CJSON_PUBLIC(cJSON_bool) cJSON_IsArray(const cJSON * const item) in cJSON_IsArray() argument
2924 if (item == NULL) in cJSON_IsArray()
2929 return (item->type & 0xFF) == cJSON_Array; in cJSON_IsArray()
2932 CJSON_PUBLIC(cJSON_bool) cJSON_IsObject(const cJSON * const item) in cJSON_IsObject() argument
2934 if (item == NULL) in cJSON_IsObject()
2939 return (item->type & 0xFF) == cJSON_Object; in cJSON_IsObject()
2942 CJSON_PUBLIC(cJSON_bool) cJSON_IsRaw(const cJSON * const item) in cJSON_IsRaw() argument
2944 if (item == NULL) in cJSON_IsRaw()
2949 return (item->type & 0xFF) == cJSON_Raw; in cJSON_IsRaw()