[Opensrf-commits] r1093 - in trunk: include/opensrf src/libopensrf

svn at svn.open-ils.org svn at svn.open-ils.org
Sun Sep 30 10:13:44 EDT 2007


Author: miker
Date: 2007-09-30 10:03:19 -0400 (Sun, 30 Sep 2007)
New Revision: 1093

Modified:
   trunk/include/opensrf/osrf_json.h
   trunk/src/libopensrf/osrf_json_object.c
Log:
Patch from Scott McKellar which introduces a const-accepting and -returning
version of jsonObjectGetKey.  This is the first step in a plan to push
const-correctness on the OpenSRF stack when dealing with complex objects.  The
hope is that this will increase the utility of compile-time checks in new
client code.




Modified: trunk/include/opensrf/osrf_json.h
===================================================================
--- trunk/include/opensrf/osrf_json.h	2007-09-26 15:17:36 UTC (rev 1092)
+++ trunk/include/opensrf/osrf_json.h	2007-09-30 14:03:19 UTC (rev 1093)
@@ -224,12 +224,12 @@
  * Retrieves the object at the given key
  */
 jsonObject* jsonObjectGetKey( const jsonObject* obj, const char* key );
+const jsonObject* jsonObjectGetKeyConst( const jsonObject* obj, const char* key );
 
 
 
 
 
-
 /** Allocates a new iterator 
 	@param obj The object over which to iterate.
 */

Modified: trunk/src/libopensrf/osrf_json_object.c
===================================================================
--- trunk/src/libopensrf/osrf_json_object.c	2007-09-26 15:17:36 UTC (rev 1092)
+++ trunk/src/libopensrf/osrf_json_object.c	2007-09-30 14:03:19 UTC (rev 1093)
@@ -132,6 +132,11 @@
 	return osrfHashGet( obj->value.h, key);
 }
 
+const jsonObject* jsonObjectGetKeyConst( const jsonObject* obj, const char* key ) {
+	if(!(obj && obj->type == JSON_HASH && obj->value.h && key)) return NULL;
+	return osrfHashGet( obj->value.h, key);
+}
+
 char* jsonObjectToJSON( const jsonObject* obj ) {
 	jsonObject* obj2 = jsonObjectEncodeClass( (jsonObject*) obj);
 	char* json = jsonObjectToJSONRaw(obj2);



More information about the opensrf-commits mailing list