Lines Matching refs:item

99 CJSON_PUBLIC(char *) cJSON_GetStringValue(const cJSON * const item)  in cJSON_GetStringValue()  argument
101 if (!cJSON_IsString(item)) in cJSON_GetStringValue()
106 return item->valuestring; in cJSON_GetStringValue()
109 CJSON_PUBLIC(double) cJSON_GetNumberValue(const cJSON * const item) in cJSON_GetNumberValue() argument
111 if (!cJSON_IsNumber(item)) in cJSON_GetNumberValue()
116 return item->valuedouble; in cJSON_GetNumberValue()
253 CJSON_PUBLIC(void) cJSON_Delete(cJSON *item) in cJSON_Delete() argument
256 while (item != NULL) in cJSON_Delete()
258 next = item->next; in cJSON_Delete()
259 if (!(item->type & cJSON_IsReference) && (item->child != NULL)) in cJSON_Delete()
261 cJSON_Delete(item->child); in cJSON_Delete()
263 if (!(item->type & cJSON_IsReference) && (item->valuestring != NULL)) in cJSON_Delete()
265 global_hooks.deallocate(item->valuestring); in cJSON_Delete()
267 if (!(item->type & cJSON_StringIsConst) && (item->string != NULL)) in cJSON_Delete()
269 global_hooks.deallocate(item->string); in cJSON_Delete()
271 global_hooks.deallocate(item); in cJSON_Delete()
272 item = next; in cJSON_Delete()
305 static cJSON_bool parse_number(cJSON * const item, parse_buffer * const input_buffer) in parse_number() argument
359 item->valuedouble = number; in parse_number()
364 item->valueint = INT_MAX; in parse_number()
368 item->valueint = INT_MIN; in parse_number()
372 item->valueint = (int)number; in parse_number()
375 item->type = cJSON_Number; in parse_number()
545 static cJSON_bool print_number(const cJSON * const item, printbuffer * const output_buffer) in print_number() argument
548 double d = item->valuedouble; in print_number()
769 static cJSON_bool parse_string(cJSON * const item, parse_buffer * const input_buffer) in parse_string() argument
875 item->type = cJSON_String; in parse_string()
876 item->valuestring = (char*)output; in parse_string()
1020 static cJSON_bool print_string(const cJSON * const item, printbuffer * const p) in print_string() argument
1022 return print_string_ptr((unsigned char*)item->valuestring, p); in print_string()
1026 static cJSON_bool parse_value(cJSON * const item, parse_buffer * const input_buffer);
1027 static cJSON_bool print_value(const cJSON * const item, printbuffer * const output_buffer);
1028 static cJSON_bool parse_array(cJSON * const item, parse_buffer * const input_buffer);
1029 static cJSON_bool print_array(const cJSON * const item, printbuffer * const output_buffer);
1030 static cJSON_bool parse_object(cJSON * const item, parse_buffer * const input_buffer);
1031 static cJSON_bool print_object(const cJSON * const item, printbuffer * const output_buffer);
1094 cJSON *item = NULL; in cJSON_ParseWithLengthOpts() local
1110 item = cJSON_New_Item(&global_hooks); in cJSON_ParseWithLengthOpts()
1111 if (item == NULL) /* memory fail */ in cJSON_ParseWithLengthOpts()
1116 if (!parse_value(item, buffer_skip_whitespace(skip_utf8_bom(&buffer)))) in cJSON_ParseWithLengthOpts()
1136 return item; in cJSON_ParseWithLengthOpts()
1139 if (item != NULL) in cJSON_ParseWithLengthOpts()
1141 cJSON_Delete(item); in cJSON_ParseWithLengthOpts()
1183 static unsigned char *print(const cJSON * const item, cJSON_bool format, const internal_hooks * con… in print() argument
1202 if (!print_value(item, buffer)) in print()
1248 CJSON_PUBLIC(char *) cJSON_Print(const cJSON *item) in cJSON_Print() argument
1250 return (char*)print(item, true, &global_hooks); in cJSON_Print()
1253 CJSON_PUBLIC(char *) cJSON_PrintUnformatted(const cJSON *item) in cJSON_PrintUnformatted() argument
1255 return (char*)print(item, false, &global_hooks); in cJSON_PrintUnformatted()
1258 CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON_bool fmt) in cJSON_PrintBuffered() argument
1279 if (!print_value(item, &p)) in cJSON_PrintBuffered()
1288 CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const… in cJSON_PrintPreallocated() argument
1304 return print_value(item, &p); in cJSON_PrintPreallocated()
1308 static cJSON_bool parse_value(cJSON * const item, parse_buffer * const input_buffer) in parse_value() argument
1319 item->type = cJSON_NULL; in parse_value()
1326 item->type = cJSON_False; in parse_value()
1333 item->type = cJSON_True; in parse_value()
1334 item->valueint = 1; in parse_value()
1341 return parse_string(item, input_buffer); in parse_value()
1346 return parse_number(item, input_buffer); in parse_value()
1351 return parse_array(item, input_buffer); in parse_value()
1356 return parse_object(item, input_buffer); in parse_value()
1363 static cJSON_bool print_value(const cJSON * const item, printbuffer * const output_buffer) in print_value() argument
1367 if ((item == NULL) || (output_buffer == NULL)) in print_value()
1372 switch ((item->type) & 0xFF) in print_value()
1402 return print_number(item, output_buffer); in print_value()
1407 if (item->valuestring == NULL) in print_value()
1412 raw_length = strlen(item->valuestring) + sizeof(""); in print_value()
1418 memcpy(output, item->valuestring, raw_length); in print_value()
1423 return print_string(item, output_buffer); in print_value()
1426 return print_array(item, output_buffer); in print_value()
1429 return print_object(item, output_buffer); in print_value()
1437 static cJSON_bool parse_array(cJSON * const item, parse_buffer * const input_buffer) in parse_array() argument
1518 item->type = cJSON_Array; in parse_array()
1519 item->child = head; in parse_array()
1535 static cJSON_bool print_array(const cJSON * const item, printbuffer * const output_buffer) in print_array() argument
1539 cJSON *current_element = item->child; in print_array()
1597 static cJSON_bool parse_object(cJSON * const item, parse_buffer * const input_buffer) in parse_object() argument
1694 item->type = cJSON_Object; in parse_object()
1695 item->child = head; in parse_object()
1710 static cJSON_bool print_object(const cJSON * const item, printbuffer * const output_buffer) in print_object() argument
1714 cJSON *current_item = item->child; in print_object()
1924 static void suffix_object(cJSON *prev, cJSON *item) in suffix_object() argument
1926 prev->next = item; in suffix_object()
1927 item->prev = prev; in suffix_object()
1931 static cJSON *create_reference(const cJSON *item, const internal_hooks * const hooks) in create_reference() argument
1934 if (item == NULL) in create_reference()
1945 memcpy(reference, item, sizeof(cJSON)); in create_reference()
1952 static cJSON_bool add_item_to_array(cJSON *array, cJSON *item) in add_item_to_array() argument
1956 if ((item == NULL) || (array == NULL) || (array == item)) in add_item_to_array()
1968 array->child = item; in add_item_to_array()
1969 item->prev = item; in add_item_to_array()
1970 item->next = NULL; in add_item_to_array()
1977 suffix_object(child->prev, item); in add_item_to_array()
1978 array->child->prev = item; in add_item_to_array()
1986 CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToArray(cJSON *array, cJSON *item) in cJSON_AddItemToArray() argument
1988 return add_item_to_array(array, item); in cJSON_AddItemToArray()
2007 …_to_object(cJSON * const object, const char * const string, cJSON * const item, const internal_hoo… in add_item_to_object() argument
2012 if ((object == NULL) || (string == NULL) || (item == NULL) || (object == item)) in add_item_to_object()
2020 new_type = item->type | cJSON_StringIsConst; in add_item_to_object()
2030 new_type = item->type & ~cJSON_StringIsConst; in add_item_to_object()
2033 if (!(item->type & cJSON_StringIsConst) && (item->string != NULL)) in add_item_to_object()
2035 hooks->deallocate(item->string); in add_item_to_object()
2038 item->string = new_key; in add_item_to_object()
2039 item->type = new_type; in add_item_to_object()
2041 return add_item_to_array(object, item); in add_item_to_object()
2044 CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item) in cJSON_AddItemToObject() argument
2046 return add_item_to_object(object, string, item, &global_hooks, false); in cJSON_AddItemToObject()
2050 CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item) in cJSON_AddItemToObjectCS() argument
2052 return add_item_to_object(object, string, item, &global_hooks, true); in cJSON_AddItemToObjectCS()
2055 CJSON_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item) in cJSON_AddItemReferenceToArray() argument
2062 return add_item_to_array(array, create_reference(item, &global_hooks)); in cJSON_AddItemReferenceToArray()
2065 …N_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item) in cJSON_AddItemReferenceToObject() argument
2072 …return add_item_to_object(object, string, create_reference(item, &global_hooks), &global_hooks, fa… in cJSON_AddItemReferenceToObject()
2183 CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * const item) in cJSON_DetachItemViaPointer() argument
2185 if ((parent == NULL) || (item == NULL)) in cJSON_DetachItemViaPointer()
2190 if (item != parent->child) in cJSON_DetachItemViaPointer()
2193 item->prev->next = item->next; in cJSON_DetachItemViaPointer()
2195 if (item->next != NULL) in cJSON_DetachItemViaPointer()
2198 item->next->prev = item->prev; in cJSON_DetachItemViaPointer()
2201 if (item == parent->child) in cJSON_DetachItemViaPointer()
2204 parent->child = item->next; in cJSON_DetachItemViaPointer()
2206 else if (item->next == NULL) in cJSON_DetachItemViaPointer()
2209 parent->child->prev = item->prev; in cJSON_DetachItemViaPointer()
2213 item->prev = NULL; in cJSON_DetachItemViaPointer()
2214 item->next = NULL; in cJSON_DetachItemViaPointer()
2216 return item; in cJSON_DetachItemViaPointer()
2288 CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSO… in cJSON_ReplaceItemViaPointer() argument
2290 if ((parent == NULL) || (replacement == NULL) || (item == NULL)) in cJSON_ReplaceItemViaPointer()
2295 if (replacement == item) in cJSON_ReplaceItemViaPointer()
2300 replacement->next = item->next; in cJSON_ReplaceItemViaPointer()
2301 replacement->prev = item->prev; in cJSON_ReplaceItemViaPointer()
2307 if (parent->child == item) in cJSON_ReplaceItemViaPointer()
2330 item->next = NULL; in cJSON_ReplaceItemViaPointer()
2331 item->prev = NULL; in cJSON_ReplaceItemViaPointer()
2332 cJSON_Delete(item); in cJSON_ReplaceItemViaPointer()
2378 cJSON *item = cJSON_New_Item(&global_hooks); in cJSON_CreateNull() local
2379 if(item) in cJSON_CreateNull()
2381 item->type = cJSON_NULL; in cJSON_CreateNull()
2384 return item; in cJSON_CreateNull()
2389 cJSON *item = cJSON_New_Item(&global_hooks); in cJSON_CreateTrue() local
2390 if(item) in cJSON_CreateTrue()
2392 item->type = cJSON_True; in cJSON_CreateTrue()
2395 return item; in cJSON_CreateTrue()
2400 cJSON *item = cJSON_New_Item(&global_hooks); in cJSON_CreateFalse() local
2401 if(item) in cJSON_CreateFalse()
2403 item->type = cJSON_False; in cJSON_CreateFalse()
2406 return item; in cJSON_CreateFalse()
2411 cJSON *item = cJSON_New_Item(&global_hooks); in cJSON_CreateBool() local
2412 if(item) in cJSON_CreateBool()
2414 item->type = boolean ? cJSON_True : cJSON_False; in cJSON_CreateBool()
2417 return item; in cJSON_CreateBool()
2422 cJSON *item = cJSON_New_Item(&global_hooks); in cJSON_CreateNumber() local
2423 if(item) in cJSON_CreateNumber()
2425 item->type = cJSON_Number; in cJSON_CreateNumber()
2426 item->valuedouble = num; in cJSON_CreateNumber()
2431 item->valueint = INT_MAX; in cJSON_CreateNumber()
2435 item->valueint = INT_MIN; in cJSON_CreateNumber()
2439 item->valueint = (int)num; in cJSON_CreateNumber()
2443 return item; in cJSON_CreateNumber()
2448 cJSON *item = cJSON_New_Item(&global_hooks); in cJSON_CreateString() local
2449 if(item) in cJSON_CreateString()
2451 item->type = cJSON_String; in cJSON_CreateString()
2452 item->valuestring = (char*)cJSON_strdup((const unsigned char*)string, &global_hooks); in cJSON_CreateString()
2453 if(!item->valuestring) in cJSON_CreateString()
2455 cJSON_Delete(item); in cJSON_CreateString()
2460 return item; in cJSON_CreateString()
2465 cJSON *item = cJSON_New_Item(&global_hooks); in cJSON_CreateStringReference() local
2466 if (item != NULL) in cJSON_CreateStringReference()
2468 item->type = cJSON_String | cJSON_IsReference; in cJSON_CreateStringReference()
2469 item->valuestring = (char*)cast_away_const(string); in cJSON_CreateStringReference()
2472 return item; in cJSON_CreateStringReference()
2477 cJSON *item = cJSON_New_Item(&global_hooks); in cJSON_CreateObjectReference() local
2478 if (item != NULL) { in cJSON_CreateObjectReference()
2479 item->type = cJSON_Object | cJSON_IsReference; in cJSON_CreateObjectReference()
2480 item->child = (cJSON*)cast_away_const(child); in cJSON_CreateObjectReference()
2483 return item; in cJSON_CreateObjectReference()
2487 cJSON *item = cJSON_New_Item(&global_hooks); in cJSON_CreateArrayReference() local
2488 if (item != NULL) { in cJSON_CreateArrayReference()
2489 item->type = cJSON_Array | cJSON_IsReference; in cJSON_CreateArrayReference()
2490 item->child = (cJSON*)cast_away_const(child); in cJSON_CreateArrayReference()
2493 return item; in cJSON_CreateArrayReference()
2498 cJSON *item = cJSON_New_Item(&global_hooks); in cJSON_CreateRaw() local
2499 if(item) in cJSON_CreateRaw()
2501 item->type = cJSON_Raw; in cJSON_CreateRaw()
2502 item->valuestring = (char*)cJSON_strdup((const unsigned char*)raw, &global_hooks); in cJSON_CreateRaw()
2503 if(!item->valuestring) in cJSON_CreateRaw()
2505 cJSON_Delete(item); in cJSON_CreateRaw()
2510 return item; in cJSON_CreateRaw()
2515 cJSON *item = cJSON_New_Item(&global_hooks); in cJSON_CreateArray() local
2516 if(item) in cJSON_CreateArray()
2518 item->type=cJSON_Array; in cJSON_CreateArray()
2521 return item; in cJSON_CreateArray()
2526 cJSON *item = cJSON_New_Item(&global_hooks); in cJSON_CreateObject() local
2527 if (item) in cJSON_CreateObject()
2529 item->type = cJSON_Object; in cJSON_CreateObject()
2532 return item; in cJSON_CreateObject()
2697 CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse) in cJSON_Duplicate() argument
2705 if (!item) in cJSON_Duplicate()
2716 newitem->type = item->type & (~cJSON_IsReference); in cJSON_Duplicate()
2717 newitem->valueint = item->valueint; in cJSON_Duplicate()
2718 newitem->valuedouble = item->valuedouble; in cJSON_Duplicate()
2719 if (item->valuestring) in cJSON_Duplicate()
2721 … newitem->valuestring = (char*)cJSON_strdup((unsigned char*)item->valuestring, &global_hooks); in cJSON_Duplicate()
2727 if (item->string) in cJSON_Duplicate()
2729 …newitem->string = (item->type&cJSON_StringIsConst) ? item->string : (char*)cJSON_strdup((unsigned … in cJSON_Duplicate()
2741 child = item->child; in cJSON_Duplicate()
2877 CJSON_PUBLIC(cJSON_bool) cJSON_IsInvalid(const cJSON * const item) in cJSON_IsInvalid() argument
2879 if (item == NULL) in cJSON_IsInvalid()
2884 return (item->type & 0xFF) == cJSON_Invalid; in cJSON_IsInvalid()
2887 CJSON_PUBLIC(cJSON_bool) cJSON_IsFalse(const cJSON * const item) in cJSON_IsFalse() argument
2889 if (item == NULL) in cJSON_IsFalse()
2894 return (item->type & 0xFF) == cJSON_False; in cJSON_IsFalse()
2897 CJSON_PUBLIC(cJSON_bool) cJSON_IsTrue(const cJSON * const item) in cJSON_IsTrue() argument
2899 if (item == NULL) in cJSON_IsTrue()
2904 return (item->type & 0xff) == cJSON_True; in cJSON_IsTrue()
2908 CJSON_PUBLIC(cJSON_bool) cJSON_IsBool(const cJSON * const item) in cJSON_IsBool() argument
2910 if (item == NULL) in cJSON_IsBool()
2915 return (item->type & (cJSON_True | cJSON_False)) != 0; in cJSON_IsBool()
2917 CJSON_PUBLIC(cJSON_bool) cJSON_IsNull(const cJSON * const item) in cJSON_IsNull() argument
2919 if (item == NULL) in cJSON_IsNull()
2924 return (item->type & 0xFF) == cJSON_NULL; in cJSON_IsNull()
2927 CJSON_PUBLIC(cJSON_bool) cJSON_IsNumber(const cJSON * const item) in cJSON_IsNumber() argument
2929 if (item == NULL) in cJSON_IsNumber()
2934 return (item->type & 0xFF) == cJSON_Number; in cJSON_IsNumber()
2937 CJSON_PUBLIC(cJSON_bool) cJSON_IsString(const cJSON * const item) in cJSON_IsString() argument
2939 if (item == NULL) in cJSON_IsString()
2944 return (item->type & 0xFF) == cJSON_String; in cJSON_IsString()
2947 CJSON_PUBLIC(cJSON_bool) cJSON_IsArray(const cJSON * const item) in cJSON_IsArray() argument
2949 if (item == NULL) in cJSON_IsArray()
2954 return (item->type & 0xFF) == cJSON_Array; in cJSON_IsArray()
2957 CJSON_PUBLIC(cJSON_bool) cJSON_IsObject(const cJSON * const item) in cJSON_IsObject() argument
2959 if (item == NULL) in cJSON_IsObject()
2964 return (item->type & 0xFF) == cJSON_Object; in cJSON_IsObject()
2967 CJSON_PUBLIC(cJSON_bool) cJSON_IsRaw(const cJSON * const item) in cJSON_IsRaw() argument
2969 if (item == NULL) in cJSON_IsRaw()
2974 return (item->type & 0xFF) == cJSON_Raw; in cJSON_IsRaw()