Lines Matching defs:object

501 CJSON_PUBLIC(long long) cJSON_SetInt64NumberValue(cJSON * const object, const long long integer)
503 if (object == NULL)
509 if (!(object->type & cJSON_Number) || !(object->type & cJSON_IsInt64))
514 object->valueint = integer;
515 object->valuedouble = (double)integer;
523 CJSON_PUBLIC(double) cJSON_SetNumberHelper(cJSON *object, double number)
527 object->valueint = LLONG_MAX;
531 object->valueint = LLONG_MIN;
535 object->valueint = (long long)number;
538 return object->valuedouble = number;
542 CJSON_PUBLIC(double) cJSON_SetNumberHelper(cJSON *object, double number)
546 object->valueint = INT_MAX;
550 object->valueint = INT_MIN;
554 object->valueint = (int)number;
557 return object->valuedouble = number;
561 CJSON_PUBLIC(char*) cJSON_SetValuestring(cJSON *object, const char *valuestring)
564 /* if object's type is not cJSON_String or is cJSON_IsReference, it should not set valuestring */
565 if ((object == NULL) || !(object->type & cJSON_String) || (object->type & cJSON_IsReference))
569 /* return NULL if the object is corrupted */
570 if (object->valuestring == NULL || valuestring == NULL)
574 if (strlen(valuestring) <= strlen(object->valuestring))
576 strcpy(object->valuestring, valuestring);
577 return object->valuestring;
584 if (object->valuestring != NULL)
586 cJSON_free(object->valuestring);
588 object->valuestring = copy;
1337 /* Parse an object - create a new root, and populate. */
1600 /* object */
1843 /* Build an object from the text. */
1857 goto fail; /* not an object */
1864 goto success; /* empty object */
1920 goto fail; /* invalid object */
1936 goto fail; /* expected end of object */
1961 /* Render an object to text. */
2075 /* Get Array size/item / object item. */
2128 static cJSON *get_object_item(const cJSON * const object, const char * const name, const cJSON_bool case_sensitive)
2132 if ((object == NULL) || (name == NULL))
2137 current_element = object->child;
2160 CJSON_PUBLIC(cJSON *) cJSON_GetObjectItem(const cJSON * const object, const char * const string)
2162 return get_object_item(object, string, false);
2165 CJSON_PUBLIC(cJSON *) cJSON_GetObjectItemCaseSensitive(const cJSON * const object, const char * const string)
2167 return get_object_item(object, string, true);
2170 CJSON_PUBLIC(cJSON_bool) cJSON_HasObjectItem(const cJSON *object, const char *string)
2172 return cJSON_GetObjectItem(object, string) ? 1 : 0;
2237 /* Add item to array/object. */
2259 static cJSON_bool add_item_to_object(cJSON * const object, const char * const string, cJSON * const item, const internal_hooks * const hooks, const cJSON_bool constant_key)
2264 if ((object == NULL) || (string == NULL) || (item == NULL) || (object == item))
2293 return add_item_to_array(object, item);
2296 CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item)
2298 return add_item_to_object(object, string, item, &global_hooks, false);
2301 /* Add an item to an object with constant string as key */
2302 CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item)
2304 return add_item_to_object(object, string, item, &global_hooks, true);
2317 CJSON_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item)
2319 if ((object == NULL) || (string == NULL))
2324 return add_item_to_object(object, string, create_reference(item, &global_hooks), &global_hooks, false);
2327 CJSON_PUBLIC(cJSON*) cJSON_AddNullToObject(cJSON * const object, const char * const name)
2330 if (add_item_to_object(object, name, null, &global_hooks, false))
2339 CJSON_PUBLIC(cJSON*) cJSON_AddTrueToObject(cJSON * const object, const char * const name)
2342 if (add_item_to_object(object, name, true_item, &global_hooks, false))
2351 CJSON_PUBLIC(cJSON*) cJSON_AddFalseToObject(cJSON * const object, const char * const name)
2354 if (add_item_to_object(object, name, false_item, &global_hooks, false))
2363 CJSON_PUBLIC(cJSON*) cJSON_AddBoolToObject(cJSON * const object, const char * const name, const cJSON_bool boolean)
2366 if (add_item_to_object(object, name, bool_item, &global_hooks, false))
2376 CJSON_PUBLIC(cJSON*) cJSON_AddInt64NumberToObject(cJSON * const object, const char * const name, const long long integer)
2379 if (add_item_to_object(object, name, int_item, &global_hooks, false))
2389 CJSON_PUBLIC(cJSON*) cJSON_AddNumberToObject(cJSON * const object, const char * const name, const double number)
2392 if (add_item_to_object(object, name, number_item, &global_hooks, false))
2401 CJSON_PUBLIC(cJSON*) cJSON_AddStringToObject(cJSON * const object, const char * const name, const char * const string)
2404 if (add_item_to_object(object, name, string_item, &global_hooks, false))
2413 CJSON_PUBLIC(cJSON*) cJSON_AddRawToObject(cJSON * const object, const char * const name, const char * const raw)
2416 if (add_item_to_object(object, name, raw_item, &global_hooks, false))
2425 CJSON_PUBLIC(cJSON*) cJSON_AddObjectToObject(cJSON * const object, const char * const name)
2428 if (add_item_to_object(object, name, object_item, &global_hooks, false))
2437 CJSON_PUBLIC(cJSON*) cJSON_AddArrayToObject(cJSON * const object, const char * const name)
2440 if (add_item_to_object(object, name, array, &global_hooks, false))
2500 CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObject(cJSON *object, const char *string)
2502 cJSON *to_detach = cJSON_GetObjectItem(object, string);
2504 return cJSON_DetachItemViaPointer(object, to_detach);
2507 CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObjectCaseSensitive(cJSON *object, const char *string)
2509 cJSON *to_detach = cJSON_GetObjectItemCaseSensitive(object, string);
2511 return cJSON_DetachItemViaPointer(object, to_detach);
2514 CJSON_PUBLIC(void) cJSON_DeleteItemFromObject(cJSON *object, const char *string)
2516 cJSON_Delete(cJSON_DetachItemFromObject(object, string));
2519 CJSON_PUBLIC(void) cJSON_DeleteItemFromObjectCaseSensitive(cJSON *object, const char *string)
2521 cJSON_Delete(cJSON_DetachItemFromObjectCaseSensitive(object, string));
2524 /* Replace array/object items with new ones. */
2618 static cJSON_bool replace_item_in_object(cJSON *object, const char *string, cJSON *replacement, cJSON_bool case_sensitive)
2638 return cJSON_ReplaceItemViaPointer(object, get_object_item(object, string, case_sensitive), replacement);
2641 CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObject(cJSON *object, const char *string, cJSON *newitem)
2643 return replace_item_in_object(object, string, newitem, false);
2646 CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object, const char *string, cJSON *newitem)
2648 return replace_item_in_object(object, string, newitem, true);
3461 CJSON_PUBLIC(void) cJSON_free(void *object)
3463 global_hooks.deallocate(object);