jx.h

Go to the documentation of this file.
00001 /*
00002 Copyright (C) 2015- The University of Notre Dame
00003 This software is distributed under the GNU General Public License.
00004 See the file COPYING for details.
00005 */
00006 
00007 #ifndef JX_H
00008 #define JX_H
00009 
00039 #include <stdint.h>
00040 #include <assert.h>
00041 
00044 typedef enum {
00045         JX_NULL,        
00046         JX_BOOLEAN,     
00047         JX_INTEGER,     
00048         JX_DOUBLE,      
00049         JX_STRING,      
00050         JX_SYMBOL,      
00051         JX_ARRAY,       
00052         JX_OBJECT,      
00053 } jx_type_t;
00054 
00055 typedef int64_t jx_int_t;
00056 
00059 struct jx_item {
00060         struct jx      *value;  
00061         struct jx_item *next;   
00062 };
00063 
00066 struct jx_pair {
00067         struct jx      *key;    
00068         struct jx      *value;  
00069         struct jx_pair *next;   
00070 };
00071 
00074 struct jx {
00075         jx_type_t type;               
00076         union {
00077                 int boolean_value;      
00078                 jx_int_t integer_value; 
00079                 double double_value;   
00080                 char * string_value;  
00081                 char * symbol_name;   
00082                 struct jx_item *items;  
00083                 struct jx_pair *pairs;  
00084         } u;
00085 };
00086 
00088 struct jx * jx_null();
00089 
00091 struct jx * jx_boolean( int boolean_value );
00092 
00094 struct jx * jx_integer( jx_int_t integer_value );
00095 
00097 struct jx * jx_double( double double_value );
00098 
00100 struct jx * jx_string( const char *string_value );
00101 
00103 struct jx * jx_format( const char *fmt, ... );
00104 
00107 struct jx * jx_symbol( const char *symbol_name );
00108 
00110 struct jx * jx_array( struct jx_item *items );
00111 
00113 struct jx * jx_arrayv( struct jx *value, ... );
00114 
00116 struct jx * jx_object( struct jx_pair *pairs );
00117 
00119 struct jx_pair * jx_pair( struct jx *key, struct jx *value, struct jx_pair *next );
00120 
00122 struct jx_item * jx_item( struct jx *value, struct jx_item *next );
00123 
00125 int jx_istype( struct jx *j, jx_type_t type );
00126 
00129 int jx_equals( struct jx *j, struct jx *k );
00130 
00133 struct jx * jx_copy( struct jx *j );
00134 
00136 void jx_delete( struct jx *j );
00137 
00139 void jx_pair_delete( struct jx_pair *p );
00140 
00142 void jx_item_delete( struct jx_item *i );
00143 
00145 struct jx * jx_remove( struct jx *object, struct jx *key );
00146 
00148 int jx_insert( struct jx *object, struct jx *key, struct jx *value );
00149 
00151 void jx_insert_integer( struct jx *object, const char *key, jx_int_t value );
00152 
00154 void jx_insert_double( struct jx *object, const char *key, double value );
00155 
00157 void jx_insert_string( struct jx *object, const char *key, const char *value );
00158 
00160 struct jx * jx_lookup( struct jx *object, const char *key );
00161 
00163 const char * jx_lookup_string( struct jx *object, const char *key );
00164 
00166 jx_int_t jx_lookup_integer( struct jx *object, const char *key );
00167 
00169 double jx_lookup_double( struct jx *object, const char *key );
00170 
00172 void jx_array_insert( struct jx *array, struct jx *value );
00173 
00175 void jx_array_append( struct jx *array, struct jx *value );
00176 
00178 int jx_is_constant( struct jx *j );
00179 
00181 void jx_export( struct jx *j );
00182 
00187 typedef struct jx * (*jx_eval_func_t) ( const char *ident );
00188 
00193 struct jx * jx_evaluate( struct jx *j, jx_eval_func_t evaluator );
00194 
00195 #endif

Generated on 24 Feb 2016 for cctools by  doxygen 1.6.1