diff options
author | Michael Clark <michael@metaparadigm.com> | 2007-03-13 08:26:20 +0000 |
---|---|---|
committer | Michael Clark <michael@metaparadigm.com> | 2007-03-13 08:26:20 +0000 |
commit | 4504df71178fe7a0eb8e7c37fa548b7c853a800f (patch) | |
tree | b5c804143276475f469429ad2f7e6c7de9584743 /json_object.h | |
parent | f0d08887b857fce1fe95a68d29eb7a07cd527d7c (diff) | |
download | json-c-4504df71178fe7a0eb8e7c37fa548b7c853a800f.tar.gz |
* printbuf.c - C. Watford (christopher dot watford at gmail dot com)
Added a Win32/Win64 compliant implementation of vasprintf
* debug.c - C. Watford (christopher dot watford at gmail dot com)
Removed usage of vsyslog on Win32/Win64 systems, needs to be handled
by a configure script
* json_object.c - C. Watford (christopher dot watford at gmail dot com)
Added scope operator to wrap usage of json_object_object_foreach, this
needs to be rethought to be more ANSI C friendly
* json_object.h - C. Watford (christopher dot watford at gmail dot com)
Added Microsoft C friendly version of json_object_object_foreach
* json_tokener.c - C. Watford (christopher dot watford at gmail dot com)
Added a Win32/Win64 compliant implementation of strndup
* json_util.c - C. Watford (christopher dot watford at gmail dot com)
Added cast and mask to suffice size_t v. unsigned int conversion
correctness
* json_tokener.c - sign reversal issue on error info for nested object parse
spotted by Johan Bj�rklund (johbjo09 at kth.se)
* json_object.c - escape " in json_escape_str
* Change to automake and libtool to build shared and static library
Michael Clark <michael@metaparadigm.com>
git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@4 327403b1-1117-474d-bef2-5cb71233fd97
Diffstat (limited to 'json_object.h')
-rw-r--r-- | json_object.h | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/json_object.h b/json_object.h index 9fc9bd0..0f32ead 100644 --- a/json_object.h +++ b/json_object.h @@ -1,5 +1,5 @@ /* - * $Id: json_object.h,v 1.8 2004/08/07 04:21:27 mclark Exp $ + * $Id: json_object.h,v 1.9 2005/06/14 22:41:51 mclark Exp $ * * Copyright Metaparadigm Pte. Ltd. 2004. * Michael Clark <michael@metaparadigm.com> @@ -19,6 +19,8 @@ #ifndef _json_object_h_ #define _json_object_h_ +#include "config.h" + #define JSON_OBJECT_DEF_HASH_ENTIRES 16 #undef FALSE @@ -37,6 +39,7 @@ struct printbuf; struct lh_table; struct array_list; struct json_object; +struct json_object_iter; /* supported object types */ @@ -143,14 +146,30 @@ extern struct json_object* json_object_object_get(struct json_object* this, extern void json_object_object_del(struct json_object* this, char *key); /** Iterate through all keys and values of an object - * @param this the json_object instance + * @param obj the json_object instance * @param key the local name for the char* key variable defined in the body * @param val the local name for the json_object* object variable defined in the body */ -#define json_object_object_foreach(obj,key,val) \ -char *key; struct json_object *val; \ -for(struct lh_entry *entry = json_object_get_object(obj)->head; ({ if(entry) { key = (char*)entry->k; val = (struct json_object*)entry->v; } ; entry; }); entry = entry->next ) +#if defined(__GNUC__) && !defined(__STRICT_ANSI__) + +# define json_object_object_foreach(obj,key,val) \ + char *key; struct json_object *val; \ + for(struct lh_entry *entry = json_object_get_object(obj)->head; ({ if(entry) { key = (char*)entry->k; val = (struct json_object*)entry->v; } ; entry; }); entry = entry->next ) + +#else /* ANSI C or MSC */ +# define json_object_object_foreach(obj,key,val) \ + char *key; struct json_object *val; struct lh_entry *entry; \ + for(entry = json_object_get_object(obj)->head; (entry ? (key = (char*)entry->k, val = (struct json_object*)entry->v, entry) : 0); entry = entry->next) + +#endif /* defined(__GNUC__) && !defined(__STRICT_ANSI__) */ + +/** Iterate through all keys and values of an object (ANSI C Safe) + * @param obj the json_object instance + * @param iter the object iterator + */ +#define json_object_object_foreachC(obj,iter) \ + for(iter.entry = json_object_get_object(obj)->head; (iter.entry ? (iter.key = (char*)iter.entry->k, iter.val = (struct json_object*)iter.entry->v, iter.entry) : 0); iter.entry = iter.entry->next) /* Array type methods */ |