Lines Matching refs:item
75 CJSON_PUBLIC(char *) cJSON_GetStringValue(cJSON *item) { in cJSON_GetStringValue() argument
76 if (!cJSON_IsString(item)) { in cJSON_GetStringValue()
80 return item->valuestring; in cJSON_GetStringValue()
214 CJSON_PUBLIC(void) cJSON_Delete(cJSON *item) in cJSON_Delete() argument
217 while (item != NULL) in cJSON_Delete()
219 next = item->next; in cJSON_Delete()
220 if (!(item->type & cJSON_IsReference) && (item->child != NULL)) in cJSON_Delete()
222 cJSON_Delete(item->child); in cJSON_Delete()
224 if (!(item->type & cJSON_IsReference) && (item->valuestring != NULL)) in cJSON_Delete()
226 global_hooks.deallocate(item->valuestring); in cJSON_Delete()
228 if (!(item->type & cJSON_StringIsConst) && (item->string != NULL)) in cJSON_Delete()
230 global_hooks.deallocate(item->string); in cJSON_Delete()
232 global_hooks.deallocate(item); in cJSON_Delete()
233 item = next; in cJSON_Delete()
266 static cJSON_bool parse_number(cJSON * const item, parse_buffer * const input_buffer) in parse_number() argument
320 item->valuedouble = number; in parse_number()
325 item->valueint = INT_MAX; in parse_number()
329 item->valueint = INT_MIN; in parse_number()
333 item->valueint = (int)number; in parse_number()
336 item->type = cJSON_Number; in parse_number()
474 static cJSON_bool print_number(const cJSON * const item, printbuffer * const output_buffer) in print_number() argument
477 double d = item->valuedouble; in print_number()
698 static cJSON_bool parse_string(cJSON * const item, parse_buffer * const input_buffer) in parse_string() argument
804 item->type = cJSON_String; in parse_string()
805 item->valuestring = (char*)output; in parse_string()
949 static cJSON_bool print_string(const cJSON * const item, printbuffer * const p) in print_string() argument
951 return print_string_ptr((unsigned char*)item->valuestring, p); in print_string()
955 static cJSON_bool parse_value(cJSON * const item, parse_buffer * const input_buffer);
956 static cJSON_bool print_value(const cJSON * const item, printbuffer * const output_buffer);
957 static cJSON_bool parse_array(cJSON * const item, parse_buffer * const input_buffer);
958 static cJSON_bool print_array(const cJSON * const item, printbuffer * const output_buffer);
959 static cJSON_bool parse_object(cJSON * const item, parse_buffer * const input_buffer);
960 static cJSON_bool print_object(const cJSON * const item, printbuffer * const output_buffer);
1003 cJSON *item = NULL; in cJSON_ParseWithOpts() local
1019 item = cJSON_New_Item(&global_hooks); in cJSON_ParseWithOpts()
1020 if (item == NULL) /* memory fail */ in cJSON_ParseWithOpts()
1025 if (!parse_value(item, buffer_skip_whitespace(skip_utf8_bom(&buffer)))) in cJSON_ParseWithOpts()
1045 return item; in cJSON_ParseWithOpts()
1048 if (item != NULL) in cJSON_ParseWithOpts()
1050 cJSON_Delete(item); in cJSON_ParseWithOpts()
1087 static unsigned char *print(const cJSON * const item, cJSON_bool format, const internal_hooks * con… in print() argument
1106 if (!print_value(item, buffer)) in print()
1152 CJSON_PUBLIC(char *) cJSON_Print(const cJSON *item) in cJSON_Print() argument
1154 return (char*)print(item, true, &global_hooks); in cJSON_Print()
1157 CJSON_PUBLIC(char *) cJSON_PrintUnformatted(const cJSON *item) in cJSON_PrintUnformatted() argument
1159 return (char*)print(item, false, &global_hooks); in cJSON_PrintUnformatted()
1162 CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON_bool fmt) in cJSON_PrintBuffered() argument
1183 if (!print_value(item, &p)) in cJSON_PrintBuffered()
1192 CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buf, const int len, const cJSON… in cJSON_PrintPreallocated() argument
1208 return print_value(item, &p); in cJSON_PrintPreallocated()
1212 static cJSON_bool parse_value(cJSON * const item, parse_buffer * const input_buffer) in parse_value() argument
1223 item->type = cJSON_NULL; in parse_value()
1230 item->type = cJSON_False; in parse_value()
1237 item->type = cJSON_True; in parse_value()
1238 item->valueint = 1; in parse_value()
1245 return parse_string(item, input_buffer); in parse_value()
1250 return parse_number(item, input_buffer); in parse_value()
1255 return parse_array(item, input_buffer); in parse_value()
1260 return parse_object(item, input_buffer); in parse_value()
1267 static cJSON_bool print_value(const cJSON * const item, printbuffer * const output_buffer) in print_value() argument
1271 if ((item == NULL) || (output_buffer == NULL)) in print_value()
1276 switch ((item->type) & 0xFF) in print_value()
1306 return print_number(item, output_buffer); in print_value()
1311 if (item->valuestring == NULL) in print_value()
1316 raw_length = strlen(item->valuestring) + sizeof(""); in print_value()
1322 memcpy(output, item->valuestring, raw_length); in print_value()
1327 return print_string(item, output_buffer); in print_value()
1330 return print_array(item, output_buffer); in print_value()
1333 return print_object(item, output_buffer); in print_value()
1341 static cJSON_bool parse_array(cJSON * const item, parse_buffer * const input_buffer) in parse_array() argument
1418 item->type = cJSON_Array; in parse_array()
1419 item->child = head; in parse_array()
1435 static cJSON_bool print_array(const cJSON * const item, printbuffer * const output_buffer) in print_array() argument
1439 cJSON *current_element = item->child; in print_array()
1497 static cJSON_bool parse_object(cJSON * const item, parse_buffer * const input_buffer) in parse_object() argument
1590 item->type = cJSON_Object; in parse_object()
1591 item->child = head; in parse_object()
1606 static cJSON_bool print_object(const cJSON * const item, printbuffer * const output_buffer) in print_object() argument
1610 cJSON *current_item = item->child; in print_object()
1816 static void suffix_object(cJSON *prev, cJSON *item) in suffix_object() argument
1818 prev->next = item; in suffix_object()
1819 item->prev = prev; in suffix_object()
1823 static cJSON *create_reference(const cJSON *item, const internal_hooks * const hooks) in create_reference() argument
1826 if (item == NULL) in create_reference()
1837 memcpy(reference, item, sizeof(cJSON)); in create_reference()
1844 static cJSON_bool add_item_to_array(cJSON *array, cJSON *item) in add_item_to_array() argument
1848 if ((item == NULL) || (array == NULL)) in add_item_to_array()
1858 array->child = item; in add_item_to_array()
1867 suffix_object(child, item); in add_item_to_array()
1874 CJSON_PUBLIC(void) cJSON_AddItemToArray(cJSON *array, cJSON *item) in cJSON_AddItemToArray() argument
1876 add_item_to_array(array, item); in cJSON_AddItemToArray()
1895 …_to_object(cJSON * const object, const char * const string, cJSON * const item, const internal_hoo… in add_item_to_object() argument
1900 if ((object == NULL) || (string == NULL) || (item == NULL)) in add_item_to_object()
1908 new_type = item->type | cJSON_StringIsConst; in add_item_to_object()
1918 new_type = item->type & ~cJSON_StringIsConst; in add_item_to_object()
1921 if (!(item->type & cJSON_StringIsConst) && (item->string != NULL)) in add_item_to_object()
1923 hooks->deallocate(item->string); in add_item_to_object()
1926 item->string = new_key; in add_item_to_object()
1927 item->type = new_type; in add_item_to_object()
1929 return add_item_to_array(object, item); in add_item_to_object()
1932 CJSON_PUBLIC(void) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item) in cJSON_AddItemToObject() argument
1934 add_item_to_object(object, string, item, &global_hooks, false); in cJSON_AddItemToObject()
1938 CJSON_PUBLIC(void) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item) in cJSON_AddItemToObjectCS() argument
1940 add_item_to_object(object, string, item, &global_hooks, true); in cJSON_AddItemToObjectCS()
1943 CJSON_PUBLIC(void) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item) in cJSON_AddItemReferenceToArray() argument
1950 add_item_to_array(array, create_reference(item, &global_hooks)); in cJSON_AddItemReferenceToArray()
1953 CJSON_PUBLIC(void) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item) in cJSON_AddItemReferenceToObject() argument
1960 add_item_to_object(object, string, create_reference(item, &global_hooks), &global_hooks, false); in cJSON_AddItemReferenceToObject()
2071 CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * const item) in cJSON_DetachItemViaPointer() argument
2073 if ((parent == NULL) || (item == NULL)) in cJSON_DetachItemViaPointer()
2078 if (item->prev != NULL) in cJSON_DetachItemViaPointer()
2081 item->prev->next = item->next; in cJSON_DetachItemViaPointer()
2083 if (item->next != NULL) in cJSON_DetachItemViaPointer()
2086 item->next->prev = item->prev; in cJSON_DetachItemViaPointer()
2089 if (item == parent->child) in cJSON_DetachItemViaPointer()
2092 parent->child = item->next; in cJSON_DetachItemViaPointer()
2095 item->prev = NULL; in cJSON_DetachItemViaPointer()
2096 item->next = NULL; in cJSON_DetachItemViaPointer()
2098 return item; in cJSON_DetachItemViaPointer()
2170 CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSO… in cJSON_ReplaceItemViaPointer() argument
2172 if ((parent == NULL) || (replacement == NULL) || (item == NULL)) in cJSON_ReplaceItemViaPointer()
2177 if (replacement == item) in cJSON_ReplaceItemViaPointer()
2182 replacement->next = item->next; in cJSON_ReplaceItemViaPointer()
2183 replacement->prev = item->prev; in cJSON_ReplaceItemViaPointer()
2193 if (parent->child == item) in cJSON_ReplaceItemViaPointer()
2198 item->next = NULL; in cJSON_ReplaceItemViaPointer()
2199 item->prev = NULL; in cJSON_ReplaceItemViaPointer()
2200 cJSON_Delete(item); in cJSON_ReplaceItemViaPointer()
2248 cJSON *item = cJSON_New_Item(&global_hooks); in cJSON_CreateNull() local
2249 if(item) in cJSON_CreateNull()
2251 item->type = cJSON_NULL; in cJSON_CreateNull()
2254 return item; in cJSON_CreateNull()
2259 cJSON *item = cJSON_New_Item(&global_hooks); in cJSON_CreateTrue() local
2260 if(item) in cJSON_CreateTrue()
2262 item->type = cJSON_True; in cJSON_CreateTrue()
2265 return item; in cJSON_CreateTrue()
2270 cJSON *item = cJSON_New_Item(&global_hooks); in cJSON_CreateFalse() local
2271 if(item) in cJSON_CreateFalse()
2273 item->type = cJSON_False; in cJSON_CreateFalse()
2276 return item; in cJSON_CreateFalse()
2281 cJSON *item = cJSON_New_Item(&global_hooks); in cJSON_CreateBool() local
2282 if(item) in cJSON_CreateBool()
2284 item->type = b ? cJSON_True : cJSON_False; in cJSON_CreateBool()
2287 return item; in cJSON_CreateBool()
2292 cJSON *item = cJSON_New_Item(&global_hooks); in cJSON_CreateNumber() local
2293 if(item) in cJSON_CreateNumber()
2295 item->type = cJSON_Number; in cJSON_CreateNumber()
2296 item->valuedouble = num; in cJSON_CreateNumber()
2301 item->valueint = INT_MAX; in cJSON_CreateNumber()
2305 item->valueint = INT_MIN; in cJSON_CreateNumber()
2309 item->valueint = (int)num; in cJSON_CreateNumber()
2313 return item; in cJSON_CreateNumber()
2318 cJSON *item = cJSON_New_Item(&global_hooks); in cJSON_CreateString() local
2319 if(item) in cJSON_CreateString()
2321 item->type = cJSON_String; in cJSON_CreateString()
2322 item->valuestring = (char*)cJSON_strdup((const unsigned char*)string, &global_hooks); in cJSON_CreateString()
2323 if(!item->valuestring) in cJSON_CreateString()
2325 cJSON_Delete(item); in cJSON_CreateString()
2330 return item; in cJSON_CreateString()
2335 cJSON *item = cJSON_New_Item(&global_hooks); in cJSON_CreateStringReference() local
2336 if (item != NULL) in cJSON_CreateStringReference()
2338 item->type = cJSON_String | cJSON_IsReference; in cJSON_CreateStringReference()
2339 item->valuestring = (char*)cast_away_const(string); in cJSON_CreateStringReference()
2342 return item; in cJSON_CreateStringReference()
2347 cJSON *item = cJSON_New_Item(&global_hooks); in cJSON_CreateObjectReference() local
2348 if (item != NULL) { in cJSON_CreateObjectReference()
2349 item->type = cJSON_Object | cJSON_IsReference; in cJSON_CreateObjectReference()
2350 item->child = (cJSON*)cast_away_const(child); in cJSON_CreateObjectReference()
2353 return item; in cJSON_CreateObjectReference()
2357 cJSON *item = cJSON_New_Item(&global_hooks); in cJSON_CreateArrayReference() local
2358 if (item != NULL) { in cJSON_CreateArrayReference()
2359 item->type = cJSON_Array | cJSON_IsReference; in cJSON_CreateArrayReference()
2360 item->child = (cJSON*)cast_away_const(child); in cJSON_CreateArrayReference()
2363 return item; in cJSON_CreateArrayReference()
2368 cJSON *item = cJSON_New_Item(&global_hooks); in cJSON_CreateRaw() local
2369 if(item) in cJSON_CreateRaw()
2371 item->type = cJSON_Raw; in cJSON_CreateRaw()
2372 item->valuestring = (char*)cJSON_strdup((const unsigned char*)raw, &global_hooks); in cJSON_CreateRaw()
2373 if(!item->valuestring) in cJSON_CreateRaw()
2375 cJSON_Delete(item); in cJSON_CreateRaw()
2380 return item; in cJSON_CreateRaw()
2385 cJSON *item = cJSON_New_Item(&global_hooks); in cJSON_CreateArray() local
2386 if(item) in cJSON_CreateArray()
2388 item->type=cJSON_Array; in cJSON_CreateArray()
2391 return item; in cJSON_CreateArray()
2396 cJSON *item = cJSON_New_Item(&global_hooks); in cJSON_CreateObject() local
2397 if (item) in cJSON_CreateObject()
2399 item->type = cJSON_Object; in cJSON_CreateObject()
2402 return item; in cJSON_CreateObject()
2550 CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse) in cJSON_Duplicate() argument
2558 if (!item) in cJSON_Duplicate()
2569 newitem->type = item->type & (~cJSON_IsReference); in cJSON_Duplicate()
2570 newitem->valueint = item->valueint; in cJSON_Duplicate()
2571 newitem->valuedouble = item->valuedouble; in cJSON_Duplicate()
2572 if (item->valuestring) in cJSON_Duplicate()
2574 … newitem->valuestring = (char*)cJSON_strdup((unsigned char*)item->valuestring, &global_hooks); in cJSON_Duplicate()
2580 if (item->string) in cJSON_Duplicate()
2582 …newitem->string = (item->type&cJSON_StringIsConst) ? item->string : (char*)cJSON_strdup((unsigned … in cJSON_Duplicate()
2594 child = item->child; in cJSON_Duplicate()
2699 CJSON_PUBLIC(cJSON_bool) cJSON_IsInvalid(const cJSON * const item) in cJSON_IsInvalid() argument
2701 if (item == NULL) in cJSON_IsInvalid()
2706 return (item->type & 0xFF) == cJSON_Invalid; in cJSON_IsInvalid()
2709 CJSON_PUBLIC(cJSON_bool) cJSON_IsFalse(const cJSON * const item) in cJSON_IsFalse() argument
2711 if (item == NULL) in cJSON_IsFalse()
2716 return (item->type & 0xFF) == cJSON_False; in cJSON_IsFalse()
2719 CJSON_PUBLIC(cJSON_bool) cJSON_IsTrue(const cJSON * const item) in cJSON_IsTrue() argument
2721 if (item == NULL) in cJSON_IsTrue()
2726 return (item->type & 0xff) == cJSON_True; in cJSON_IsTrue()
2730 CJSON_PUBLIC(cJSON_bool) cJSON_IsBool(const cJSON * const item) in cJSON_IsBool() argument
2732 if (item == NULL) in cJSON_IsBool()
2737 return (item->type & (cJSON_True | cJSON_False)) != 0; in cJSON_IsBool()
2739 CJSON_PUBLIC(cJSON_bool) cJSON_IsNull(const cJSON * const item) in cJSON_IsNull() argument
2741 if (item == NULL) in cJSON_IsNull()
2746 return (item->type & 0xFF) == cJSON_NULL; in cJSON_IsNull()
2749 CJSON_PUBLIC(cJSON_bool) cJSON_IsNumber(const cJSON * const item) in cJSON_IsNumber() argument
2751 if (item == NULL) in cJSON_IsNumber()
2756 return (item->type & 0xFF) == cJSON_Number; in cJSON_IsNumber()
2759 CJSON_PUBLIC(cJSON_bool) cJSON_IsString(const cJSON * const item) in cJSON_IsString() argument
2761 if (item == NULL) in cJSON_IsString()
2766 return (item->type & 0xFF) == cJSON_String; in cJSON_IsString()
2769 CJSON_PUBLIC(cJSON_bool) cJSON_IsArray(const cJSON * const item) in cJSON_IsArray() argument
2771 if (item == NULL) in cJSON_IsArray()
2776 return (item->type & 0xFF) == cJSON_Array; in cJSON_IsArray()
2779 CJSON_PUBLIC(cJSON_bool) cJSON_IsObject(const cJSON * const item) in cJSON_IsObject() argument
2781 if (item == NULL) in cJSON_IsObject()
2786 return (item->type & 0xFF) == cJSON_Object; in cJSON_IsObject()
2789 CJSON_PUBLIC(cJSON_bool) cJSON_IsRaw(const cJSON * const item) in cJSON_IsRaw() argument
2791 if (item == NULL) in cJSON_IsRaw()
2796 return (item->type & 0xFF) == cJSON_Raw; in cJSON_IsRaw()
2945 cJSON *item = object; in cJSON_GetObjectItemByPath() local
2950 item = cJSON_GetObjectItem(item, next); in cJSON_GetObjectItemByPath()
2951 if (item) { in cJSON_GetObjectItemByPath()
2952 item = cJSON_GetArrayItem(item, atoi(arr_ptr)); in cJSON_GetObjectItemByPath()
2955 item = cJSON_GetObjectItem(item, next); in cJSON_GetObjectItemByPath()
2957 if (item == NULL) { in cJSON_GetObjectItemByPath()
2966 return item; in cJSON_GetObjectItemByPath()