Parcourir la source

Tidy comments. Add cJSON_SetIntValue.

git-svn-id: http://svn.code.sf.net/p/cjson/code@53 e3330c51-1366-4df0-8b21-3ccf24e3d50e
Dave Gamble il y a 12 ans
Parent
commit
15adf71272
1 fichiers modifiés avec 5 ajouts et 2 suppressions
  1. 5 2
      cJSON.h

+ 5 - 2
cJSON.h

@@ -120,10 +120,10 @@ extern cJSON *cJSON_Duplicate(cJSON *item,int recurse);
 need to be released. With recurse!=0, it will duplicate any children connected to the item.
 The item->next and ->prev pointers are always zero on return from Duplicate. */
 
-/* ParseWithOpts allows you to require (and check) that the JSON is null terminated, and to retrieve the pointer to the final byte parsed */
+/* ParseWithOpts allows you to require (and check) that the JSON is null terminated, and to retrieve the pointer to the final byte parsed. */
 extern cJSON *cJSON_ParseWithOpts(const char *value,const char **return_parse_end,int require_null_terminated);
 
-
+/* Macros for creating things quickly. */
 #define cJSON_AddNullToObject(object,name)		cJSON_AddItemToObject(object, name, cJSON_CreateNull())
 #define cJSON_AddTrueToObject(object,name)		cJSON_AddItemToObject(object, name, cJSON_CreateTrue())
 #define cJSON_AddFalseToObject(object,name)		cJSON_AddItemToObject(object, name, cJSON_CreateFalse())
@@ -131,6 +131,9 @@ extern cJSON *cJSON_ParseWithOpts(const char *value,const char **return_parse_en
 #define cJSON_AddNumberToObject(object,name,n)	cJSON_AddItemToObject(object, name, cJSON_CreateNumber(n))
 #define cJSON_AddStringToObject(object,name,s)	cJSON_AddItemToObject(object, name, cJSON_CreateString(s))
 
+/* When assigning an integer value, it needs to be propagated to valuedouble too. */
+#define cJSON_SetIntValue(object,val)			((object)?(object)->valueint=(object)->valuedouble=(val):(val))
+
 #ifdef __cplusplus
 }
 #endif